Пример #1
0
 def openDoorLongGiveAlarm(self):
     if self.isgivealarm == 0:
         n = self.givealarmtime
         self.isgivealarm = 1
         startalarmtime = time.time()
         head = tp.MsgHead()
         head.iMsgType = tp.MsgTypeEnum.ALARM_REPORT
         head.iSubMsgType = tp.MsgSubTypeEnum.UNUSED
         head.iPayloadLen = ct.sizeof(tp.MsgHead) + ct.sizeof(
             tp.AlarmStruct)
         head.iFeedBack = 1
         alarm = tp.AlarmStruct()
         alarm.cType = 1
         alarm.cSubType = 3
         alarm.cLevel = 3
         alarm.uiTime = int(time.time())
         self.sockSend(head.pack() + alarm.pack())
         while self.givealarmtime > 0:
             os.system('echo 1 > /sys/class/leds/beep/brightness')
             time.sleep(0.1)
             os.system('echo 0 > /sys/class/leds/beep/brightness')
             time.sleep(0.1)
             if time.time() - startalarmtime > self.givealarmtime:
                 self.givealarmtime = 0
         self.givealarmtime = n
         self.isgivealarm = 0
Пример #2
0
 def giveAlarm(self, type, subtype, level, uitime=int(time.time())):
     head = tp.MsgHead()
     head.iMsgType = tp.MsgTypeEnum.ALARM_REPORT
     head.iSubMsgType = tp.MsgSubTypeEnum.UNUSED
     head.iPayloadLen = ct.sizeof(tp.MsgHead) + ct.sizeof(tp.AlarmStruct)
     head.iFeedBack = 1
     alarm = tp.AlarmStruct()
     alarm.cType = type
     alarm.cSubType = subtype
     alarm.cLevel = level
     alarm.uiTime = uitime
     self.sockSend(head.pack() + alarm.pack())