00001
00055 #define _EXPORT_CCL_
00056
00057 #include "CigiSensorCtrlV3.h"
00058 #include "CigiSwapping.h"
00059 #include "CigiExceptions.h"
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 CigiSensorCtrlV3::CigiSensorCtrlV3()
00071 {
00072
00073 PacketID = CIGI_SENSOR_CTRL_PACKET_ID_V3;
00074 PacketSize = CIGI_SENSOR_CTRL_PACKET_SIZE_V3;
00075 Version = 3;
00076 MinorVersion = 0;
00077
00078 ViewID = 0;
00079 SensorID = 0;
00080 SensorOn = false;
00081 Polarity = WhiteHot;
00082 LineDropEn = false;
00083 TrackMode = TrackOff;
00084 AutoGainEn = false;
00085 TrackPolarity = TrackWhite;
00086 ResponseType = GatePos;
00087 Gain = 0.0;
00088 Level = 0.0;
00089 ACCoupling = 0.0;
00090 Noise = 0.0;
00091
00092 }
00093
00094
00095
00096
00097 CigiSensorCtrlV3::~CigiSensorCtrlV3()
00098 {
00099
00100 }
00101
00102
00103
00104
00105
00106
00107
00108
00109 int CigiSensorCtrlV3::Pack(CigiBasePacket * Base, Cigi_uint8 * Buff, void *Spec) const
00110 {
00111 PackPointer CDta;
00112
00113 CigiBaseSensorCtrl * Data = ( CigiBaseSensorCtrl *)Base;
00114
00115 CDta.c = Buff;
00116
00117 *CDta.c++ = PacketID;
00118 *CDta.c++ = PacketSize;
00119
00120 *CDta.s++ = Data->ViewID;
00121 *CDta.c++ = Data->SensorID;
00122
00123 Cigi_uint8 HDta = (Cigi_uint8)(Data->TrackMode << 5);
00124
00125 if(Data->TrackPolarity == TrackBlack)
00126 HDta |= 0x10;
00127
00128 if(Data->AutoGainEn)
00129 HDta |= 0x08;
00130
00131 if(Data->LineDropEn)
00132 HDta |= 0x04;
00133
00134 if(Data->Polarity == BlackHot)
00135 HDta |= 0x02;
00136
00137 if(Data->SensorOn)
00138 HDta |= 0x01;
00139
00140 *CDta.c++ = HDta;
00141
00142 *CDta.c++ = (Cigi_uint8)(Data->ResponseType & 0x01);
00143
00144 *CDta.c++ = 0;
00145
00146 *CDta.f++ = Data->Gain;
00147 *CDta.f++ = Data->Level;
00148 *CDta.f++ = Data->ACCoupling;
00149 *CDta.f++ = Data->Noise;
00150
00151 return(PacketSize);
00152
00153 }
00154
00155
00156
00157
00158 int CigiSensorCtrlV3::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00159 {
00160 PackPointer CDta;
00161
00162 CDta.c = Buff;
00163
00164 CDta.c += 2;
00165
00166 if(!Swap)
00167 {
00168 ViewID = *CDta.s++;
00169 SensorID = *CDta.c++;
00170
00171 Cigi_uint8 HDta = *CDta.c++;
00172
00173 SensorOn = ((HDta & 0x01) != 0);
00174 Polarity = (PolarityGrp)((HDta >> 1) & 0x01);
00175 LineDropEn = ((HDta & 0x04) != 0);
00176 AutoGainEn = ((HDta & 0x08) != 0);
00177 TrackPolarity = (TrackPolarityGrp)((HDta >> 4) & 0x01);
00178 TrackMode = (TrackModeGrp)((HDta >> 5) & 0x07);
00179
00180 HDta = *CDta.c++;
00181
00182 ResponseType = (ResponseTypeGrp)(HDta & 0x01);
00183
00184 CDta.c++;
00185
00186 Gain = *CDta.f++;
00187 Level = *CDta.f++;
00188 ACCoupling = *CDta.f++;
00189 Noise = *CDta.f++;
00190 }
00191 else
00192 {
00193 CigiSwap2(&ViewID, CDta.s++);
00194 SensorID = *CDta.c++;
00195
00196 Cigi_uint8 HDta = *CDta.c++;
00197
00198 SensorOn = ((HDta & 0x01) != 0);
00199 Polarity = (PolarityGrp)((HDta >> 1) & 0x01);
00200 LineDropEn = ((HDta & 0x04) != 0);
00201 AutoGainEn = ((HDta & 0x08) != 0);
00202 TrackPolarity = (TrackPolarityGrp)((HDta >> 4) & 0x01);
00203 TrackMode = (TrackModeGrp)((HDta >> 5) & 0x07);
00204
00205 HDta = *CDta.c++;
00206
00207 ResponseType = (ResponseTypeGrp)(HDta & 0x01);
00208
00209 CDta.c++;
00210
00211 CigiSwap4(&Gain, CDta.f++);
00212 CigiSwap4(&Level, CDta.f++);
00213 CigiSwap4(&ACCoupling, CDta.f++);
00214 CigiSwap4(&Noise, CDta.f++);
00215 }
00216
00217 return(PacketSize);
00218
00219 }
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 int CigiSensorCtrlV3::SetResponseType(const ResponseTypeGrp ResponseTypeIn, bool bndchk)
00232 {
00233
00234 #ifndef CIGI_NO_BND_CHK
00235 if(bndchk && ((ResponseTypeIn < 0)||(ResponseTypeIn > 1)))
00236 {
00237 #ifndef CIGI_NO_EXCEPT
00238 throw CigiValueOutOfRangeException("ResponseType",(ResponseTypeGrp)ResponseTypeIn,0,1);
00239 #endif
00240 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00241 }
00242 #endif
00243
00244 ResponseType = ResponseTypeIn;
00245 return(CIGI_SUCCESS);
00246
00247 }
00248
00249
00250
00251
00252
00253 int CigiSensorCtrlV3::SetGain(const float GainIn, bool bndchk)
00254 {
00255
00256 #ifndef CIGI_NO_BND_CHK
00257 if(bndchk && ((GainIn < 0.0)||(GainIn > 1.0)))
00258 {
00259 #ifndef CIGI_NO_EXCEPT
00260 throw CigiValueOutOfRangeException("Gain",(float)GainIn,0.0,1.0);
00261 #endif
00262 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00263 }
00264 #endif
00265
00266 Gain = GainIn;
00267 return(CIGI_SUCCESS);
00268
00269 }
00270
00271