FedmIscPeopleCounter.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |                       FedmIscPeopleCounter.cpp                                        |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright © 2010                FEIG ELECTRONIC GmbH, All Rights Reserved.
00008                                                 Lange Strasse 4
00009                                                 D-35781 Weilburg
00010                                                 Federal Republic of Germany
00011                                                 phone    : +49 6471 31090
00012                                                 fax      : +49 6471 310999
00013                                                 e-mail   : obid-support@feig.de
00014                                                 Internet : http://www.feig.de
00015                                         
00016 Author                  :       Manuel Sahm
00017 Begin                   :       18.02.2010
00018 
00019 Version                 :       03.02.04 / 25.08.2010 / M. Hultsch
00020 
00021 Operation Systems       :       independent
00022 
00023 Function                        :       this class supports the peripheral device called People Counter
00024 
00025 
00026 Trademarks:
00027 -----------
00028 OBID®, OBID i-scan® and OBID myAXXESS® are registered Trademarks of FEIG ELECTRONIC GmbH
00029 Other Trademarks: see FEDM.h
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 // class FedmIscPeopleCounter
00047 //####################################################################
00048 
00050 // Constructor
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 // Destructor
00060 FedmIscPeopleCounter::~FedmIscPeopleCounter()
00061 {
00062 }
00063 
00064 
00065 /***************************************************************************
00066   Begin                 :       18.02.2010 / M. Sahm
00067   
00068   Version               :       03.01.01 / 18.02.2010 / M. Sahm
00069 
00070   Function                      :       Set Outputs 
00071 
00072   Parameters            :       FEISC_GPC_OUTPUT structure for Output 1, 2 and 3
00073 
00074   Return value          :       0:              FEDM_OK
00075                                                 <0:             Error Code
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         // Check if at least on pointer is valid
00088         if((pOutput1 == NULL) && (pOutput2 == NULL) && (pOutput3 == NULL))
00089         {
00090                 FEDM_RETURN(FEDM_ERROR_NULL_POINTER);
00091         }
00092 
00093         m_iSendDataLen = 0;
00094 
00095         // Build the "internal" protocol
00096         m_ucSendData[0] = 0x01; // Mode Byte
00097         m_ucSendData[1] = 0x00; // OUT-N
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         // Build Protocol : SetOutput (0x72)
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         // Send Protocol within Piggyback frame
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) // Reader: External Device communication error
00143         {
00144                 FEDM_RETURN(iBack);
00145         }
00146 
00147         // Get Response out of Answer from Protocol 0x72 (SetOutput)
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         // Anaylze the Response Data
00155         FEDM_RETURN(FEDM_OK);
00156 }
00157 
00158 
00159 /***************************************************************************
00160   Begin                 :       18.02.2010 / M. Sahm
00161   
00162   Version               :       03.02.00 / 15.06.2010 / M. Sahm
00163 
00164   Function                      :       Get the Counter Values
00165 
00166   Parameters            :       <unsigned int&> uiRadar1_Cnt1:  Counter Value 1 of Radar Detector 1
00167                                                 <unsigned int&> uiRadar1_Cnt2:  Counter Value 2 of Radar Detector 1 
00168                                                 <unsigned int&> uiRadar2_Cnt1:  Counter Value 1 of Radar Detector 2
00169                                                 <unsigned int&> uiRadar2_Cnt2:  Counter Value 2 of Radar Detector 2
00170 
00171   Return value          :       0:              FEDM_OK
00172                                                 <0:             Error Code
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         //Build the "internal" protocol
00181         m_ucSendData[0] = 0x00;                         //Mode-Byte
00182         
00183         // Build Protocol : GetCounter (0x77)
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         // Send Protocol within Piggyback frame
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) // Reader: External Device communication error
00197         {
00198                 FEDM_RETURN(iBack);
00199         }
00200 
00201         // Get Response out of Answer from Protocol 0x77 (GetCounter)
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         // Anaylze the Response Data
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   Begin                 :       18.02.2010 / M. Sahm
00231   
00232   Version               :       03.01.01 / 18.02.2010 / M. Sahm
00233 
00234   Function                      :       Set the Counter Values
00235 
00236   Parameters            :       <unsigned int> uiRadar1_Cnt1:   Counter Value 1 of Radar Detector 1
00237                                                 <unsigned int> uiRadar1_Cnt2:   Counter Value 2 of Radar Detector 1
00238                                                 <unsigned int> uiRadar2_Cnt1:   Counter Value 1 of Radar Detector 2
00239                                                 <unsigned int> uiRadar2_Cnt2:   Counter Value 2 of Radar Detector 2
00240 
00241   Return value          :       0:              FEDM_OK
00242                                                 <0:             Error Code
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         // Build the "internal" Protocol
00253         m_ucSendData[0] = 0x00;                                         // Mode Byte
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         // Build Protocol : SetCounter (0x78)
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         // Send Protocol within Piggyback frame
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) // Reader: External Device communication error
00286         {
00287                 FEDM_RETURN(iBack);
00288         }
00289 
00290         // Get Response out of Answer from Protocol 0x78 (SetCounter)
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         // Anaylze the Response Data
00298         FEDM_RETURN(FEDM_OK);
00299 }
00300 
00301 #endif // #if !defined(_FEDM_NO_PD_SUPPORT)


maggie_rfid_drivers
Author(s): Raul Perula-Martinez
autogenerated on Mon Sep 14 2015 03:05:30