Quellcode durchsuchen

#IQRV #comment [BugFix] GPIO ++ % 0 问题处理

gifur vor 4 Jahren
Ursprung
Commit
ab339967a6
2 geänderte Dateien mit 219 neuen und 194 gelöschten Zeilen
  1. 199 183
      Module/mod_gpio/mod_gpio.cpp
  2. 20 11
      Module/mod_gpio/mod_gpio.h

+ 199 - 183
Module/mod_gpio/mod_gpio.cpp

@@ -45,7 +45,7 @@ static const char* GetDriverPortString(int pin)
     case 15: return "";
     case 16: return "";
     case 17: return "【接收】震动探测器";
-    case 18: return "【接收】机感应开关";
+    case 18: return "【接收】机具门感应开关";
     case 19: return "【接收】话机提机感应开关";
     case 20: return "【接收】人体探测感应器";
     case 21: return "【接收】发卡器卡嘴覆盖探测器";
@@ -248,12 +248,12 @@ ErrorCodeEnum CGpioEntity::Initial()
     }
 
     err = m_hDevHelper->WritePort(0, 0x00);
-    Dbg("write ports(%d)", err);
+    Dbg("write ports(0) returned: %d)", err);
     err = m_hDevHelper->WritePort(1, 0x00);
-    Dbg("write ports(%d)", err);
+    Dbg("write ports(1) returned: %d", err);
     if (m_bNewVersion) {
         err = m_hDevHelper->WritePort(3, 0x00);
-        Dbg("write ports(%d)", err);
+        Dbg("write ports(3) returned: %d", err);
     }
 
     //oilyang@20170214 
@@ -437,7 +437,7 @@ void CGpioEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nLogID, con
         Req.close = 1;
         break;
     default:
-        Dbg("unkown event(%d)...", dwUserCode);
+        Dbg("unkown event: 0x%X", dwUserCode);
         return;
     }
     Dbg("devseq[%d],mode[%d]close[%d]", Req.devseq, Req.mode, Req.close);
