functions for the communication between SOLID slow control modules and Cprograms
Diff: sscm_comm.cpp
- Revision:
- 10:0675c2e3d330
- Parent:
- 9:4bfcfa029dff
- Child:
- 12:cf007e9619e1
diff -r 4bfcfa029dff -r 0675c2e3d330 sscm_comm.cpp --- a/sscm_comm.cpp Tue Oct 14 17:06:23 2014 +0000 +++ b/sscm_comm.cpp Thu Oct 23 17:24:33 2014 +0000 @@ -10,6 +10,9 @@ * version history * v3.31 first version history entry * v3.32 changed the return values for decode and range checking + * v3.33 corrected range checking temperature + * v3.40 added float to datain , dataout conversion + * v3.41 bug status decoding corrected *******/ #include "sscm_comm.h" @@ -17,7 +20,7 @@ -#define SSCM_COMM_LIB_SRC_VERSION "3.32" +#define SSCM_COMM_LIB_SRC_VERSION "3.40" using namespace sscm_comm; @@ -51,7 +54,7 @@ part[0]=input[ic++];part[1]=input[ic++];part[2]=input[ic++];part[3]=input[ic++];part[4]=0;sc->dataout = (u16)strtol(part, NULL, 16); if( input[ic++] != SEP ) rv= -7; else { - part[0]=input[ic++];part[1]=input[ic++];part[4]=0;sc->status = (u8)strtol(part, NULL, 16); + part[0]=input[ic++];part[1]=input[ic++];part[3]=0;sc->status = (u8)strtol(part, NULL, 16); if( input[ic++] != SEP ) rv= -8; else rv=0; @@ -75,7 +78,7 @@ case ADC : if(sc->devnr < 1 || sc->devnr > 2 ){ rv=-0x11; break; } break; - case TEMP : if( sc->ch <1 || sc->ch >2) {rv =-0x12 ;break;} + case TEMP : if( sc->devnr <1 || sc->devnr >3) {rv =-0x12 ;break;} break; default : rv=1; } @@ -96,19 +99,27 @@ } -/* -u16 sscm_comm::getSrcVersion(){ - return get_hex_version_nr(SSCM_COMM_LIB_SRC_VERSION ); -} - -u16 sscm_comm::getHdrVersion(){ - return get_hex_version_nr(SSCM_COMM_LIB_HDR_VERSION ); -} -*/ void sscm_comm::get_mppc_dac_chnr(u8 plane, u8 x , u8 y, u8& ch,u8& modulenr, u8& connr ,u8&dacch, u8& serialnr ) {}; void sscm_comm::get_mppc_adc_chnr(u8 plane, u8 x , u8 y, u8& ch,u8& modulenr, u8& connr , u8& adcdevnr, u8& adcchnr , u8& serialnr ){}; +void sscm_comm::float2_2u16( float in, u16& msb, u16& lsb){ + float* inp=∈ + u16* pi=(u16*)inp; + msb=*pi; pi++; + lsb=*pi; +} +float sscm_comm::u162float( u16 msb, u16 lsb){ + float rv=-288; + float* fp=&rv; + u16* rp=(u16*)fp ; + *rp=msb; rp++; + *rp=lsb; + return rv; +} + + + sscm_comm::getsscmVersion::getsscmVersion():getVersion( SSCM_COMM_LIB_HDR_VERSION,SSCM_COMM_LIB_SRC_VERSION, __TIME__, __DATE__){};