⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linkage_8cpp-source.html

📁 美国COPLEY驱动器,程序开发工具之一.
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00388"></a>00388 <span class="preprocessor"></span>   <a class="code" href="classLinkage.html#a17">ClearLatchedError</a>();<a name="l00389"></a>00389 <a name="l00390"></a>00390    <span class="keywordflow">if</span>( p.<a class="code" href="classPointN.html#a0">getDim</a>() != <a class="code" href="classLinkage.html#a20">GetAxesCount</a>() )<a name="l00391"></a>00391       <span class="keywordflow">return</span> &amp;<a class="code" href="classLinkError.html#s4">LinkError::AxisCount</a>;<a name="l00392"></a>00392 <a name="l00393"></a>00393    <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *err;<a name="l00394"></a>00394 <a name="l00395"></a>00395    <a class="code" href="classPoint.html">Point&lt;CML_MAX_AMPS_PER_LINK&gt;</a> startPos;<a name="l00396"></a>00396    startPos.<a class="code" href="classPoint.html#a4">setDim</a>( <a class="code" href="classLinkage.html#a20">GetAxesCount</a>() );<a name="l00397"></a>00397 <a name="l00398"></a>00398    err = <a class="code" href="classLinkage.html#a21">GetPositionCommand</a>( startPos );<a name="l00399"></a>00399    <span class="keywordflow">if</span>( err ) <span class="keywordflow">return</span> err;<a name="l00400"></a>00400 <a name="l00401"></a>00401    err = scurve.<a class="code" href="classLinkTrjScurve.html#a1">Calculate</a>( startPos, p, vel, acc, dec, jrk );<a name="l00402"></a>00402    <span class="keywordflow">if</span>( err ) <span class="keywordflow">return</span> err;<a name="l00403"></a>00403 <a name="l00404"></a>00404    <span class="keywordflow">return</span> SendTrajectory( scurve, start );<a name="l00405"></a>00405 <span class="preprocessor">#endif</span><a name="l00406"></a>00406 <span class="preprocessor"></span>}<a name="l00407"></a>00407 <a name="l00408"></a>00408 <span class="preprocessor">#ifdef CML_LINKAGE_TRJ_BUFFER_SIZE</span><a name="l00409"></a>00409 <span class="preprocessor"></span><span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00410"></a>00410 <span class="comment">/**</span><a name="l00411"></a>00411 <span class="comment">  Upload a multi-axis PVT move trajectory to the linkage and optionally start the move.</span><a name="l00412"></a>00412 <span class="comment"></span><a name="l00413"></a>00413 <span class="comment">  @param trj Reference to the linkage trajectory to be used.  A local</span><a name="l00414"></a>00414 <span class="comment">  pointer to this trajectory will be stored if the entire profile will </span><a name="l00415"></a>00415 <span class="comment">  not fit in the amplifiers on-board buffer.  This pointer will be kept</span><a name="l00416"></a>00416 <span class="comment">  until the entire profile has been uploaded to the linkage.  It is therefore</span><a name="l00417"></a>00417 <span class="comment">  important to ensure that the trajectory object passed here will remain</span><a name="l00418"></a>00418 <span class="comment">  valid (i.e. not be deallocated) until the linkage has called the LinkTrajectory.Finish()</span><a name="l00419"></a>00419 <span class="comment">  method.</span><a name="l00420"></a>00420 <span class="comment"></span><a name="l00421"></a>00421 <span class="comment">  @param start If true (the default), the profile will be started by this call.</span><a name="l00422"></a>00422 <span class="comment">               If false, the profile will be uploaded, but not started.  In that case</span><a name="l00423"></a>00423 <span class="comment">               the move may be later started by a call to Linkage::StartMove.</span><a name="l00424"></a>00424 <span class="comment"></span><a name="l00425"></a>00425 <span class="comment">  @return An error object.</span><a name="l00426"></a>00426 <span class="comment">  */</span><a name="l00427"></a>00427 <span class="comment">/***************************************************************************/</span><a name="l00428"></a>00428 <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *Linkage::SendTrajectory( <a class="code" href="classLinkTrajectory.html">LinkTrajectory</a> &amp;trj, <span class="keywordtype">bool</span> start )<a name="l00429"></a>00429 {<a name="l00430"></a>00430    <a class="code" href="classLinkage.html#a17">ClearLatchedError</a>();<a name="l00431"></a>00431 <a name="l00432"></a>00432    linkTrjPtr = &amp;trj;<a name="l00433"></a>00433    <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="classLinkage.html#a20">GetAxesCount</a>(); i++ )<a name="l00434"></a>00434    {<a name="l00435"></a>00435       <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *err = amp[i]-&gt;<a class="code" href="classAmp.html#z13_0">SendTrajectory</a>( ampTrj[i], <span class="keyword">false</span> );<a name="l00436"></a>00436       <span class="keywordflow">if</span>( err )<a name="l00437"></a>00437     <span class="keywordflow">return</span> LatchError( err, i );<a name="l00438"></a>00438    }<a name="l00439"></a>00439 <a name="l00440"></a>00440    <span class="keywordflow">if</span>( start )<a name="l00441"></a>00441       <span class="keywordflow">return</span> <a class="code" href="classLinkage.html#a10">StartMove</a>();<a name="l00442"></a>00442 <a name="l00443"></a>00443    <span class="keywordflow">return</span> 0;<a name="l00444"></a>00444 }<a name="l00445"></a>00445 <span class="preprocessor">#endif</span><a name="l00446"></a>00446 <span class="preprocessor"></span><a name="l00447"></a>00447 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00448"></a>00448 <span class="comment">/**</span><a name="l00449"></a>00449 <span class="comment">  Start the moves that have already been programmed into all</span><a name="l00450"></a>00450 <span class="comment">  axes of this linkage.</span><a name="l00451"></a>00451 <span class="comment"></span><a name="l00452"></a>00452 <span class="comment">  @return An error object pointer, or NULL on success.</span><a name="l00453"></a>00453 <span class="comment">  */</span><a name="l00454"></a>00454 <span class="comment">/***************************************************************************/</span><a name="l00455"></a><a class="code" href="classLinkage.html#a10">00455</a> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classLinkage.html#a10">Linkage::StartMove</a>( <span class="keywordtype">void</span> )<a name="l00456"></a>00456 {<a name="l00457"></a>00457    <a class="code" href="classLinkage.html#a17">ClearLatchedError</a>();<a name="l00458"></a>00458 <a name="l00459"></a>00459    <a class="code" href="CML__Utils_8h.html#a10">uint32</a> allAmps = (1&lt;&lt;ampct) - 1;<a name="l00460"></a>00460    <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *err = 0;<a name="l00461"></a>00461    <a class="code" href="classEventAny.html">EventAny</a> events[<a class="code" href="CML__Settings_8h.html#a6">CML_MAX_AMPS_PER_LINK</a>];<a name="l00462"></a>00462    <a class="code" href="classEventMap.html">EventMap</a> map;<a name="l00463"></a>00463    <span class="keywordtype">int</span> i;<a name="l00464"></a>00464 <a name="l00465"></a>00465    <span class="comment">// Make sure all amps are in profile mode</span><a name="l00466"></a>00466    <span class="comment">// and are ready to start a new move.</span><a name="l00467"></a>00467    <span class="keywordflow">for</span>( i=0; i&lt;ampct; i++ )<a name="l00468"></a>00468    {<a name="l00469"></a>00469       err = amp[i]-&gt;<a class="code" href="classAmp.html#z1_7">CheckStateForMove</a>();<a name="l00470"></a>00470       <span class="keywordflow">if</span>( err )<a name="l00471"></a>00471     <span class="keywordflow">return</span> LatchError( err, i );<a name="l00472"></a>00472 <a name="l00473"></a>00473       events[i].<a class="code" href="classEvent.html#a3">setChain</a>( map, (1&lt;&lt;i) );<a name="l00474"></a>00474       events[i].<a class="code" href="classEvent.html#a2">setValue</a>( <a class="code" href="CML__AmpDef_8h.html#a399a248">AMPEVENT_SPACK</a> | <a class="code" href="CML__AmpDef_8h.html#a399a263">AMPEVENT_PVT_EMPTY</a> );<a name="l00475"></a>00475       amp[i]-&gt;<a class="code" href="classAmp.html#p0">eventMap</a>.<a class="code" href="classEventMap.html#a2">Add</a>( &amp;events[i] );<a name="l00476"></a>00476    }<a name="l00477"></a>00477 <a name="l00478"></a>00478    <span class="comment">// Enable the amps, and wait for them to clear</span><a name="l00479"></a>00479    <span class="comment">// the acknowledge bit.</span><a name="l00480"></a>00480    SetControlWord( 0x000F );<a name="l00481"></a>00481    <a class="code" href="classEventNone.html">EventNone</a> none = allAmps;<a name="l00482"></a>00482    err = none.<a class="code" href="classEvent.html#a7">Wait</a>( map, cfg.<a class="code" href="classLinkSettings.html#o0">moveAckTimeout</a> );<a name="l00483"></a>00483 <a name="l00484"></a>00484    <span class="comment">// On timeout, find the offending thread</span><a name="l00485"></a>00485    <span class="keywordflow">if</span>( err == &amp;<a class="code" href="classThreadError.html#s2">ThreadError::Timeout</a> )<a name="l00486"></a>00486    {<a name="l00487"></a>00487       <span class="keywordflow">for</span>( i=0; i&lt;ampct; i++ )<a name="l00488"></a>00488       {<a name="l00489"></a>00489     <a class="code" href="CML__AmpDef_8h.html#a399">AMP_EVENT</a> e;<a name="l00490"></a>00490     amp[i]-&gt;<a class="code" href="classAmp.html#z14_4">GetEventMask</a>( e );<a name="l00491"></a>00491     <span class="keywordflow">if</span>( e &amp; <a class="code" href="CML__AmpDef_8h.html#a399a248">AMPEVENT_SPACK</a> )<a name="l00492"></a>00492        <span class="keywordflow">return</span> LatchError( &amp;<a class="code" href="classLinkError.html#s11">LinkError::StartMoveTO</a>, i );<a name="l00493"></a>00493       }<a name="l00494"></a>00494    }<a name="l00495"></a>00495    <span class="keywordflow">else</span> <span class="keywordflow">if</span>( err )<a name="l00496"></a>00496       <span class="keywordflow">return</span> LatchError( err, -1 );<a name="l00497"></a>00497 <a name="l00498"></a>00498    <span class="comment">// Now, start a move on all amps, and wait for</span><a name="l00499"></a>00499    <span class="comment">// the acknowledge bit to be set.</span><a name="l00500"></a>00500    SetControlWord( 0x003F );<a name="l00501"></a>00501    <a class="code" href="classEventAll.html">EventAll</a> all = allAmps;<a name="l00502"></a>00502    err = all.<a class="code" href="classEvent.html#a7">Wait</a>( map, cfg.<a class="code" href="classLinkSettings.html#o0">moveAckTimeout</a> );<a name="l00503"></a>00503 <a name="l00504"></a>00504    <span class="comment">// On timeout, find the offending thread</span><a name="l00505"></a>00505    <span class="keywordflow">if</span>( err == &amp;<a class="code" href="classThreadError.html#s2">ThreadError::Timeout</a> )<a name="l00506"></a>00506    {<a name="l00507"></a>00507       <span class="keywordflow">for</span>( i=0; i&lt;ampct; i++ )<a name="l00508"></a>00508       {<a name="l00509"></a>00509     <a class="code" href="CML__AmpDef_8h.html#a399">AMP_EVENT</a> e;<a name="l00510"></a>00510     amp[i]-&gt;<a class="code" href="classAmp.html#z14_4">GetEventMask</a>( e );<a name="l00511"></a>00511     <span class="keywordflow">if</span>( !(e &amp; <a class="code" href="CML__AmpDef_8h.html#a399a248">AMPEVENT_SPACK</a>) )<a name="l00512"></a>00512        <span class="keywordflow">return</span> LatchError( &amp;<a class="code" href="classLinkError.html#s11">LinkError::StartMoveTO</a>, i );<a name="l00513"></a>00513       }<a name="l00514"></a>00514    }<a name="l00515"></a>00515    <span class="keywordflow">else</span> <span class="keywordflow">if</span>( err )<a name="l00516"></a>00516       <span class="keywordflow">return</span> LatchError( err, -1 );<a name="l00517"></a>00517 <a name="l00518"></a>00518    <span class="comment">// Notify my thread that a move has started</span><a name="l00519"></a>00519    startSema.<a class="code" href="classSemaphore.html#a3">Put</a>();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -