cml__pdo_8h-source.html

来自「美国COPLEY驱动器,程序开发工具之一.」· HTML 代码 · 共 571 行 · 第 1/5 页

HTML
571
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Copley Motion Library: CML_PDO.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.4 --><div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div><div class="nav"><a class="el" href="dir_000001.html">inc</a></div><h1>CML_PDO.h</h1><a href="CML__PDO_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/************************************************************/</span><a name="l00002"></a>00002 <span class="comment">/*                                                          */</span><a name="l00003"></a>00003 <span class="comment">/*  Copley Motion Libraries                                 */</span><a name="l00004"></a>00004 <span class="comment">/*                                                          */</span><a name="l00005"></a>00005 <span class="comment">/*  Author: Stephen Glow                                    */</span><a name="l00006"></a>00006 <span class="comment">/*                                                          */</span><a name="l00007"></a>00007 <span class="comment">/*  Copyright (c) 2002-2005 Copley Controls Corp.           */</span><a name="l00008"></a>00008 <span class="comment">/*                          http://www.copleycontrols.com   */</span><a name="l00009"></a>00009 <span class="comment">/*                                                          */</span><a name="l00010"></a>00010 <span class="comment">/************************************************************/</span><a name="l00011"></a>00011 <span class="comment"></span><a name="l00012"></a>00012 <span class="comment">/** </span><a name="l00013"></a>00013 <span class="comment">\file</span><a name="l00014"></a>00014 <span class="comment"></span><a name="l00015"></a>00015 <span class="comment">This header file defines the classes used to communicate</span><a name="l00016"></a>00016 <span class="comment">to CANopen nodes using Process Data Objects (PDOs).</span><a name="l00017"></a>00017 <span class="comment"></span><a name="l00018"></a>00018 <span class="comment">*/</span><a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#ifndef _DEF_INC_CO_PDO</span><a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define _DEF_INC_CO_PDO</span><a name="l00022"></a>00022 <span class="preprocessor"></span><a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="CML__Settings_8h.html">CML_Settings.h</a>"</span><a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="CML__CanOpen_8h.html">CML_CanOpen.h</a>"</span><a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="CML__Utils_8h.html">CML_Utils.h</a>"</span><a name="l00026"></a>00026 <a name="l00027"></a>00027 <a class="code" href="CML__Settings_8h.html#a11">CML_NAMESPACE_START</a>()<a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="comment">/// Number of variables that may be added to a PDO's map.</span><a name="l00030"></a><a class="code" href="CML__PDO_8h.html#a0">00030</a> <span class="comment"></span>#define <a class="code" href="CML__PDO_8h.html#a0">PDO_MAP_LEN</a>  8<a name="l00031"></a>00031 <span class="comment"></span><a name="l00032"></a>00032 <span class="comment">/// Flag used by transmit PDOs to indicate that RTR requests are allowed</span><a name="l00033"></a><a class="code" href="CML__PDO_8h.html#a1">00033</a> <span class="comment"></span><span class="preprocessor">#define FLG_RTR_OK    0x01</span><a name="l00034"></a>00034 <span class="preprocessor"></span><span class="comment"></span><a name="l00035"></a>00035 <span class="comment">/**</span><a name="l00036"></a>00036 <span class="comment">This class represents error conditions related to PDOs.</span><a name="l00037"></a>00037 <span class="comment">*/</span><a name="l00038"></a><a class="code" href="classPDO__Error.html">00038</a> <span class="keyword">class </span><a class="code" href="classPDO__Error.html">PDO_Error</a>: <span class="keyword">public</span> <a class="code" href="classCanOpenError.html">CanOpenError</a><a name="l00039"></a>00039 {<a name="l00040"></a>00040 <span class="keyword">public</span>:<span class="comment"></span><a name="l00041"></a>00041 <span class="comment">   /// The variable map associated with the PDO is already full</span><a name="l00042"></a><a class="code" href="classPDO__Error.html#s0">00042</a> <span class="comment"></span>   <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classPDO__Error.html">PDO_Error</a> <a class="code" href="classPDO__Error.html#s0">MapFull</a>;<a name="l00043"></a>00043 <span class="comment"></span><a name="l00044"></a>00044 <span class="comment">   /// Adding the variable to the map would cause the map to</span><a name="l00045"></a>00045 <span class="comment">   /// be too long (more then 64 bits).</span><a name="l00046"></a><a class="code" href="classPDO__Error.html#s1">00046</a> <span class="comment"></span>   <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classPDO__Error.html">PDO_Error</a> <a class="code" href="classPDO__Error.html#s1">BitOverflow</a>;<a name="l00047"></a>00047 <span class="comment"></span><a name="l00048"></a>00048 <span class="comment">   /// PDO Map variables of the passed bit size are </span><a name="l00049"></a>00049 <span class="comment">   /// not presently supported</span><a name="l00050"></a><a class="code" href="classPDO__Error.html#s2">00050</a> <span class="comment"></span>   <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classPDO__Error.html">PDO_Error</a> <a class="code" href="classPDO__Error.html#s2">BitSizeError</a>;<a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="keyword">protected</span>:<span class="comment"></span><a name="l00053"></a>00053 <span class="comment">   /// Standard protected constructor</span><a name="l00054"></a><a class="code" href="classPDO__Error.html#b0">00054</a> <span class="comment"></span>   <a class="code" href="classPDO__Error.html#b0">PDO_Error</a>( <a class="code" href="CML__Utils_8h.html#a8">uint16</a> <span class="keywordtype">id</span>, <span class="keyword">const</span> <span class="keywordtype">char</span> *desc ): <a class="code" href="classCanOpenError.html">CanOpenError</a>( id, desc ){}<a name="l00055"></a>00055 };<a name="l00056"></a>00056 <a name="l00057"></a>00057 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00058"></a>00058 <span class="comment">/**</span><a name="l00059"></a>00059 <span class="comment">This class allows variables to be mapped into a PDO.  This class can be used</span><a name="l00060"></a>00060 <span class="comment">directly for transmit PDOs if the received data is not of interest (it will</span><a name="l00061"></a>00061 <span class="comment">simply be discarded by the Set() function.  Using this for receive PDOs is</span><a name="l00062"></a>00062 <span class="comment">not recommended since the Get() function doesn't add any data to the output</span><a name="l00063"></a>00063 <span class="comment">stream and therefore the data transmitted to the node will be undefined.</span><a name="l00064"></a>00064 <span class="comment">*/</span><a name="l00065"></a>00065 <span class="comment">/***************************************************************************/</span><a name="l00066"></a><a class="code" href="classPmap.html">00066</a> <span class="keyword">class </span><a class="code" href="classPmap.html">Pmap</a><a name="l00067"></a>00067 {<a name="l00068"></a>00068 <span class="keyword">public</span>:<span class="comment"></span><a name="l00069"></a>00069 <span class="comment">   /// Default constructor for a generic PDO mapping variable</span><a name="l00070"></a><a class="code" href="classPmap.html#a0">00070</a> <span class="comment"></span>   <a class="code" href="classPmap.html#a0">Pmap</a>(){}<a name="l00071"></a>00071 <span class="comment"></span><a name="l00072"></a>00072 <span class="comment">   /// Construct a generic PDO mapping variable and initialize</span><a name="l00073"></a>00073 <span class="comment">   /// it's size and object ID.</span><a name="l00074"></a>00074 <span class="comment">   /// @param index The index of the variable in the object dictionary</span><a name="l00075"></a>00075 <span class="comment">   /// @param sub The variable's sub-index in the object dictionary</span><a name="l00076"></a>00076 <span class="comment">   /// @param bits The size of the variable in bits</span><a name="l00077"></a><a class="code" href="classPmap.html#a1">00077</a> <span class="comment"></span>   <a class="code" href="classPmap.html#a0">Pmap</a>( <a class="code" href="CML__Utils_8h.html#a8">uint16</a> <a class="code" href="classPmap.html#p0">index</a>, <a class="code" href="CML__Utils_8h.html#a2">byte</a> <a class="code" href="classPmap.html#p1">sub</a>, <a class="code" href="CML__Utils_8h.html#a2">byte</a> <a class="code" href="classPmap.html#p2">bits</a> )<a name="l00078"></a>00078    {<a name="l00079"></a>00079       <a class="code" href="classPmap.html#a3">Init</a>( index, sub, bits );<a name="l00080"></a>00080    }<a name="l00081"></a>00081 <span class="comment"></span><a name="l00082"></a>00082 <span class="comment">   /// Virtual destructor</span><a name="l00083"></a><a class="code" href="classPmap.html#a2">00083</a> <span class="comment"></span>   <span class="keyword">virtual</span> <a class="code" href="classPmap.html#a2">~Pmap</a>(){}<a name="l00084"></a>00084 <span class="comment"></span><a name="l00085"></a>00085 <span class="comment">   /// Initialize a generic PDO mapping variable</span><a name="l00086"></a>00086 <span class="comment">   /// @param index The index of the variable in the object dictionary</span><a name="l00087"></a>00087 <span class="comment">   /// @param sub The variable's sub-index in the object dictionary</span><a name="l00088"></a>00088 <span class="comment">   /// @param bits The size of the variable in bits</span><a name="l00089"></a>00089 <span class="comment">   /// @return An error object</span><a name="l00090"></a><a class="code" href="classPmap.html#a3">00090</a> <span class="comment"></span>   <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classPmap.html#a3">Init</a>( <a class="code" href="CML__Utils_8h.html#a8">uint16</a> <a class="code" href="classPmap.html#p0">index</a>, <a class="code" href="CML__Utils_8h.html#a2">byte</a> <a class="code" href="classPmap.html#p1">sub</a>, <a class="code" href="CML__Utils_8h.html#a2">byte</a> <a class="code" href="classPmap.html#p2">bits</a> )<a name="l00091"></a>00091    {<a name="l00092"></a>00092       this-&gt;index = index;<a name="l00093"></a>00093       this-&gt;sub   = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(sub);<a name="l00094"></a>00094       this-&gt;bits  = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(bits);<a name="l00095"></a>00095       <span class="keywordflow">return</span> 0;<a name="l00096"></a>00096    }<a name="l00097"></a>00097 <span class="comment"></span><a name="l00098"></a>00098 <span class="comment">   /// Called when a receive PDO is about to be transmitted.</span><a name="l00099"></a>00099 <span class="comment">   /// This virtual function does nothing and therefore objects of this</span><a name="l00100"></a>00100 <span class="comment">   /// generic type shouldn't be used when actually transmitting PDOs</span><a name="l00101"></a><a class="code" href="classPmap.html#a4">00101</a> <span class="comment"></span>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPmap.html#a4">Get</a>( <a class="code" href="CML__Utils_8h.html#a2">byte</a> *cptr ){};<a name="l00102"></a>00102 <span class="comment"></span><a name="l00103"></a>00103 <span class="comment">   /// Called when a transmit PDO is received.  This virtual function</span><a name="l00104"></a>00104 <span class="comment">   /// doesn't do anything and therefore objects of this base class should</span><a name="l00105"></a>00105 <span class="comment">   /// only be used for variables that are not of interest and can therefore</span><a name="l00106"></a>00106 <span class="comment">   /// be ignored.</span>

⌨️ 快捷键说明

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