00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #if !defined(_FEDM_NO_PD_SUPPORT)
00033
00034 #include "FedmIscPeopleCounter.h"
00035 #include "../FEDM_ISCReader.h"
00036 #include "feisc.h"
00037
00038
00039 #if _MSC_VER >= 1400
00040 #pragma warning(disable : 4996)
00041 #endif
00042
00043
00044
00045
00046
00047
00048
00050
00052 FedmIscPeopleCounter::FedmIscPeopleCounter(FEDM_ISCReader* pReader, unsigned char ucBusAdr)
00053 : FedmIscPeripheralDevice(pReader, ucBusAdr, FEDM_ISC_PD_PORT_TYPE_RS4XX, FEDM_ISC_PD_TYPE_PEOPLE_COUNTER)
00054 {
00055 }
00056
00058
00060 FedmIscPeopleCounter::~FedmIscPeopleCounter()
00061 {
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 int FedmIscPeopleCounter::SetOutput( FEISC_GPC_OUTPUT* pOutput1,
00078 FEISC_GPC_OUTPUT* pOutput2,
00079 FEISC_GPC_OUTPUT* pOutput3)
00080 {
00081 int iBack = 0;
00082 unsigned char* pData = NULL;
00083 unsigned char ucRecBusAddr = 0x00;
00084 unsigned char ucCmd = 0x00;
00085
00086
00087
00088 if((pOutput1 == NULL) && (pOutput2 == NULL) && (pOutput3 == NULL))
00089 {
00090 FEDM_RETURN(FEDM_ERROR_NULL_POINTER);
00091 }
00092
00093 m_iSendDataLen = 0;
00094
00095
00096 m_ucSendData[0] = 0x01;
00097 m_ucSendData[1] = 0x00;
00098 m_iSendDataLen += 2;
00099 pData = &m_ucSendData[2];
00100 if(pOutput1 != NULL && pOutput1->ucNumber > 0)
00101 {
00102 m_ucSendData[1] += 1;
00103 *pData++ = (pOutput1->ucNumber & 0x0F) | ((pOutput1->ucType << 5) & 0xE0);
00104 *pData++ = (pOutput1->ucMode & 0x03) | ((pOutput1->ucFrequency << 2) & 0x0C);
00105 *pData++ = (pOutput1->uiHoldTime >> 8) & 0xFF;
00106 *pData++ = pOutput1->uiHoldTime & 0xFF;
00107 m_iSendDataLen += 4;
00108 }
00109 if(pOutput2 != NULL && pOutput2->ucNumber > 0)
00110 {
00111 m_ucSendData[1] += 1;
00112 *pData++ = (pOutput2->ucNumber & 0x0F) | ((pOutput2->ucType << 5) & 0xE0);
00113 *pData++ = (pOutput2->ucMode & 0x03) | ((pOutput2->ucFrequency << 2) & 0x0C);
00114 *pData++ = (pOutput2->uiHoldTime >> 8) & 0xFF;
00115 *pData++ = pOutput2->uiHoldTime & 0xFF;
00116 m_iSendDataLen += 4;
00117 }
00118 if(pOutput3 != NULL && pOutput3->ucNumber > 0)
00119 {
00120 m_ucSendData[1] += 1;
00121 *pData++ = (pOutput3->ucNumber & 0x0F) | ((pOutput3->ucType << 5) & 0xE0);
00122 *pData++ = (pOutput3->ucMode & 0x03) | ((pOutput3->ucFrequency << 2) & 0x0C);
00123 *pData++ = (pOutput3->uiHoldTime >> 8) & 0xFF;
00124 *pData++ = pOutput3->uiHoldTime & 0xFF;
00125 m_iSendDataLen += 4;
00126 }
00127
00128
00129
00130 m_iSendProtLen = FEISC_BuildSendProtocol(m_iReaderHnd, m_ucBusAdr, FEISC_SET_OUTPUT_EX, m_ucSendData , m_iSendDataLen, m_ucSendProt, 0);
00131 if(m_iSendProtLen <= 0)
00132 {
00133 FEDM_RETURN(m_iSendProtLen);
00134 }
00135
00136
00137 iBack = FEISC_0x9F_Piggyback_Command(m_pReader->GetReaderHnd(),m_pReader->GetBusAddress(), 0x00, FEDM_ISC_TYPE_ANT_GPC, FEDM_ISC_PD_PORT_TYPE_RS4XX, m_ucSendProt, m_iSendProtLen, m_ucRspProt, &m_iRspProtLen);
00138 if(iBack < 0)
00139 {
00140 FEDM_RETURN(iBack);
00141 }
00142 else if(iBack == 0x20)
00143 {
00144 FEDM_RETURN(iBack);
00145 }
00146
00147
00148 iBack = FEISC_SplitRecProtocol(m_iReaderHnd, m_ucRspProt, m_iRspProtLen, &ucRecBusAddr, &ucCmd, m_ucRspData, &m_iRspDataLen, 0);
00149 if(iBack != 0)
00150 {
00151 FEDM_RETURN(iBack);
00152 }
00153
00154
00155 FEDM_RETURN(FEDM_OK);
00156 }
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 int FedmIscPeopleCounter::GetCounter(unsigned int& uiPC_Sense1, unsigned int& uiPC_Sense2, unsigned int& uiPC_Sense3, unsigned int& uiPC_Sense4)
00175 {
00176 int iBack = 0;
00177 unsigned char ucRecBusAddr = 0x00;
00178 unsigned char ucCmd = 0x00;
00179
00180
00181 m_ucSendData[0] = 0x00;
00182
00183
00184 m_iSendProtLen = FEISC_BuildSendProtocol(m_iReaderHnd, m_ucBusAdr, FEISC_GET_COUNTER, m_ucSendData , 1, m_ucSendProt, 0);
00185 if(m_iSendProtLen <= 0)
00186 {
00187 FEDM_RETURN(m_iSendProtLen);
00188 }
00189
00190
00191 iBack = FEISC_0x9F_Piggyback_Command(m_pReader->GetReaderHnd(),m_pReader->GetBusAddress(), 0x00, FEDM_ISC_TYPE_ANT_GPC, FEDM_ISC_PD_PORT_TYPE_RS4XX, m_ucSendProt, m_iSendProtLen, m_ucRspProt, &m_iRspProtLen);
00192 if(iBack < 0)
00193 {
00194 FEDM_RETURN(iBack);
00195 }
00196 else if(iBack == 0x20)
00197 {
00198 FEDM_RETURN(iBack);
00199 }
00200
00201
00202 iBack = FEISC_SplitRecProtocol(m_iReaderHnd, m_ucRspProt, m_iRspProtLen, &ucRecBusAddr, &ucCmd, m_ucRspData, &m_iRspDataLen, 0);
00203 if(iBack != 0)
00204 {
00205 FEDM_RETURN(iBack);
00206 }
00207
00208
00209 if(m_iRspDataLen == 16)
00210 {
00211 uiPC_Sense1 = m_ucRspData[3] | m_ucRspData [2] << 8 | m_ucRspData[1] << 16 | m_ucRspData[0] << 24;
00212 uiPC_Sense2 = m_ucRspData[7] | m_ucRspData [6] << 8 | m_ucRspData[5] << 16 | m_ucRspData[4] << 24;
00213 uiPC_Sense3 = m_ucRspData[11] | m_ucRspData [10] << 8 | m_ucRspData[9] << 16 | m_ucRspData[8] << 24;
00214 uiPC_Sense4 = m_ucRspData[15] | m_ucRspData [14] << 8 | m_ucRspData[13] << 16 | m_ucRspData[12] << 24;
00215 }
00216 else
00217 {
00218 uiPC_Sense1 = 0;
00219 uiPC_Sense2 = 0;
00220 uiPC_Sense3 = 0;
00221 uiPC_Sense4 = 0;
00222 FEDM_RETURN(FEDM_ERROR_NO_DATA);
00223 }
00224
00225 FEDM_RETURN(FEDM_OK);
00226 }
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 int FedmIscPeopleCounter::SetCounter(unsigned int uiPC_Sense1, unsigned int uiPC_Sense2, unsigned int uiPC_Sense3, unsigned int uiPC_Sense4)
00245 {
00246 int iBack = 0;
00247 unsigned char ucRecBusAddr = 0x00;
00248 unsigned char ucCmd = 0x00;
00249
00250
00251
00252
00253 m_ucSendData[0] = 0x00;
00254 m_ucSendData[1] = uiPC_Sense1 >> 24;
00255 m_ucSendData[2] = uiPC_Sense1 >> 16;
00256 m_ucSendData[3] = uiPC_Sense1 >> 8;
00257 m_ucSendData[4] = uiPC_Sense1;
00258 m_ucSendData[5] = uiPC_Sense2 >> 24;
00259 m_ucSendData[6] = uiPC_Sense2 >> 16;
00260 m_ucSendData[7] = uiPC_Sense2 >> 8;
00261 m_ucSendData[8] = uiPC_Sense2;
00262 m_ucSendData[9] = uiPC_Sense3 >> 24;
00263 m_ucSendData[10] = uiPC_Sense3 >> 16;
00264 m_ucSendData[11] = uiPC_Sense3 >> 8;
00265 m_ucSendData[12] = uiPC_Sense3;
00266 m_ucSendData[13] = uiPC_Sense4 >> 24;
00267 m_ucSendData[14] = uiPC_Sense4 >> 16;
00268 m_ucSendData[15] = uiPC_Sense4 >> 8;
00269 m_ucSendData[16] = uiPC_Sense4;
00270
00271
00272
00273 m_iSendProtLen = FEISC_BuildSendProtocol(m_iReaderHnd, m_ucBusAdr, FEISC_SET_COUNTER, m_ucSendData , 17, m_ucSendProt, 0);
00274 if(m_iSendProtLen <= 0)
00275 {
00276 FEDM_RETURN(m_iSendProtLen);
00277 }
00278
00279
00280 iBack = FEISC_0x9F_Piggyback_Command(m_pReader->GetReaderHnd(),m_pReader->GetBusAddress(), 0x00, FEDM_ISC_TYPE_ANT_GPC, FEDM_ISC_PD_PORT_TYPE_RS4XX, m_ucSendProt, m_iSendProtLen, m_ucRspProt, &m_iRspProtLen);
00281 if(iBack < 0)
00282 {
00283 FEDM_RETURN(iBack);
00284 }
00285 else if(iBack == 0x20)
00286 {
00287 FEDM_RETURN(iBack);
00288 }
00289
00290
00291 iBack = FEISC_SplitRecProtocol(m_iReaderHnd, m_ucRspProt, m_iRspProtLen, &ucRecBusAddr, &ucCmd, m_ucRspData, &m_iRspDataLen, 0);
00292 if(iBack != 0)
00293 {
00294 FEDM_RETURN(iBack);
00295 }
00296
00297
00298 FEDM_RETURN(FEDM_OK);
00299 }
00300
00301 #endif // #if !defined(_FEDM_NO_PD_SUPPORT)