iomodule_8cpp-source.html
来自「美国COPLEY驱动器,程序开发工具之一.」· HTML 代码 · 共 575 行 · 第 1/5 页
HTML
575 行
<a name="l00222"></a>00222 <span class="comment"> is faster since it only requires a single message to be sent. SDO </span><a name="l00223"></a>00223 <span class="comment"> transfers additionally require a response from the module. </span><a name="l00224"></a>00224 <span class="comment"></span><a name="l00225"></a>00225 <span class="comment"> If a PDO transfer is requested, but is not possible because the module is</span><a name="l00226"></a>00226 <span class="comment"> not in an operational state, or because the output isn't mapped to</span><a name="l00227"></a>00227 <span class="comment"> the PDO, then an SDO transfer will be used.</span><a name="l00228"></a>00228 <span class="comment"></span><a name="l00229"></a>00229 <span class="comment"> @param id Identifies which output to write.</span><a name="l00230"></a>00230 <span class="comment"> @param value The new value of the output line.</span><a name="l00231"></a>00231 <span class="comment"> @param viaSDO If true, the outputs will be written using SDO messages.</span><a name="l00232"></a>00232 <span class="comment"> If false (default), then a PDO will be used if possible.</span><a name="l00233"></a>00233 <span class="comment"> @return A pointer to an error object, or NULL on success</span><a name="l00234"></a>00234 <span class="comment"> */</span><a name="l00235"></a>00235 <span class="comment">/***************************************************************************/</span><a name="l00236"></a><a class="code" href="classIOModule.html#z20_1">00236</a> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classIOModule.html#z20_1">IOModule::DoutWrite</a>( <a class="code" href="CML__Utils_8h.html#a8">uint16</a> <span class="keywordtype">id</span>, <span class="keywordtype">bool</span> value, <span class="keywordtype">bool</span> viaSDO )<a name="l00237"></a>00237 {<a name="l00238"></a>00238 <span class="preprocessor">#ifdef CML_ENABLE_IOMODULE_PDOS</span><a name="l00239"></a>00239 <span class="preprocessor"></span> <span class="comment">// Update the bit value in the PDO to keep my local data current.</span><a name="l00240"></a>00240 <span class="comment">// If this fails, then the bit isn't mapped and I'll have to use</span><a name="l00241"></a>00241 <span class="comment">// an SDO to update it.</span><a name="l00242"></a>00242 <span class="keywordflow">if</span>( !<a class="code" href="classIOModule.html#p3">doutPDO</a>.<a class="code" href="classIOModule_1_1DigOutPDO.html#a2">UpdateBit</a>( <span class="keywordtype">id</span>, value ) )<a name="l00243"></a>00243 viaSDO = <span class="keyword">true</span>;<a name="l00244"></a>00244 <a name="l00245"></a>00245 <span class="comment">// Output this using a PDO if requested and possible</span><a name="l00246"></a>00246 <span class="keywordflow">if</span>( (!viaSDO) && (<a class="code" href="classNode.html#a20">GetState</a>() == <a class="code" href="CML__Node_8h.html#a9a5">NODESTATE_OPERATIONAL</a>) )<a name="l00247"></a>00247 <span class="keywordflow">return</span> <a class="code" href="classIOModule.html#p3">doutPDO</a>.<a class="code" href="classIOModule_1_1DigOutPDO.html#a3">Transmit</a>();<a name="l00248"></a>00248 <a name="l00249"></a>00249 <span class="keywordflow">else</span><a name="l00250"></a>00250 <span class="preprocessor">#endif</span><a name="l00251"></a>00251 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="classIOModule.html#b1">BitDnld</a>( <a class="code" href="CML__IO_8h.html#a90a30">IOOBJID_DOUT_1_VALUE</a>, <span class="keywordtype">id</span>, value );<a name="l00252"></a>00252 }<a name="l00253"></a>00253 <a name="l00254"></a>00254 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00255"></a>00255 <span class="comment">/**</span><a name="l00256"></a>00256 <span class="comment"> Write a group of 8 digital outputs.</span><a name="l00257"></a>00257 <span class="comment"></span><a name="l00258"></a>00258 <span class="comment"> The outputs may be written either by SDO or by PDO. The PDO method </span><a name="l00259"></a>00259 <span class="comment"> is faster since it only requires a single message to be sent. SDO </span><a name="l00260"></a>00260 <span class="comment"> transfers additionally require a response from the module. </span><a name="l00261"></a>00261 <span class="comment"></span><a name="l00262"></a>00262 <span class="comment"> If a PDO transfer is requested, but is not possible because the module is</span><a name="l00263"></a>00263 <span class="comment"> not in an operational state, or because the output block isn't mapped to</span><a name="l00264"></a>00264 <span class="comment"> the PDO, then an SDO transfer will be used.</span><a name="l00265"></a>00265 <span class="comment"></span><a name="l00266"></a>00266 <span class="comment"> @param id Identifies which group of outputs to write. </span><a name="l00267"></a>00267 <span class="comment"> @param value The new value of the output lines. </span><a name="l00268"></a>00268 <span class="comment"> @param viaSDO If true, the outputs will be written using SDO messages.</span><a name="l00269"></a>00269 <span class="comment"> If false (default), then a PDO will be used if possible.</span><a name="l00270"></a>00270 <span class="comment"> @return A pointer to an error object, or NULL on success</span><a name="l00271"></a>00271 <span class="comment"> */</span><a name="l00272"></a>00272 <span class="comment">/***************************************************************************/</span><a name="l00273"></a><a class="code" href="classIOModule.html#z20_11">00273</a> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classIOModule.html#z20_11">IOModule::Dout8Write</a>( <a class="code" href="CML__Utils_8h.html#a6">uint8</a> <span class="keywordtype">id</span>, <a class="code" href="CML__Utils_8h.html#a6">uint8</a> value, <span class="keywordtype">bool</span> viaSDO )<a name="l00274"></a>00274 {<a name="l00275"></a>00275 <span class="preprocessor">#ifdef CML_ENABLE_IOMODULE_PDOS</span><a name="l00276"></a>00276 <span class="preprocessor"></span> <span class="comment">// Update the PDO even if we are using an SDO. This keeps</span><a name="l00277"></a>00277 <span class="comment">// my PDO data up to date.</span><a name="l00278"></a>00278 <span class="keywordflow">if</span>( !<a class="code" href="classIOModule.html#p3">doutPDO</a>.<a class="code" href="classIOModule_1_1DigOutPDO.html#a1">Update</a>( <span class="keywordtype">id</span>, value ) )<a name="l00279"></a>00279 viaSDO = <span class="keyword">true</span>;<a name="l00280"></a>00280 <a name="l00281"></a>00281 <span class="comment">// Output this using a PDO if requested and possible</span><a name="l00282"></a>00282 <span class="keywordflow">if</span>( (!viaSDO) && (<a class="code" href="classNode.html#a20">GetState</a>() == <a class="code" href="CML__Node_8h.html#a9a5">NODESTATE_OPERATIONAL</a>) )<a name="l00283"></a>00283 <span class="keywordflow">return</span> <a class="code" href="classIOModule.html#p3">doutPDO</a>.<a class="code" href="classIOModule_1_1DigOutPDO.html#a3">Transmit</a>();<a name="l00284"></a>00284 <a name="l00285"></a>00285 <span class="keywordflow">else</span><a name="l00286"></a>00286 <span class="preprocessor">#endif</span><a name="l00287"></a>00287 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="classNode.html#o0">sdo</a>.<a class="code" href="classSDO.html#a12">Dnld8</a>( <a class="code" href="CML__IO_8h.html#a90a25">IOOBJID_DOUT_8_VALUE</a>, <span class="keywordtype">id</span>+1, value );<a name="l00288"></a>00288 }<a name="l00289"></a>00289 <a name="l00290"></a>00290 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00291"></a>00291 <span class="comment">/**</span><a name="l00292"></a>00292 <span class="comment"> Write a group of 16 digital outputs.</span><a name="l00293"></a>00293 <span class="comment"></span><a name="l00294"></a>00294 <span class="comment"> The outputs may be written either by SDO or by PDO. The PDO method </span><a name="l00295"></a>00295 <span class="comment"> is faster since it only requires a single message to be sent. SDO </span><a name="l00296"></a>00296 <span class="comment"> transfers additionally require a response from the module. </span><a name="l00297"></a>00297 <span class="comment"></span><a name="l00298"></a>00298 <span class="comment"> If a PDO transfer is requested, but is not possible because the module is</span><a name="l00299"></a>00299 <span class="comment"> not in an operational state, or because the output block isn't mapped to</span><a name="l00300"></a>00300 <span class="comment"> the PDO, then an SDO transfer will be used.</span><a name="l00301"></a>00301 <span class="comment"></span><a name="l00302"></a>00302 <span class="comment"> @param id Identifies which group of outputs to write.</span><a name="l00303"></a>00303 <span class="comment"> @param value The new value of the output lines.</span><a name="l00304"></a>00304 <span class="comment"> @param viaSDO If true, the outputs will be written using SDO messages.</span><a name="l00305"></a>00305 <span class="comment"> If false (default), then a PDO will be used if possible.</span><a name="l00306"></a>00306 <span class="comment"> @return A pointer to an error object, or NULL on success</span><a name="l00307"></a>00307 <span class="comment"> */</span><a name="l00308"></a>00308 <span class="comment">/***************************************************************************/</span><a name="l00309"></a><a class="code" href="classIOModule.html#z20_21">00309</a> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classIOModule.html#z20_21">IOModule::Dout16Write</a>( <a class="code" href="CML__Utils_8h.html#a6">uint8</a> <span class="keywordtype">id</span>, <a class="code" href="CML__Utils_8h.html#a8">uint16</a> value, <span class="keywordtype">bool</span> viaSDO )<a name="l00310"></a>00310 {<a name="l00311"></a>00311 <span class="preprocessor">#ifdef CML_ENABLE_IOMODULE_PDOS</span><a name="l00312"></a>00312 <span class="preprocessor"></span> <span class="keywordflow">if</span>( <span class="keywordtype">id</span> >= 127 ) <a name="l00313"></a>00313 viaSDO = <span class="keyword">true</span>;<a name="l00314"></a>00314 <a name="l00315"></a>00315 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( !<a class="code" href="classIOModule.html#p3">doutPDO</a>.<a class="code" href="classIOModule_1_1DigOutPDO.html#a1">Update</a>( 2*<span class="keywordtype">id</span>, (<a class="code" href="CML__Utils_8h.html#a6">uint8</a>)value ) )<a name="l00316"></a>00316 viaSDO = <span class="keyword">true</span>;<a name="l00317"></a>00317 <a name="l00318"></a>00318 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( !<a class="code" href="classIOModule.html#p3">doutPDO</a>.<a class="code" href="classIOModule_1_1DigOutPDO.html#a1">Update</a>( 2*<span class="keywordtype">id</span>+1, (<a class="code" href="CML__Utils_8h.html#a6">uint8</a>)(value>>8) ) )<a name="l00319"></a>00319 viaSDO = <span class="keyword">true</span>;<a name="l00320"></a>00320 <a name="l00321"></a>00321 <span class="comment">// Output this using a PDO if requested and possible</span><a name="l00322"></a>00322 <span class="keywordflow">if</span>( (!viaSDO) && (<a class="code" href="classNode.html#a20">GetState</a>() == <a class="code" href="CML__Node_8h.html#a9a5">NODESTATE_OPERATIONAL</a>) )<a name="l00323"></a>00323 <span class="keywordflow">return</span> <a class="code" href="classIOModule.html#p3">doutPDO</a>.<a class="code" href="classIOModule_1_1DigOutPDO.html#a3">Transmit</a>();<a name="l00324"></a>00324 <a name="l00325"></a>00325 <span class="keywordflow">else</span><a name="l00326"></a>00326 <span class="preprocessor">#endif</span><a name="l00327"></a>00327 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="classNode.html#o0">sdo</a>.<a class="code" href="classSDO.html#a10">Dnld16</a>( <a class="code" href="CML__IO_8h.html#a90a35">IOOBJID_DOUT_16_VALUE</a>, <span class="keywordtype">id</span>+1, value );<a name="l00328"></a>00328 }<a name="l00329"></a>00329 <a name="l00330"></a>00330 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00331"></a>00331 <span class="comment">/**</span><a name="l00332"></a>00332 <span class="comment"> Write a group of 32 digital outputs.</span><a name="l00333"></a>00333 <span class="comment"></span><a name="l00334"></a>00334 <span class="comment"> The outputs may be written either by SDO or by PDO. The PDO method </span><a name="l00335"></a>00335 <span class="comment"> is faster since it only requires a single message to be sent. SDO </span><a name="l00336"></a>00336 <span class="comment"> transfers additionally require a response from the module. </span>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?