@@ -680,7 +680,8 @@ Error:
 
 void CGpioEntity::GetStatus(int deviceSeq, SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
 {
-    Dbg("GetStatus devseq%d", deviceSeq);
+    /** 注意设备序号是实体内定义的逻辑,不是设备端口号*/
+    Dbg("GetStatus with devseq %d", deviceSeq);
     CSimpleStringA initDriver = "";
     int devicePort;
     ErrorCodeEnum Error;
@@ -691,14 +692,14 @@ void CGpioEntity::GetStatus(int deviceSeq, SpReqAnsContext<GpioService_GetStatus
         LOG_TRACE("open cfg file failed!");
         return;
     }
-    {
-        spConfig->ReadConfigValue("InitDriver", "PhoneLift", initDriver);
-        spConfig->ReadConfigValueInt("DriverPort", "PhoneLift", devicePort);
-        ReceivingInfo ri;
-        GetReceivingModInfo(initDriver, ri);
-        ri.Port = devicePort;
-        GetReceiving(deviceSeq, ri, PICKUPSENSOR, ctx);
-    }
+    /** 获取指定的模式,以便后续获取输入模式和持续触发模式,见 GetReceivingModInfo*/
+    spConfig->ReadConfigValue("InitDriver", "PhoneLift", initDriver);
+    /** 获取硬件规格里对应的序号,其实是固定死的*/
+    spConfig->ReadConfigValueInt("DriverPort", "PhoneLift", devicePort);
+    ReceivingInfo ri;
+    GetReceivingModInfo(initDriver, ri);
+    ri.Port = devicePort;
+    GetReceiving(deviceSeq, ri, PICKUPSENSOR, ctx);
 }
 void CGpioEntity::OnOutputPositiveLevelTimerout(void* pData)
 {
@@ -890,14 +891,18 @@ void CGpioEntity::OnNegativePulseUpTimerout(void* pData)
 void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
 {
     GetContextInfo* pGci = (GetContextInfo*)pData;
-    int count = pGci->InitCTT;
-    int initCTT = pGci->InitCTT;
-    int pos = pGci->Port;
+
+    const int count = pGci->InitCTT;
+    const int initCtt = pGci->InitCTT;
+    const int pos = pGci->Port;
+    
     ULONG input = 0;
+    BYTE btInput;
 
     bool bShakeOne, bMoveOne, bSwitchOne, bPhoneOne, bCardOne;
     bShakeOne = bMoveOne = bSwitchOne = bPhoneOne = bCardOne = false;
-    BYTE btInput;
+    
+
     ErrorCodeEnum err = m_hDevHelper->ReadPort(INPUT_PORT_2, btInput);
     if (err != Error_Succeed) {
         DevErrorInfo devErrInfo;
@@ -907,213 +912,204 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
         return;
     }
 
+    /** 震动感应 */
     if (pGci->CttShake == 1) {
+        
+        bShakeOne = true;
+
         do {
-            bShakeOne = true;
 
-            if (initCTT == 1) {
+            if (initCtt == 1) {
                 if (DetectBit(btInput, VIBRATIONSENSOR)) {
                     if (!m_bVibrationFlag && m_eMachineType == RVC_Stand2S) {
-                        LogEvent(Severity_Middle, LOG_EVT_VIBRATIONSENSOR, "机具震动 1");
+                        LogEvent(Severity_Middle, LOG_EVT_VIBRATIONSENSOR,  CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(17), __LINE__));
                     }
                     m_bVibrationFlag = true;
                 } else
                     m_bVibrationFlag = false;
+
                 break;
             }
 
             if (m_bVibrationRound) {
-                if (DetectBit(btInput, VIBRATIONSENSOR)) {
-                    if (!m_bVibrationFlag) {
-                        if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_VIBRATIONSENSOR, "机具震动 2");
-
-                        m_bVibrationFlag = true;
-                        m_bVibrationRound = false;
-                    }
-                }
-            } else {
-                if (!DetectBit(btInput, VIBRATIONSENSOR)) {
-                    if (m_bVibrationFlag) {
-                        //LogEvent(Severity_Middle,LOG_EVT_VIBRATIONSENSOR,"震动");
-                        m_bVibrationFlag = false;
-                        m_bVibrationRound = true;
-                    }
+                if (DetectBit(btInput, VIBRATIONSENSOR) && !m_bVibrationFlag) {
+                    if (m_eMachineType == RVC_Stand2S)
+                        LogEvent(Severity_Middle, LOG_EVT_VIBRATIONSENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(17), __LINE__));
+                    m_bVibrationFlag = true;
+                    m_bVibrationRound = false;
                 }
+            } else if (!DetectBit(btInput, VIBRATIONSENSOR) && m_bVibrationFlag) {
+                m_bVibrationFlag = false;
+                m_bVibrationRound = true;
             }
         } while (0);
+
         pGci->CttShake = pGci->InitCTT;
     }
+
+    /** 机箱门开关检测*/
     if (pGci->CttSwitch == 1) {
+
+        bSwitchOne = true;
+
         do {
-            bSwitchOne = true;
 
-            if (initCTT == 1) {
+            if (initCtt == 1) {
                 if (DetectBit(btInput, OPENSENSOR)) {
                     if (!m_bOpenFlag) {
                         if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_ON, "机具门打开");
-                    }
-                    m_bOpenFlag = true;
-                } else {
-                    if (m_bOpenFlag) {
-                        if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_OFF, "机具门关闭");
+                            LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(18), __LINE__));
+                        m_bOpenFlag = true;
                     }
+                } else if (m_bOpenFlag) {
+                    if (m_eMachineType == RVC_Stand2S)
+                        LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(18), __LINE__));
                     m_bOpenFlag = false;
                 }
                 break;
             }
-            if (m_bOpenRound) {
-                if (DetectBit(btInput, OPENSENSOR)) {
-                    if (!m_bOpenFlag) {
-                        if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_ON, "机具门打开");
 
-                        m_bOpenFlag = true;
-                        m_bOpenRound = false;
-                    }
-                }
-            } else {
-                if (!DetectBit(btInput, OPENSENSOR)) {
-                    if (m_bOpenFlag) {
-                        if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_OFF, "机具门关闭");
-                        m_bOpenFlag = false;
-                        m_bOpenRound = true;
-                    }
+            if (m_bOpenRound) {
+                if (DetectBit(btInput, OPENSENSOR) && !m_bOpenFlag) {
+                    if (m_eMachineType == RVC_Stand2S)
+                        LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(18), __LINE__));
+                    m_bOpenFlag = true;
+                    m_bOpenRound = false;
                 }
+            } else if (!DetectBit(btInput, OPENSENSOR) && m_bOpenFlag) {
+                if (m_eMachineType == RVC_Stand2S)
+                    LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(18), __LINE__));
+                m_bOpenFlag = false;
+                m_bOpenRound = true;
             }
         } while (0);
+
         pGci->CttSwitch = pGci->InitCTT;
     }
+
+    /**话机检测*/
     if (pGci->CttPhone == 1) {
+
+        bPhoneOne = true;
+
         do {
-            bPhoneOne = true;
 
-            if (initCTT == 1) {
+            if (initCtt == 1) {
                 if (DetectBit(btInput, PICKUPSENSOR)) {
                     if (!m_bPickUpFlag) {
                         if (m_eMachineType == RVC_Stand2S)
                             LogEvent(Severity_Middle, LOG_EVT_PICKUP, "话机提起");
+                        m_bPickUpFlag = true;
                     }
-                    m_bPickUpFlag = true;
-                } else {
-                    if (m_bPickUpFlag) {
-                        if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_ONHOOK, "话机放下");
-                    }
+                    
+                } else if (m_bPickUpFlag) {
+                    if (m_eMachineType == RVC_Stand2S)
+                        LogEvent(Severity_Middle, LOG_EVT_ONHOOK, "话机放下");
                     m_bPickUpFlag = false;
                 }
                 break;
             }
             if (m_bPickUpRound) {
-                if (DetectBit(btInput, PICKUPSENSOR)) {
-                    if (!m_bPickUpFlag) {
-                        if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_PICKUP, "话机提起");
-
-                        m_bPickUpFlag = true;
-                        m_bPickUpRound = false;
-                    }
+                if (DetectBit(btInput, PICKUPSENSOR) && !m_bPickUpFlag) {
+                    if (m_eMachineType == RVC_Stand2S)
+                        LogEvent(Severity_Middle, LOG_EVT_PICKUP, "话机提起");
+                    m_bPickUpFlag = true;
+                    m_bPickUpRound = false;
                 }
-            } else {
-                if (!DetectBit(btInput, PICKUPSENSOR)) {
-                    if (m_bPickUpFlag) {
-                        if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_ONHOOK, "话机放下");
-
-                        m_bPickUpFlag = false;
-                        m_bPickUpRound = true;
-                    }
+            } else if (!DetectBit(btInput, PICKUPSENSOR)) {
+                if (m_bPickUpFlag) {
+                    if (m_eMachineType == RVC_Stand2S)
+                        LogEvent(Severity_Middle, LOG_EVT_ONHOOK, "话机放下");
+                    m_bPickUpFlag = false;
+                    m_bPickUpRound = true;
                 }
             }
         } while (0);
+
         pGci->CttPhone = pGci->InitCTT;
     }
+
+    /*物体靠近感知检测*/
     if (pGci->CttMove == 1) {
+
+        bMoveOne = true;
+
         do {
-            bMoveOne = true;
-            if (initCTT == 1) {
+            if (initCtt == 1) {
                 if (DetectBit(btInput, MOVESENSOR)) {
                     if (m_eMachineType == RVC_Stand2S)
-                        LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, "移动 1");
+                        LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(20), __LINE__));
                 }
                 break;
             }
 
             if (m_bMoveRound) {
                 if (DetectBit(btInput, MOVESENSOR)) {
-                    m_moveHoldTimes++;
                     m_moveDisappearTimes = 0;
-                    if (m_moveHoldTimes < MAX_MOVE_HOLD_TIMES) {
-                        if ((m_moveHoldTimes % LOG_TIME_VALUE) == 0) {
+                    if (m_moveHoldTimes < MAX_MOVE_HOLD_TIMES) { // 100ms * 5000
+                        if ((m_moveHoldTimes % LOG_TIME_VALUE) == 0) {  //100ms * 25 = 2.5s 但因为厂家接口调用,不进来计数,需要800ms+
                             if (m_eMachineType == RVC_Stand2S)
-                                LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, "移动 2");
-                        }
-                    } else {
-                        if ((m_moveHoldTimes % MAX_MOVE_HOLD_TIMES) == 0) {
-                            if (m_eMachineType == RVC_Stand2S)
-                                LogWarn(Severity_Middle, Error_Unexpect, LOG_EVT_MOVEDETECT_ABNORMAL, "移动次数异常");
+                                LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(20), __LINE__));
                         }
+                    } else if ((m_moveHoldTimes % MAX_MOVE_HOLD_TIMES) == 0) { //难道8分钟一直有人就异常?还有一个 Round 标识
+                        if (m_eMachineType == RVC_Stand2S)
+                            LogWarn(Severity_Middle, Error_Unexpect, LOG_EVT_MOVEDETECT_ABNORMAL, "移动次数异常");
                     }
+                    m_moveHoldTimes++;
                     m_bMoveRound = false;
                 }
-            } else {
-                if (!DetectBit(btInput, MOVESENSOR)) {
-                    m_moveHoldTimes = 0;
-                    m_moveDisappearTimes++;
-                    if ((m_moveDisappearTimes % LOG_TIME_VALUE) == 0) {
-                        if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_OFF, "移动消失");
-                    }
-                    m_bMoveRound = true;
+            } else if (!DetectBit(btInput, MOVESENSOR)) {
+                m_moveHoldTimes = 0;
+                if ((m_moveDisappearTimes % LOG_TIME_VALUE) == 0) {
+                    if (m_eMachineType == RVC_Stand2S)
+                        LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(20), __LINE__));
                 }
+                m_moveDisappearTimes++;
+                m_bMoveRound = true;
             }
         } while (0);
+
         pGci->CttMove = pGci->InitCTT;
     }
 
+    /*卡嘴异物检测*/
     if (pGci->CttCard == 1) {
+
+        bCardOne = true;
+
         do {
-            bCardOne = true;
-            //Dbg("oiltest %d",btInput);
-            if (initCTT == 1) {
+            
+            if (initCtt == 1) {
                 if (DetectBit(btInput, CARDGATESENSOR)) {
                     if (!m_bCardGateFlag) {
                         if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_CARDGATESENSOR, "卡嘴 1");
+                            LogEvent(Severity_Middle, LOG_EVT_CARDGATESENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(21), __LINE__));
+                        m_bCardGateFlag = true;
                     }
-                    m_bCardGateFlag = true;
                 } else
                     m_bCardGateFlag = false;
                 break;
             }
 
             if (m_bCardGateRound) {
-                if (DetectBit(btInput, CARDGATESENSOR)) {
-                    if (!m_bCardGateFlag) {
-                        if (m_eMachineType == RVC_Stand2S)
-                            LogEvent(Severity_Middle, LOG_EVT_CARDGATESENSOR, "卡嘴 2");
-
-                        m_bCardGateFlag = true;
-                        m_bCardGateRound = false;
-                    }
-                }
-            } else {
-                if (!DetectBit(btInput, CARDGATESENSOR)) {
-                    if (m_bCardGateFlag) {
-                        m_bCardGateFlag = false;
-                        m_bCardGateRound = true;
-                    }
+                if (DetectBit(btInput, CARDGATESENSOR) && !m_bCardGateFlag) {
+                    if (m_eMachineType == RVC_Stand2S)
+                        LogEvent(Severity_Middle, LOG_EVT_CARDGATESENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(21), __LINE__));
+                    m_bCardGateFlag = true;
+                    m_bCardGateRound = false;
                 }
+            } else if (!DetectBit(btInput, CARDGATESENSOR) && m_bCardGateFlag) {
+                m_bCardGateFlag = false;
+                m_bCardGateRound = true;
             }
         } while (0);
+
         pGci->CttCard = pGci->InitCTT;
     }
 
-    if (pGci->CttShake > 1 && !bShakeOne) {
+    /////////////////////////////////////////////////////////////////////////////////////
 
+    if (pGci->CttShake > 1 && !bShakeOne) {
 
         do {
             if (m_bVibrationRound) {
@@ -1133,6 +1129,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
             }
         } while (0);
     }
+
     if (pGci->CttSwitch > 1 && !bSwitchOne) {
         do {
             if (m_bOpenRound) {
@@ -1152,6 +1149,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
             }
         } while (0);
     }
+
     if (pGci->CttPhone > 1 && !bPhoneOne) {
         do {
             if (m_bPickUpRound) {
@@ -1171,8 +1169,13 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
             }
         } while (0);
     }
+
     if (pGci->CttMove > 1 && !bMoveOne) {
         do {
+
+            Dbg("before ccMove: %d, ccInit: %d, moveRound: %d, %d, disppear: %d, holder: %d",
+                pGci->CttMove, pGci->InitCTT, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
+
             if (m_bMoveRound) {
                 if (DetectBit(btInput, MOVESENSOR))
                     pGci->CttMove--;
@@ -1188,8 +1191,17 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
                     pGci->CttMove = pGci->InitCTT;
                 }
             }
+
+            Dbg("after ccMove: %d, ccInit: %d, moveRound: %d, %d, disppear: %d, holder: %d",
+                pGci->CttMove, pGci->InitCTT, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
+
+
         } while (0);
+    } else {
+        Dbg("===== ccMove: %d, moveOne: %d, moveRound: %d, %d, disppear: %d, holder: %d",
+            pGci->CttMove, bMoveOne, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
     }
+
     if (pGci->CttCard > 1 && !bCardOne) {
         do {
             if (m_bCardGateRound) {
@@ -1232,62 +1244,65 @@ void CGpioEntity::OnNegativeLevelTimerOut(void* pData)
         }
     }
 }
-bool CGpioEntity::GetReceiving(int deviceSeq, ReceivingInfo ri, ULONG iIndex, SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
+bool CGpioEntity::GetReceiving(int deviceSeq, ReceivingInfo ri, ULONG iIndex, 
+                               SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
 {
+
     Dbg("inputmode[%d],port[%d],ctt[%d]", ri.InputMode, ri.Port, ri.ContinuousTriggerTime);
-    switch (ri.InputMode) {
-    case IM_POSITIVE_PULSE_UP:
+    switch (ri.InputMode) 
     {
-        GetContextInfo* pGci = new GetContextInfo();
-        pGci->timerID = ctx->Req.devseq;
-        pGci->ctx = ctx;
-        pGci->index = iIndex;
-        pGci->Port = ri.Port;
-        pGci->CttCard = ri.ContinuousTriggerTime;
-        pGci->CttMove = ri.ContinuousTriggerTime;
-        pGci->CttPhone = ri.ContinuousTriggerTime;
-        pGci->CttShake = ri.ContinuousTriggerTime;
-        pGci->CttSwitch = ri.ContinuousTriggerTime;
-        pGci->InitCTT = ri.ContinuousTriggerTime;
-        ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositivePulseUpTimerout, pGci);
-        GetFunction()->SetTimer(pGci->timerID, pListener, 1);
-        break;
-    }
+        case IM_POSITIVE_PULSE_UP:
+        {
+            GetContextInfo* pGci = new GetContextInfo();
+            pGci->timerID = ctx->Req.devseq;
+            pGci->ctx = ctx;
+            pGci->index = iIndex;
+            pGci->Port = ri.Port;
+            pGci->CttCard = ri.ContinuousTriggerTime;
+            pGci->CttMove = ri.ContinuousTriggerTime;
+            pGci->CttPhone = ri.ContinuousTriggerTime;
+            pGci->CttShake = ri.ContinuousTriggerTime;
+            pGci->CttSwitch = ri.ContinuousTriggerTime;
+            pGci->InitCTT = ri.ContinuousTriggerTime;
+            ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositivePulseUpTimerout, pGci);
+            GetFunction()->SetTimer(pGci->timerID, pListener, 1);
+            break;
+        }
 
-    case IM_POSITIVE_LEVEL:
-    {
-        GetContextInfo* pGci = new GetContextInfo();
-        pGci->timerID = deviceSeq;
-        pGci->ctx = ctx;
-        pGci->index = iIndex;
-        pGci->Port = ri.Port;
-        //pGci->ContinuousTriggerTime = ri.ContinuousTriggerTime;//oiltest 20130709
-        pGci->CttCard = ri.ContinuousTriggerTime;
-        pGci->CttMove = ri.ContinuousTriggerTime;
-        pGci->CttPhone = ri.ContinuousTriggerTime;
-        pGci->CttShake = ri.ContinuousTriggerTime;
-        pGci->CttSwitch = ri.ContinuousTriggerTime;
-        pGci->InitCTT = ri.ContinuousTriggerTime;
-        ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositiveLevelTimerOut, pGci);
-        GetFunction()->SetTimer(pGci->timerID, pListener, 100);
-        break;
-    }
-    case IM_NEGATIVE_LEVEL:
-    {
-        GetContextInfo* pGci = new GetContextInfo();
-        pGci->timerID = deviceSeq;
-        pGci->ctx = ctx;
-        pGci->index = iIndex;
-        pGci->Port = ri.Port;
-        //pGci->ContinuousTriggerTime = ri.ContinuousTriggerTime;//oiltest 20130709
-
-        pGci->InitCTT = ri.ContinuousTriggerTime;
-        ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnNegativeLevelTimerOut, pGci);
-        GetFunction()->SetTimer(pGci->timerID, pListener, 1);
-        break;
-    }
-    default:
-        break;
+        case IM_POSITIVE_LEVEL:
+        {
+            GetContextInfo* pGci = new GetContextInfo();
+            pGci->timerID = deviceSeq;
+            pGci->ctx = ctx;
+            pGci->index = iIndex;
+            pGci->Port = ri.Port;
+            //pGci->ContinuousTriggerTime = ri.ContinuousTriggerTime;//oiltest 20130709
+            pGci->CttCard = ri.ContinuousTriggerTime;
+            pGci->CttMove = ri.ContinuousTriggerTime;
+            pGci->CttPhone = ri.ContinuousTriggerTime;
+            pGci->CttShake = ri.ContinuousTriggerTime;
+            pGci->CttSwitch = ri.ContinuousTriggerTime;
+            pGci->InitCTT = ri.ContinuousTriggerTime;
+            ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositiveLevelTimerOut, pGci);
+            GetFunction()->SetTimer(pGci->timerID, pListener, 100);
+            break;
+        }
+        case IM_NEGATIVE_LEVEL:
+        {
+            GetContextInfo* pGci = new GetContextInfo();
+            pGci->timerID = deviceSeq;
+            pGci->ctx = ctx;
+            pGci->index = iIndex;
+            pGci->Port = ri.Port;
+            //pGci->ContinuousTriggerTime = ri.ContinuousTriggerTime;//oiltest 20130709
+
+            pGci->InitCTT = ri.ContinuousTriggerTime;
+            ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnNegativeLevelTimerOut, pGci);
+            GetFunction()->SetTimer(pGci->timerID, pListener, 1);
+            break;
+        }
+        default:
+            break;
     }
     return true;
 }
