Beispiel #1
0
        public static bool Init(string iamgePath)
        {
            bool rel = false;

            ImageSavePath = iamgePath;
            if (!Directory.Exists(ImageSavePath))
            {
                Directory.CreateDirectory(ImageSavePath);
            }
            int[] distinctProtocolIds = Cache.PathIdEquips.Select(it => it.ProtocolId).Distinct().ToArray();

            foreach (int pid in distinctProtocolIds)
            {
                List <T_PathIdentifyEquip> currentList = Cache.PathIdEquips.Where(it => it.ProtocolId == pid).ToList();

                PathIdentifyDriverInterface driver = null;

                switch (pid)
                {
                case 1:
                {
                    driver = new HanvonDriver();
                } break;

                case 2:
                {
                    driver = new SignalwayDriver();
                } break;

                case 3:
                {
                    driver = new HitDriver();
                } break;

                default:
                {
                    throw new Exception("未定义的驱动类型,ProtocolId=" + pid.ToString());
                }
                }
                if (driver == null)
                {
                    throw new Exception("没有驱动程序被初始化");
                }
                else
                {
                    driver.DeviceStatusNotifyHandler = OnDeviceStatusChanged;
                    driver.VehicleInfoReceiveHandler = OnVehicleInfoNotify;
                    rel = driver.InitDriver(currentList);
                    DriverDict.Add(pid, driver);
                }
            }

            return(rel);
        }
        public static bool Init(string iamgePath)
        {
            bool rel = false;

            ImageSavePath = iamgePath;
            if (!Directory.Exists(ImageSavePath))
            {
                Directory.CreateDirectory(ImageSavePath);
            }
            int[] distinctProtocolIds = Cache.PathIdEquips.Select(it => it.ProtocolId).Distinct().ToArray();

            foreach (int pid in distinctProtocolIds)
            {
                List<T_PathIdentifyEquip> currentList = Cache.PathIdEquips.Where(it => it.ProtocolId == pid).ToList();

                PathIdentifyDriverInterface driver = null;

                switch (pid)
                {
                    case 1:
                        {
                            driver = new HanvonDriver();
                        } break;
                    case 2:
                        {
                            driver = new SignalwayDriver();
                        } break;
                    case 3:
                        {
                            driver = new HitDriver();
                        } break;
                    default:
                        {
                            throw new Exception("未定义的驱动类型,ProtocolId=" + pid.ToString());
                        }
                }
                if (driver == null)
                {
                    throw new Exception("没有驱动程序被初始化");
                }
                else
                {
                    driver.DeviceStatusNotifyHandler = OnDeviceStatusChanged;
                    driver.VehicleInfoReceiveHandler = OnVehicleInfoNotify;
                    rel = driver.InitDriver(currentList);
                    DriverDict.Add(pid, driver);
                }
            }

            return rel;
        }