📄 filter_8cpp-source.html
字号:
<!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: Filter.cpp 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 Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div><div class="nav"><a class="el" href="dir_000000.html">c</a></div><h1>Filter.cpp</h1><a href="Filter_8cpp.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">/** \file</span><a name="l00013"></a>00013 <span class="comment">Implementation of the Filter class.</span><a name="l00014"></a>00014 <span class="comment">*/</span><a name="l00015"></a>00015 <a name="l00016"></a>00016 <span class="preprocessor">#include "<a class="code" href="CML_8h.html">CML.h</a>"</span><a name="l00017"></a>00017 <a name="l00018"></a>00018 <a class="code" href="CML__Settings_8h.html#a13">CML_NAMESPACE_USE</a>();<a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00021"></a>00021 <span class="comment">/**</span><a name="l00022"></a>00022 <span class="comment">Default constructor for filter object. Simply sets all coefficients to zero.</span><a name="l00023"></a>00023 <span class="comment">*/</span><a name="l00024"></a>00024 <span class="comment">/***************************************************************************/</span><a name="l00025"></a><a class="code" href="classFilter.html#a0">00025</a> <a class="code" href="classFilter.html#a0">Filter::Filter</a>( <span class="keywordtype">void</span> )<a name="l00026"></a>00026 {<a name="l00027"></a>00027 <span class="comment">// Setting the filter info field to 0xffff </span><a name="l00028"></a>00028 <span class="comment">// disables the filter</span><a name="l00029"></a>00029 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i<3; i++ )<a name="l00030"></a>00030 <a class="code" href="classFilter.html#o0">info</a>[i] = 0xFFFF;<a name="l00031"></a>00031 <a name="l00032"></a>00032 <a class="code" href="classFilter.html#o1">a0</a> = <a class="code" href="classFilter.html#o2">a1</a> = <a class="code" href="classFilter.html#o3">a2</a> = <a class="code" href="classFilter.html#o4">b1</a> = <a class="code" href="classFilter.html#o5">b2</a> = <a class="code" href="classFilter.html#o6">k</a> = 0;<a name="l00033"></a>00033 }<a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00036"></a>00036 <span class="comment">/**</span><a name="l00037"></a>00037 <span class="comment">Convert the filter's coefficients to an array of 18 byte values which can</span><a name="l00038"></a>00038 <span class="comment">then be downloaded to the amplifier.</span><a name="l00039"></a>00039 <span class="comment">@param data An array of 18+ bytes which will be filled with the converted</span><a name="l00040"></a>00040 <span class="comment">coefficient values.</span><a name="l00041"></a>00041 <span class="comment">*/</span><a name="l00042"></a>00042 <span class="comment">/***************************************************************************/</span><a name="l00043"></a><a class="code" href="classFilter.html#a1">00043</a> <span class="keywordtype">void</span> <a class="code" href="classFilter.html#a1">Filter::toBytes</a>( <a class="code" href="CML__Utils_8h.html#a2">byte</a> data[] )<a name="l00044"></a>00044 {<a name="l00045"></a>00045 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i<3; i++ )<a name="l00046"></a>00046 {<a name="l00047"></a>00047 data[2*i] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o0">info</a>[i]);<a name="l00048"></a>00048 data[2*i+1] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o0">info</a>[i]>>8);<a name="l00049"></a>00049 }<a name="l00050"></a>00050 <a name="l00051"></a>00051 data[ 6] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o1">a0</a>); data[ 7] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o1">a0</a>>>8);<a name="l00052"></a>00052 data[ 8] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o2">a1</a>); data[ 9] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o2">a1</a>>>8);<a name="l00053"></a>00053 data[10] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o3">a2</a>); data[11] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o3">a2</a>>>8);<a name="l00054"></a>00054 data[12] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o4">b1</a>); data[13] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o4">b1</a>>>8);<a name="l00055"></a>00055 data[14] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o5">b2</a>); data[15] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>(<a class="code" href="classFilter.html#o5">b2</a>>>8);<a name="l00056"></a>00056 data[16] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>( <a class="code" href="classFilter.html#o6">k</a>); data[17] = <a class="code" href="CML__Utils_8h.html#a0">ByteCast</a>( <a class="code" href="classFilter.html#o6">k</a>>>8);<a name="l00057"></a>00057 }<a name="l00058"></a>00058 <a name="l00059"></a>00059 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00060"></a>00060 <span class="comment">/**</span><a name="l00061"></a>00061 <span class="comment">Load the filter coefficient structure given an array of 18 bytes of data.</span><a name="l00062"></a>00062 <span class="comment">This function is useful for loading the filter based on data received over</span><a name="l00063"></a>00063 <span class="comment">the CANopen interface.</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="classFilter.html#a2">00066</a> <span class="keywordtype">void</span> <a class="code" href="classFilter.html#a2">Filter::fromBytes</a>( <a class="code" href="CML__Utils_8h.html#a2">byte</a> data[] )<a name="l00067"></a>00067 {<a name="l00068"></a>00068 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i<3; i++ )<a name="l00069"></a>00069 <a class="code" href="classFilter.html#o0">info</a>[i] = <a class="code" href="CML__Utils_8h.html#a13">bytes_to_uint16</a>( &data[2*i] );<a name="l00070"></a>00070 <a name="l00071"></a>00071 <a class="code" href="classFilter.html#o1">a0</a> = <a class="code" href="CML__Utils_8h.html#a13">bytes_to_uint16</a>( &data[ 6] );<a name="l00072"></a>00072 <a class="code" href="classFilter.html#o2">a1</a> = <a class="code" href="CML__Utils_8h.html#a13">bytes_to_uint16</a>( &data[ 8] );<a name="l00073"></a>00073 <a class="code" href="classFilter.html#o3">a2</a> = <a class="code" href="CML__Utils_8h.html#a13">bytes_to_uint16</a>( &data[10] );<a name="l00074"></a>00074 <a class="code" href="classFilter.html#o4">b1</a> = <a class="code" href="CML__Utils_8h.html#a13">bytes_to_uint16</a>( &data[12] );<a name="l00075"></a>00075 <a class="code" href="classFilter.html#o5">b2</a> = <a class="code" href="CML__Utils_8h.html#a13">bytes_to_uint16</a>( &data[14] );<a name="l00076"></a>00076 <a class="code" href="classFilter.html#o6">k</a> = <a class="code" href="CML__Utils_8h.html#a13">bytes_to_uint16</a>( &data[16] );<a name="l00077"></a>00077 }<a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00080"></a>00080 <span class="comment">/**</span><a name="l00081"></a>00081 <span class="comment">Load the filter coefficient structure given an array of 9 16-bit words of data.</span><a name="l00082"></a>00082 <span class="comment">This function is useful for loading the filter based on data read from a </span><a name="l00083"></a>00083 <span class="comment">CME-2 amplifier data file.</span><a name="l00084"></a>00084 <span class="comment">*/</span><a name="l00085"></a>00085 <span class="comment">/***************************************************************************/</span><a name="l00086"></a><a class="code" href="classFilter.html#a3">00086</a> <span class="keywordtype">void</span> <a class="code" href="classFilter.html#a3">Filter::fromWords</a>( <a class="code" href="CML__Utils_8h.html#a7">int16</a> data[] )<a name="l00087"></a>00087 {<a name="l00088"></a>00088 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i<3; i++ )<a name="l00089"></a>00089 <a class="code" href="classFilter.html#o0">info</a>[i] = data[i];<a name="l00090"></a>00090 <a name="l00091"></a>00091 <a class="code" href="classFilter.html#o1">a0</a> = data[3];<a name="l00092"></a>00092 <a class="code" href="classFilter.html#o2">a1</a> = data[4];<a name="l00093"></a>00093 <a class="code" href="classFilter.html#o3">a2</a> = data[5];<a name="l00094"></a>00094 <a class="code" href="classFilter.html#o4">b1</a> = data[6];<a name="l00095"></a>00095 <a class="code" href="classFilter.html#o5">b2</a> = data[7];<a name="l00096"></a>00096 <a class="code" href="classFilter.html#o6">k</a> = data[8];<a name="l00097"></a>00097 }<a name="l00098"></a>00098 </pre></div><hr><address style="align: right;"><small>Copley Motion Library, Copyright (c) 2002-2003<a href="http://www.copleycontrols.com"><img src="CCC_logo.gif" alt="Copley Controls Corp." align="middle" border=0 ></a></small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -