📄 amp_8cpp-source.html
字号:
<a name="l00334"></a>00334 err = <a class="code" href="classAmp.html#z1_8">ClearFaults</a>();<a name="l00335"></a>00335 <span class="keywordflow">if</span>( err ) <span class="keywordflow">goto</span> retErr;<a name="l00336"></a>00336 <a name="l00337"></a>00337 <span class="comment">// Now, try to enable the amplifier if requested</span><a name="l00338"></a>00338 <span class="keywordflow">if</span>( settings.<a class="code" href="classAmpSettings.html#o9">enableOnInit</a> )<a name="l00339"></a>00339 {<a name="l00340"></a>00340 <a class="code" href="CML__AmpDef_8h.html#a399">AMP_EVENT</a> evnt;<a name="l00341"></a>00341 <a name="l00342"></a>00342 <a class="code" href="CML_8h.html#a0">cml</a>.<a class="code" href="classCopleyMotionLibrary.html#a8">Debug</a>( <span class="stringliteral">"Amp %d, Enabling amp\n"</span>, nodeID );<a name="l00343"></a>00343 <a name="l00344"></a>00344 <span class="comment">// Wait for any non-latching errors to clear.</span><a name="l00345"></a>00345 <span class="comment">// This can occure on the Xenus as it's high</span><a name="l00346"></a>00346 <span class="comment">// voltage comes up. I'll wait 400ms which </span><a name="l00347"></a>00347 <span class="comment">// is about twice what this should take max.</span><a name="l00348"></a>00348 <a class="code" href="classEventNone.html">EventNone</a> e(<a class="code" href="CML__AmpDef_8h.html#a399a250">AMPEVENT_ERROR</a>);<a name="l00349"></a>00349 e.<a class="code" href="classEvent.html#a7">Wait</a>( <a class="code" href="classAmp.html#p0">eventMap</a>, 400 );<a name="l00350"></a>00350 <a name="l00351"></a>00351 <span class="comment">// Now, try to enable the amplifier.</span><a name="l00352"></a>00352 err = <a class="code" href="classAmp.html#z1_3">Enable</a>();<a name="l00353"></a>00353 <a name="l00354"></a>00354 <span class="comment">// On failure, try to return a useful error</span><a name="l00355"></a>00355 <span class="comment">// message rather then just a timeout.</span><a name="l00356"></a>00356 <span class="keywordflow">if</span>( err )<a name="l00357"></a>00357 {<a name="l00358"></a>00358 <span class="keywordflow">if</span>( err == &<a class="code" href="classThreadError.html#s2">ThreadError::Timeout</a> )<a name="l00359"></a>00359 err = <a class="code" href="classAmp.html#z14_5">GetErrorStatus</a>( <span class="keyword">false</span> );<a name="l00360"></a>00360 <span class="keywordflow">goto</span> retErr;<a name="l00361"></a>00361 }<a name="l00362"></a>00362 <a name="l00363"></a>00363 <span class="comment">// Make sure the amplifier is really enabled.</span><a name="l00364"></a>00364 <span class="comment">// The fact that the Enable() function returned success</span><a name="l00365"></a>00365 <span class="comment">// means that the amplifier is software enabled (i.e. </span><a name="l00366"></a>00366 <span class="comment">// allowed to enable if possible), but it could still be</span><a name="l00367"></a>00367 <span class="comment">// disabled by other factors.</span><a name="l00368"></a>00368 err = <a class="code" href="classAmp.html#z14_4">GetEventMask</a>( evnt );<a name="l00369"></a>00369 <span class="keywordflow">if</span>( err ) <span class="keywordflow">goto</span> retErr;<a name="l00370"></a>00370 <a name="l00371"></a>00371 <span class="keywordflow">if</span>( evnt & <a class="code" href="CML__AmpDef_8h.html#a399a254">AMPEVENT_DISABLED</a> )<a name="l00372"></a>00372 {<a name="l00373"></a>00373 <span class="comment">// Check the lower level 'event status' register</span><a name="l00374"></a>00374 <span class="comment">// returned with the most recent status PDO.</span><a name="l00375"></a>00375 <span class="comment">// This should give me more info on what's holding</span><a name="l00376"></a>00376 <span class="comment">// me up.</span><a name="l00377"></a>00377 <a class="code" href="CML__AmpDef_8h.html#a398">EVENT_STATUS</a> estat = (<a class="code" href="CML__AmpDef_8h.html#a398">EVENT_STATUS</a>)statPdo.<a class="code" href="classTPDO__Status.html#o1">estat</a>.<a class="code" href="classPmap32.html#a5">Read</a>();<a name="l00378"></a>00378 <a name="l00379"></a>00379 <span class="comment">// The only good reason for the amplifier to be disabled</span><a name="l00380"></a>00380 <span class="comment">// at this point is if an input pin is configured to disable</span><a name="l00381"></a>00381 <span class="comment">// it. If that's not the case, I'll give the amplifier a</span><a name="l00382"></a>00382 <span class="comment">// little time to enable on it's own. This is helpful for the</span><a name="l00383"></a>00383 <span class="comment">// Xenus amplifier which has a built in delay after closing</span><a name="l00384"></a>00384 <span class="comment">// it's high voltage relay.</span><a name="l00385"></a>00385 <span class="keywordflow">if</span>( !(estat & <a class="code" href="CML__AmpDef_8h.html#a398a226">ESTAT_DISABLE_INPUT</a>) )<a name="l00386"></a>00386 {<a name="l00387"></a>00387 <a class="code" href="classEventNone.html">EventNone</a> e(<a class="code" href="CML__AmpDef_8h.html#a399a254">AMPEVENT_DISABLED</a>);<a name="l00388"></a>00388 e.<a class="code" href="classEvent.html#a7">Wait</a>( <a class="code" href="classAmp.html#p0">eventMap</a>, 200 );<a name="l00389"></a>00389 }<a name="l00390"></a>00390 }<a name="l00391"></a>00391 }<a name="l00392"></a>00392 <a name="l00393"></a>00393 retErr:<a name="l00394"></a>00394 <span class="keywordflow">if</span>( err )<a name="l00395"></a>00395 <a class="code" href="CML_8h.html#a0">cml</a>.<a class="code" href="classCopleyMotionLibrary.html#a9">Warn</a>( <span class="stringliteral">"Amp %d failed init %s\n"</span>, nodeID, err-><a class="code" href="classError.html#a0">toString</a>() );<a name="l00396"></a>00396 <span class="keywordflow">else</span><a name="l00397"></a>00397 <a class="code" href="CML_8h.html#a0">cml</a>.<a class="code" href="classCopleyMotionLibrary.html#a8">Debug</a>( <span class="stringliteral">"Amp %d, init done\n"</span>, nodeID );<a name="l00398"></a>00398 <a name="l00399"></a>00399 <span class="keywordflow">return</span> err;<a name="l00400"></a>00400 }<a name="l00401"></a>00401 <a name="l00402"></a>00402 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00403"></a>00403 <span class="comment">/**</span><a name="l00404"></a>00404 <span class="comment"> Re-initialize an amplifier. This function simply calls Amp::Init using </span><a name="l00405"></a>00405 <span class="comment"> the same parameters that were initially passed.</span><a name="l00406"></a>00406 <span class="comment"> @return A pointer to an error object, or NULL on success.</span><a name="l00407"></a>00407 <span class="comment"> */</span><a name="l00408"></a>00408 <span class="comment">/***************************************************************************/</span><a name="l00409"></a><a class="code" href="classAmp.html#z0_6">00409</a> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classAmp.html#z0_6">Amp::ReInit</a>( <span class="keywordtype">void</span> )<a name="l00410"></a>00410 {<a name="l00411"></a>00411 <a class="code" href="CML_8h.html#a0">cml</a>.<a class="code" href="classCopleyMotionLibrary.html#a8">Debug</a>( <span class="stringliteral">"Amp %d ReInit\n"</span>, <a class="code" href="classNode.html#a38">GetNodeID</a>() );<a name="l00412"></a>00412 <span class="keywordflow">if</span>( !<a class="code" href="classReceiver.html#p0">co</a> ) <span class="keywordflow">return</span> &<a class="code" href="classCanOpenError.html#s8">CanOpenError::NotInitialized</a>;<a name="l00413"></a>00413 <span class="keywordflow">return</span> <a class="code" href="classAmp.html#z0_4">Init</a>( *<a class="code" href="classReceiver.html#p0">co</a>, <a class="code" href="classNode.html#a38">GetNodeID</a>(), initialSettings );<a name="l00414"></a>00414 }<a name="l00415"></a>00415 <a name="l00416"></a>00416 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00417"></a>00417 <span class="comment">/**</span><a name="l00418"></a>00418 <span class="comment"> Reset the amplifier object. This function should be used for Amp objects </span><a name="l00419"></a>00419 <span class="comment"> instead of Node::ResetNode(). It resets the amplifier and re-initializes </span><a name="l00420"></a>00420 <span class="comment"> the amplifier object.</span><a name="l00421"></a>00421 <span class="comment"> @return A pointer to an error object, or NULL on success.</span><a name="l00422"></a>00422 <span class="comment"> */</span><a name="l00423"></a>00423 <span class="comment">/***************************************************************************/</span><a name="l00424"></a><a class="code" href="classAmp.html#z0_7">00424</a> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classAmp.html#z0_7">Amp::Reset</a>( <span class="keywordtype">void</span> )<a name="l00425"></a>00425 {<a name="l00426"></a>00426 <a class="code" href="CML_8h.html#a0">cml</a>.<a class="code" href="classCopleyMotionLibrary.html#a8">Debug</a>( <span class="stringliteral">"Amp %d Reset\n"</span>, <a class="code" href="classNode.html#a38">GetNodeID</a>() );<a name="l00427"></a>00427 <span class="keywordtype">bool</span> oldResetOnInit = initialSettings.<a class="code" href="classAmpSettings.html#o11">resetOnInit</a>;<a name="l00428"></a>00428 initialSettings.<a class="code" href="classAmpSettings.html#o11">resetOnInit</a> = <span class="keyword">true</span>;<a name="l00429"></a>00429 <a name="l00430"></a>00430 <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *err = <a class="code" href="classAmp.html#z0_6">ReInit</a>();<a name="l00431"></a>00431 <a name="l00432"></a>00432 initialSettings.<a class="code" href="classAmpSettings.html#o11">resetOnInit</a> = oldResetOnInit;<a name="l00433"></a>00433 <span class="keywordflow">return</span> err;<a name="l00434"></a>00434 }<a name="l00435"></a>00435 <a name="l00436"></a>00436 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00437"></a>00437 <span class="comment">/**</span><a name="l00438"></a>00438 <span class="comment"> Execute a home move. The various homing parameters are passed in the</span><a name="l00439"></a>00439 <span class="comment"> HomeConfig structure.</span><a name="l00440"></a>00440 <span class="comment"></span><a name="l00441"></a>00441 <span class="comment"> This function simply programs all the homing parameters passed in the </span><a name="l00442"></a>00442 <span class="comment"> structure, then calls Amp::GoHome().</span><a name="l00443"></a>00443 <span class="comment"></span><a name="l00444"></a>00444 <span class="comment"> @param cfg The homing configuration parameter structure.</span><a name="l00445"></a>00445 <span class="comment"> @return A pointer to an error object, or NULL on success.</span><a name="l00446"></a>00446 <span class="comment"> */</span><a name="l00447"></a>00447 <span class="comment">/***************************************************************************/</span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -