Tcm.cpp file, 5 tcm.cpp file – PNI TCM User Manual
Page 74
PNI Sensor Corporation
DOC#1014688 r06
TCM User Manual
– July 2013
Page 69
7.4.5
TCM.cpp File
#i nc l ude " TCM. h"
#i nc l ude " Ti ck Gener at or . h"
c ons t UI nt 8 kDat aCount = 4;
/ / We wi l l be r eques t i ng 4 component s ( headi ng, pi t c h, r ol l , and
/ / t emper at ur e)
/ /
/ / Thi s obj ec t pol l s t he TCM modul e onc e a second f or
/ / headi ng, pi t ch, r ol l and t emper at ur e.
/ /
TCM: : TCM( Ser Por t * s er Por t )
: Pr ocess ( " TCM" )
{
/ / Let t he CommPr ot oc ol k now t hi s obj ec t wi l l handl e any
/ / s er i al dat a r et ur ned by t he modul e
mComm = new CommPr ot ocol ( t hi s , ser Por t ) ;
mTi me = 0;
mSt ep = 1;
}
TCM: : ~TCM( )
{
}
/ /
/ / Cal l ed by t he CommPr ot oc ol obj ec t when a f r ame i s c ompl et el y / /
r ecei v ed
/ /
v oi d TCM: : Handl eComm( UI nt 8 f r ameType, v oi d * dat aPt r , UI nt 16
dat aLen)
{
UI nt 8 * dat a = ( UI nt 8 * ) dat aPt r ;
s wi t ch( f r ameTy pe)
{
c ase CommPr ot ocol : : k Get Dat aResp:
{
/ / Par se t he dat a r es pons e
UI nt 8 count = dat a[ 0] ;
/ / The number of dat a el ement s r et ur ned
UI nt 32 pnt r = 1;
/ / Used t o r et r i ev e t he r et ur ned el ement s
/ / The dat a el ement s we r equest ed
Fl oat 32 headi ng, pi t c h, r ol l , t emper at ur e;
i f ( c ount ! = kDat aCount )
{
/ / Mes sage i s a f unc t i on t hat di s pl ay s a C f or mat t ed s t r i ng
/ / ( si mi l ar t o pr i nt f )
Mess age( " Rec ei ved %u dat a el ement s i nst ead of
t he %u r equest ed\ r \ n" , ( UI nt 16) count ,
( UI nt 16) k Dat aCount ) ;
r et ur n;