void FireAllEvents(DoorInfo door, DoorState state)
        {
            var capabilities = door.Capabilities;

            EventServer.DoorModeEvent(this, "Initialized", door.token, state.DoorMode);

            if (capabilities.DoorMonitorSpecified && capabilities.DoorMonitor)
            {
                EventServer.DoorPhysicalStateEvent(this, "Initialized", door.token, state.DoorPhysicalState);
            }

            if (capabilities.LockMonitorSpecified && capabilities.LockMonitor)
            {
                EventServer.LockPhysicalStateEvent(this, "Initialized", door.token, state.LockPhysicalState);
            }

            if (capabilities.DoubleLockMonitorSpecified && capabilities.DoubleLockMonitor)
            {
                EventServer.DoubleLockPhysicalStateEvent(this, "Initialized", door.token, state.DoubleLockPhysicalState);
            }

            if (capabilities.AlarmSpecified && capabilities.Alarm)
            {
                EventServer.DoorAlarmMonitorEvent(this, "Initialized", door.token, state.Alarm);
            }

            if (capabilities.TamperSpecified && capabilities.Tamper)
            {
                if (state.Tamper != null)
                {
                    EventServer.DoorTamperMonitorEvent(this, "Initialized", door.token, state.Tamper.State);
                }
            }

            if (capabilities.FaultSpecified && capabilities.Fault)
            {
                if (state.Fault != null)
                {
                    EventServer.DoorFaultEvent(this, "Initialized", door.token, state.Fault.State);
                }
            }

            //if (capabilities.FaultSpecified && capabilities.Fault)
            //    EventServer.DoorFaultMonitorEvent(this, "Initialized", door.token, state.Fault);
        }
예제 #2
0
        public void SignalReceived(string deviceToken, string deviceType, string sensor, string value)
        {
            ConfStorageLoad();

            LoggingService.LogMessage(string.Format("Signal received: token={0}, deviceType={1} sensor={2}, value={3}", deviceToken, deviceType, sensor, value), ExternalLogging.MessageType.Details);

            if (deviceType == "Door")
            {
                DoorState doorState = null;
                if (ConfStorage.DoorStateList.ContainsKey(deviceToken))
                {
                    doorState = ConfStorage.DoorStateList[deviceToken];
                }

                switch (sensor)
                {
                case "Alarm":
                {
                    DoorAlarmState state = (DoorAlarmState)Enum.Parse(typeof(DoorAlarmState), value);
                    if (doorState != null)
                    {
                        doorState.Alarm = state;
                        EventServer.DoorAlarmMonitorEvent(null, "Changed", deviceToken, state);
                    }
                }
                break;

                case "LockPhysicalState":
                {
                    LockPhysicalState state =
                        (LockPhysicalState)Enum.Parse(typeof(LockPhysicalState), value);
                    if (doorState != null)
                    {
                        doorState.LockPhysicalState = state;
                        EventServer.LockPhysicalStateEvent(null, "Changed", deviceToken, state);
                    }
                }
                break;

                case "DoubleLockPhysicalState":
                {
                    LockPhysicalState state =
                        (LockPhysicalState)Enum.Parse(typeof(LockPhysicalState), value);

                    if (doorState != null)
                    {
                        doorState.DoubleLockPhysicalState = state;
                        EventServer.DoubleLockPhysicalStateEvent(null, "Changed", deviceToken, state);
                    }
                }
                break;

                case "DoorPhysicalState":
                {
                    DoorPhysicalState state =
                        (DoorPhysicalState)Enum.Parse(typeof(DoorPhysicalState), value);

                    if (doorState != null)
                    {
                        doorState.DoorPhysicalState = state;
                        EventServer.DoorPhysicalStateEvent(null, "Changed", deviceToken, state);
                    }
                }
                break;

                case "Tamper":
                {
                    DoorTamperState state =
                        (DoorTamperState)Enum.Parse(typeof(DoorTamperState), value);

                    if ((doorState != null) && (doorState.Tamper != null))
                    {
                        doorState.Tamper.State = state;
                        EventServer.DoorTamperMonitorEvent(null, "Changed", deviceToken, state);
                    }
                }
                break;

                case "Fault":
                {
                    DoorFaultState state =
                        (DoorFaultState)Enum.Parse(typeof(DoorFaultState), value);

                    if ((doorState != null) && (doorState.Fault != null))
                    {
                        doorState.Fault.State = state;
                        EventServer.DoorFaultEvent(null, "Changed", deviceToken, state);
                    }
                }
                break;
                }

                StateReporter.ReportStateUpdate(deviceToken, doorState);
            }

            if (deviceType == "Credential")
            {
                CredentialState credentialState = null;
                if (ConfStorage.CredentialStateList.ContainsKey(deviceToken))
                {
                    credentialState = ConfStorage.CredentialStateList[deviceToken];
                }

                switch (sensor)
                {
                case "AntipassbackViolated":
                {
                    bool state = (value == "True");
                    if (credentialState != null)
                    {
                        credentialState.AntipassbackState.AntipassbackViolated = state;
                        //TODO: event
                    }
                }
                break;
                }
            }
        }