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

📄 amppvt_8cpp-source.html

📁 美国COPLEY驱动器,程序开发工具之一.
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00418"></a>00418    }<a name="l00419"></a>00419 <a name="l00420"></a>00420    <span class="keywordflow">return</span> err;<a name="l00421"></a>00421 }<a name="l00422"></a>00422 <a name="l00423"></a>00423 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00424"></a>00424 <span class="comment">/**</span><a name="l00425"></a>00425 <span class="comment">  A new abort event was just received.  This function is called from the </span><a name="l00426"></a>00426 <span class="comment">  status PDO when the 'move aborted' status is set.  It's used to clean up</span><a name="l00427"></a>00427 <span class="comment">  the PVT move in progress.</span><a name="l00428"></a>00428 <span class="comment">  */</span><a name="l00429"></a>00429 <span class="comment">/***************************************************************************/</span><a name="l00430"></a>00430 <span class="keywordtype">void</span> Amp::MoveAborted( <span class="keywordtype">void</span> )<a name="l00431"></a>00431 {<a name="l00432"></a>00432    <span class="keywordflow">if</span>( pvtTrj )<a name="l00433"></a>00433    {<a name="l00434"></a>00434       pvtTrj-&gt;<a class="code" href="classTrajectory.html#a1">Finish</a>();<a name="l00435"></a>00435       pvtTrj = 0;<a name="l00436"></a>00436    }<a name="l00437"></a>00437 }<a name="l00438"></a>00438 <a name="l00439"></a>00439 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00440"></a>00440 <span class="comment">/**</span><a name="l00441"></a>00441 <span class="comment">  Get the starting position of the PVT segment currently active in the </span><a name="l00442"></a>00442 <span class="comment">  amplifier.  When running in PVT mode, this allows an approximation of the</span><a name="l00443"></a>00443 <span class="comment">  amplifier position to be retrieved without adding any additional overhead</span><a name="l00444"></a>00444 <span class="comment">  to the CANopen network.</span><a name="l00445"></a>00445 <span class="comment"></span><a name="l00446"></a>00446 <span class="comment">  The position returned by this function is only valid when running in PVT mode.</span><a name="l00447"></a>00447 <span class="comment"></span><a name="l00448"></a>00448 <span class="comment">  @param pos The position is returned here.</span><a name="l00449"></a>00449 <span class="comment">  @return A pointer to an error object, or NULL on success.</span><a name="l00450"></a>00450 <span class="comment">  */</span><a name="l00451"></a>00451 <span class="comment">/***************************************************************************/</span><a name="l00452"></a><a class="code" href="classAmp.html#z13_5">00452</a> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classAmp.html#z13_5">Amp::GetPvtSegPos</a>( <a class="code" href="CML__Utils_8h.html#a11">uunit</a> &amp;pos )<a name="l00453"></a>00453 {<a name="l00454"></a>00454    <span class="keywordflow">if</span>( pvtCache.<a class="code" href="classPvtSegCache.html#a4">GetPosition</a>( &amp;pos, pvtSegActive ) )<a name="l00455"></a>00455       <span class="keywordflow">return</span> 0;<a name="l00456"></a>00456 <a name="l00457"></a>00457    <span class="keywordflow">return</span> &amp;<a class="code" href="classAmpError.html#s29">AmpError::pvtPosUnavail</a>;<a name="l00458"></a>00458 }<a name="l00459"></a>00459 <a name="l00460"></a>00460 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00461"></a>00461 <span class="comment">/**</span><a name="l00462"></a>00462 <span class="comment">  This function is called by the PVT status PDO receiver function.  It takes</span><a name="l00463"></a>00463 <span class="comment">  care of the gory details of streaming out a trajectory that's too big to </span><a name="l00464"></a>00464 <span class="comment">  fit in the amplifier's PVT buffer all at once.</span><a name="l00465"></a>00465 <span class="comment"></span><a name="l00466"></a>00466 <span class="comment">  Note that this function will be called by the receive task and therefore </span><a name="l00467"></a>00467 <span class="comment">  must be as quick as possible.  Also, SDO access is not available from within</span><a name="l00468"></a>00468 <span class="comment">  the receive task.</span><a name="l00469"></a>00469 <span class="comment"></span><a name="l00470"></a>00470 <span class="comment">  @param status The amplifier status word passed in the PDO</span><a name="l00471"></a>00471 <span class="comment">  */</span><a name="l00472"></a>00472 <span class="comment">/***************************************************************************/</span><a name="l00473"></a>00473 <span class="keywordtype">void</span> Amp::PvtStatusUpdate( <a class="code" href="CML__Utils_8h.html#a10">uint32</a> status )<a name="l00474"></a>00474 {<a name="l00475"></a>00475    <span class="comment">// Break the status into it's main components.  These are:</span><a name="l00476"></a>00476    <span class="comment">//</span><a name="l00477"></a>00477    <span class="comment">// - The segment ID of the next segment expected by the amp</span><a name="l00478"></a>00478    <span class="comment">// - The number of free positions in the buffer</span><a name="l00479"></a>00479    <span class="comment">// - Any error codes</span><a name="l00480"></a>00480    <a class="code" href="CML__Utils_8h.html#a8">uint16</a> ampNextID = (<a class="code" href="CML__Utils_8h.html#a8">uint16</a>)(status &amp; <a class="code" href="AmpPVT_8cpp.html#a3">PVTSTAT_NEXTID</a>);<a name="l00481"></a>00481    <a class="code" href="CML__Utils_8h.html#a6">uint8</a>  freeCt    = (<a class="code" href="CML__Utils_8h.html#a6">uint8</a>)((status &amp; <a class="code" href="AmpPVT_8cpp.html#a4">PVTSTAT_FREECT</a>)&gt;&gt;16);<a name="l00482"></a>00482    <a class="code" href="CML__Utils_8h.html#a6">uint8</a>  errors    = (<a class="code" href="CML__Utils_8h.html#a6">uint8</a>)((status &amp; <a class="code" href="AmpPVT_8cpp.html#a5">PVTSTAT_ERROR</a> )&gt;&gt;24);<a name="l00483"></a>00483 <a name="l00484"></a>00484    <a class="code" href="CML_8h.html#a0">cml</a>.<a class="code" href="classCopleyMotionLibrary.html#a8">Debug</a>( <span class="stringliteral">"Amp %d PVT Stat: %5u %3u 0x%02x\n"</span>, <a class="code" href="classNode.html#a38">GetNodeID</a>(), ampNextID, freeCt, errors );<a name="l00485"></a>00485 <a name="l00486"></a>00486    <span class="comment">// Set an amplifier status bit if the PVT buffer is empty</span><a name="l00487"></a>00487    <span class="keywordflow">if</span>( status &amp; 0x80000000 )<a name="l00488"></a>00488       <a class="code" href="classAmp.html#p0">eventMap</a>.<a class="code" href="classEventMap.html#a6">setBits</a>( <a class="code" href="CML__AmpDef_8h.html#a399a263">AMPEVENT_PVT_EMPTY</a> );<a name="l00489"></a>00489    <span class="keywordflow">else</span><a name="l00490"></a>00490       <a class="code" href="classAmp.html#p0">eventMap</a>.<a class="code" href="classEventMap.html#a7">clrBits</a>( <a class="code" href="CML__AmpDef_8h.html#a399a263">AMPEVENT_PVT_EMPTY</a> );<a name="l00491"></a>00491 <a name="l00492"></a>00492    <span class="comment">// Keep track of the active segment ID</span><a name="l00493"></a>00493    pvtSegActive = ampNextID - pvtBuffSize + freeCt - 1;<a name="l00494"></a>00494 <a name="l00495"></a>00495    <span class="comment">// If the amplifier has experienced an underflow error, then</span><a name="l00496"></a>00496    <span class="comment">// it has already aborted the trajectory.  At this point there</span><a name="l00497"></a>00497    <span class="comment">// is no reason to send more segments, so I'll just return.</span><a name="l00498"></a>00498    <span class="keywordflow">if</span>( errors &amp; <a class="code" href="AmpPVT_8cpp.html#a2">PVTERR_UNDERFLOW</a> )<a name="l00499"></a>00499    {<a name="l00500"></a>00500       <span class="keywordflow">if</span>( pvtTrj )<a name="l00501"></a>00501       {<a name="l00502"></a>00502     pvtTrj-&gt;<a class="code" href="classTrajectory.html#a1">Finish</a>();<a name="l00503"></a>00503     pvtTrj = 0;<a name="l00504"></a>00504       }<a name="l00505"></a>00505       <span class="keywordflow">return</span>;<a name="l00506"></a>00506    }<a name="l00507"></a>00507 <a name="l00508"></a>00508    <span class="comment">// If a segment sequencing error has occurred, then I'll try</span><a name="l00509"></a>00509    <span class="comment">// to resend data starting at the segment the amp desires.</span><a name="l00510"></a>00510    <span class="comment">// First, I'll clear the error and update my state to</span><a name="l00511"></a>00511    <span class="comment">// indicate that segments need to be resent.</span><a name="l00512"></a>00512    <span class="comment">// That's all I'll do until I get a status indicating that </span><a name="l00513"></a>00513    <span class="comment">// the error was cleared since there could be other pending</span><a name="l00514"></a>00514    <span class="comment">// status messages coming my way with the old error flagged, and</span><a name="l00515"></a>00515    <span class="comment">// I don't want to get confused about where the error occurred.</span><a name="l00516"></a>00516    <span class="keywordflow">if</span>( errors &amp; <a class="code" href="AmpPVT_8cpp.html#a0">PVTERR_SEQUENCE</a> )<a name="l00517"></a>00517    {<a name="l00518"></a>00518       <a class="code" href="classAmp.html#b10">PvtClearErrors</a>( <a class="code" href="AmpPVT_8cpp.html#a0">PVTERR_SEQUENCE</a>, <span class="keyword">false</span> );<a name="l00519"></a>00519       pvtUseCache = <span class="keyword">true</span>;<a name="l00520"></a>00520       pvtCacheID = ampNextID;<a name="l00521"></a>00521       <span class="keywordflow">return</span>;<a name="l00522"></a>00522    }<a name="l00523"></a>00523 <a name="l00524"></a>00524    <span class="comment">// OK, no errors that we care about.  Reduce the free count value</span><a name="l00525"></a>00525    <span class="comment">// passed in the status to take any recently sent segments into</span><a name="l00526"></a>00526    <span class="comment">// account.  The result is the number of new segments we can</span><a name="l00527"></a>00527    <span class="comment">// send safely.</span><a name="l00528"></a>00528    <span class="keywordflow">if</span>( pvtUseCache )<a name="l00529"></a>00529       freeCt -= (pvtCacheID - ampNextID);<a name="l00530"></a>00530    <span class="keywordflow">else</span><a name="l00531"></a>00531       freeCt -= (pvtSegID - ampNextID);<a name="l00532"></a>00532 <a name="l00533"></a>00533    <span class="comment">// Limit the number of new segments I'll send in response</span><a name="l00534"></a>00534    <span class="comment">// to a single status message.  </span><a name="l00535"></a>00535    <span class="keywordflow">if</span>( freeCt &gt; initialSettings.<a class="code" href="classAmpSettings.html#o12">maxPvtSendCt</a> )<a name="l00536"></a>00536       freeCt = initialSettings.<a class="code" href="classAmpSettings.html#o12">maxPvtSendCt</a>;<a name="l00537"></a>00537 <a name="l00538"></a>00538    <span class="comment">// Now, send as many segments as possible.</span><a name="l00539"></a>00539    <span class="keywordflow">for</span>( <a class="code" href="CML__Utils_8h.html#a6">uint8</a> i=0; i&lt;freeCt; i++ )<a name="l00540"></a>00540    {<a name="l00541"></a>00541       <a class="code" href="CML__Utils_8h.html#a6">uint8</a> buff[8];<a name="l00542"></a>00542 <a name="l00543"></a>00543       <span class="comment">// See if we need to resend an old segment.  </span><a name="l00544"></a>00544       <span class="comment">// If so, I'll pull it out of the cache.</span><a name="l00545"></a>00545       <span class="keywordflow">if</span>( pvtUseCache )<a name="l00546"></a>00546       {<a name="l00547"></a>00547     <span class="comment">// If the necessary segment isn't available, then </span><a name="l00548"></a>00548     <span class="comment">// I have no choice but to flush the cache and </span><a name="l00549"></a>00549     <span class="comment">// abort the profile.</span><a name="l00550"></a>00550     <span class="keywordflow">if</span>( !pvtCache.<a class="code" href="classPvtSegCache.html#a3">GetSegment</a>( buff, pvtCacheID ) )<a name="l00551"></a>00551     {<a name="l00552"></a>00552        <a class="code" href="classAmp.html#b8">PvtBufferFlush</a>( <span class="keyword">false</span> );<a name="l00553"></a>00553        <span class="keywordflow">if</span>( pvtTrj )<a name="l00554"></a>00554        {<a name="l00555"></a>00555           pvtTrj-&gt;<a class="code" href="classTrajectory.html#a1">Finish</a>();<a name="l00556"></a>00556           pvtTrj = 0;<a name="l00557"></a>00557        }<a name="l00558"></a>00558        <span class="keywordflow">return</span>;<a name="l00559"></a>00559     }

⌨️ 快捷键说明

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