@@ -1298,7 +1313,7 @@ void CGpioEntity::GetOutDrivingModInfo(CSimpleStringA modName, OutDrivingInfo& o
     CSmartPointer<IConfigInfo> spConfig;
     Error = spEntityFunction->OpenConfig(Config_Software, spConfig);
     if (Error != Error_Succeed) {
-        LOG_TRACE("open cfg file failed!");
+        Dbg("open cfg file failed!");
         return;
     }
     spConfig->ReadConfigValueInt(modName, "OutputMode", odi.OutputMode);
@@ -1309,6 +1324,7 @@ void CGpioEntity::GetOutDrivingModInfo(CSimpleStringA modName, OutDrivingInfo& o
     LOG_TRACE("outputmode.stopmode:[%d].[%d]", odi.OutputMode, odi.StopMode);
 }
 
+/*从配置文件中获取配置*/
 void CGpioEntity::GetReceivingModInfo(CSimpleStringA modName, ReceivingInfo& ri)
 {
     ErrorCodeEnum Error;

+ 20 - 11
Module/mod_gpio/mod_gpio.h

@@ -34,11 +34,11 @@ enum InputMode{
 	IM_NEGATIVE_LEVEL
 };
 enum PinPort{
-	VIBRATIONSENSOR,
-	OPENSENSOR,
-	PICKUPSENSOR,
-	MOVESENSOR,
-	CARDGATESENSOR,
+	VIBRATIONSENSOR, /**震动探测器*/
+	OPENSENSOR, /*开机箱门感应器*/
+	PICKUPSENSOR, /*话机感应器*/
+	MOVESENSOR, /**人体探测感应器*/
+	CARDGATESENSOR, /**发卡器卡嘴感应器*/
 };
 struct OutDrivingInfo 
 {
@@ -123,7 +123,9 @@ struct GetContextInfo
 	ULONG timerID;
 	ULONG index;
 	int CttPhone,CttMove,CttShake,CttSwitch,CttCard;
-	int InitCTT;//ContinuousTriggerTime get from configure file
+
+	//ContinuousTriggerTime get from configure file
+	int InitCTT;
 };
 class CGpioEntity : public CDevAdptEntityBase, public ILogListener
 {
@@ -172,10 +174,11 @@ public:
 		if (err == Error_Succeed)
 		{
 			LOG_TRACE("Gpio open succeeded.");
+
 			GetStatus(PHONEPICKUP,NULL);
+
 			Dbg("subscribelog...");
 			GetFunction()->SubscribeLog(m_uuidHealth,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"HealthManager");
-			GetFunction()->SubscribeLog(m_uuidPtr,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"Printer");
 			GetFunction()->SubscribeLog(m_uuidIDC,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"IDCertificate");
 			GetFunction()->SubscribeLog(m_uuidFP, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "FingerPrint");
 			GetFunction()->SubscribeLog(m_uuidKB,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"PinPad");
@@ -184,11 +187,16 @@ public:
 			GetFunction()->SubscribeLog(m_uuidCC,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"ContactlessCard");
 			GetFunction()->SubscribeLog(m_uuidDD,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"DeviceControl");
 			GetFunction()->SubscribeLog(m_uuidCS, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "CardSwiper");
-			GetFunction()->SubscribeLog(m_uuidIE, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "IEBrowser");
 			GetFunction()->SubscribeLog(m_uuidHSPscanner, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "HSPScanner");
-			GetFunction()->SubscribeLog(m_uuidPrinter, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "ThermalPrint");
-			GetFunction()->SubscribeLog(m_uuidPrintSeal, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "PrintSeal");
+            GetFunction()->SubscribeLog(m_uuidIE, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "IEBrowser");
+
+#if defined(RVC_OS_WIN)
+			GetFunction()->SubscribeLog(m_uuidPtr, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "Printer");
+            GetFunction()->SubscribeLog(m_uuidPrinter, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "ThermalPrint");
+            GetFunction()->SubscribeLog(m_uuidPrintSeal, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "PrintSeal");
+#endif //RVC_OS_WIN
 			Dbg("subscribelog ok...");
+
 			pTransactionContext->SendAnswer(Error_Succeed);
 		}
 		else
@@ -229,7 +237,8 @@ public:
 
 	bool SetOutDriving(GpioService_Set_Info req,OutDrivingInfo od, ULONG iIndex,ULONG devSeq);
 
-	bool GetReceiving(int deviceSeq,ReceivingInfo ri, ULONG iIndex, SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx);
+	bool GetReceiving(int deviceSeq,ReceivingInfo ri, ULONG iIndex, 
+					  SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx);
 
 	DevOutputInfo GetCurrDevStatus()const {return currDevStatus;}