コード例 #1
0
        public static ProtocolDriver CreateInstance(Device device)
        {
            ProtocolDriver driver = null;

            switch (device.key)
            {
            case DEVICE_KEY.FBG:
                driver = new ProtocolFbg(device);
                break;

            case DEVICE_KEY.DVS:
            case DEVICE_KEY.DTS:
                driver = new ProtocolDVS(device);
                break;

            case DEVICE_KEY.INANTER:
                driver = new ProtocolInanter(device);
                break;

            case DEVICE_KEY.ES:
                driver = new ProtocolEs(device);
                break;

            case DEVICE_KEY.HK:
                driver = new ProtocolHK(device);
                break;

            case DEVICE_KEY.MOXA_2K:
                driver = new ProtocolMoxa(device);
                break;

            case DEVICE_KEY.JDEX:
                driver = new ProtocolJDExpand(device);
                break;

            case DEVICE_KEY.VIDEO:
                driver = new ProtocolVideo(device);
                break;

            case DEVICE_KEY.HKAI:
                driver = new ProtocolHKAI(device);
                break;

            case DEVICE_KEY.DHAlarm:
                driver = new ProtocolDHAlarm(device);
                break;

            default:
                break;
            }
            return(driver);
        }
コード例 #2
0
ファイル: ProtocolHK.cs プロジェクト: cyberslacking/Fork
        public static void cbHK_ReadReport(string ID, string ActId, string SubId, string ZoneId, string UserId, string CID, int Port, string Ip, string Value)
        {
            ProtocolHK instrument = listInstrument.Find(x => x.device.ip == Ip);

            if (instrument == null)
            {
                return;
            }

            switch (CID)
            {
            case "E998":
                instrument.OnConnectEH(instrument.device, 0);
                break;

            case "E997":
                instrument.OnConnectEH(instrument.device, 1);
                break;

            case "E570":
            case "E806":
            {
                if (ZoneId == "")
                {
                    return;
                }
                Sensor sensor = instrument.FindSensorBySID(1, int.Parse(ZoneId));
                if (sensor != null)
                {
                    ERROR_INFO old = instrument.listError.Find(x => x.id == sensor.id);
                    if (old == null)
                    {
                        ERROR_INFO info = new ERROR_INFO();
                        info.id        = sensor.id;
                        info.name      = sensor.name;
                        info.status    = STATUS_TYPE.ERROR;
                        info.starttime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        info.type      = OBJECT_TYPE.sensor;
                        instrument.OnObjectErrorEH(info);
                        instrument.listError.Add(info);
                    }
                }
            }
            break;

            case "R570":
            case "R806":
            {
                if (ZoneId == "")
                {
                    return;
                }
                Sensor sensor = instrument.FindSensorBySID(1, int.Parse(ZoneId));
                if (sensor != null)
                {
                    ERROR_INFO old = instrument.listError.Find(x => x.id == sensor.id);
                    if (old != null)
                    {
                        ERROR_INFO info = new ERROR_INFO();
                        info.id        = sensor.id;
                        info.name      = sensor.name;
                        info.status    = STATUS_TYPE.NORMAL;
                        info.starttime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        info.type      = OBJECT_TYPE.sensor;
                        instrument.OnObjectErrorEH(info);
                        instrument.listError.Remove(old);
                    }
                }
            }
            break;

            case "E134":
            case "E103":
            {
                if (ZoneId == "")
                {
                    return;
                }
                Sensor sensor = instrument.FindSensorBySID(1, int.Parse(ZoneId));
                if (sensor != null)
                {
                    STATUS_INFO old = instrument.listAlarm.Find(x => x.id == sensor.id);
                    if (old == null)
                    {
                        STATUS_INFO info = new STATUS_INFO();
                        info.no         = (int)sensor.id;
                        info.id         = sensor.id;
                        info.name       = sensor.name;
                        info.status     = STATUS_TYPE.ALARM;
                        info.time       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        info.type       = MONITOR_TYPE.io;
                        info.confidence = 100;
                        instrument.OnObjectStatusEH(info);
                        instrument.listAlarm.Add(info);
                    }
                }
            }
            break;

            case "R134":
            case "R103":
            {
                if (ZoneId == "")
                {
                    return;
                }
                Sensor sensor = instrument.FindSensorBySID(1, int.Parse(ZoneId));
                if (sensor != null)
                {
                    STATUS_INFO old = instrument.listAlarm.Find(x => x.id == sensor.id);
                    if (old != null)
                    {
                        instrument.listAlarm.Remove(old);
                    }
                }
            }
            break;
            }
        }