예제 #1
0
        public Gate ConstructGateModelFromGateSetupItems(ObservableCollection<GateSetupItem> gateSetupItems)
        {
            var gate = new Gate("Default_Gate");

            foreach (var gateSetupItem in gateSetupItems)
            {
                if (gateSetupItem is GateCameraSetupItem)
                {
                    gate.Cameras.Add(((GateCameraSetupItem)gateSetupItem).CameraModel);
                }
                else if (gateSetupItem is GateComPortSetupItem)
                {
                    gate.ComPortName = gateSetupItem.Address;
                }
                else if (gateSetupItem is GateNameSetupItem)
                {
                    gate.Name = gateSetupItem.Address;
                }
                else if (gateSetupItem is GateVehicleNumberSaveLoc)
                {
                    gate.VehicleNumberSaveFolder = gateSetupItem.Address;
                }
            }

            return gate;
        }
예제 #2
0
 public GateProvider(Gate gate)
 {
     this.Gate = gate;
     
     this._comPortProvider = GetComPortProvider();
     this._cameraProviders = this.Gate.Cameras.Select(x => new HikVisionCameraProvider(x));
     this._licenceNumberProvider = new LicenceNumberProvider(this.Gate.VehicleNumberSaveFolder);
 }
        private Gate ConstructGate()
        {
            const int expectedCamId = 1;

            var gateModel = new Gate(GateId) { ComPortName = ExpectedCom, Name = ExpectedGateName, VehicleNumberSaveFolder = ExpectedVehicleNumberSavePath };
            gateModel.Cameras.Add(new CameraModel() { ID = expectedCamId, IpAddress = ExpectedIpAddress, SavePath = ExpectedSavePath });

            return gateModel;
        }
 // Get CameraModel with specified name
 public CameraModel GetCamera(string name, Gate parent)
 {
     // find the CameraModel
     foreach (CameraModel camera in InnerList)
     {
         if ((camera.Name == name) )
             return camera;
     }
     return null;
 }
예제 #5
0
        public void TestValidateGateInformationInvalidSavePath()
        {
            var gateModel = new Gate("one");
            gateModel.Cameras.Add(new CameraModel(){SavePath = Path.GetTempFileName()});

            var dataAccesslayer = new DataAccessLayer(new MockDatabaseProvider());
            var hasError = dataAccesslayer.ValidateGateInformation(gateModel);

            Assert.IsTrue(hasError.Length > 0);
        }
예제 #6
0
        public void TestValidateGateInformationNoErrors()
        {
            var gateModel = new Gate("one");
            gateModel.Cameras.Add(new CameraModel() {SavePath = Path.GetTempPath()});

            var dataAccesslayer = new DataAccessLayer(new MockDatabaseProvider());
            var errors = dataAccesslayer.ValidateGateInformation(gateModel);

            Assert.IsFalse(errors.Length > 0);
        }
예제 #7
0
        private Gate ConstructDummyGateSetupItems()
        {
            var gate = new Gate("Main Entry Gate");
            gate.Cameras.Add(new CameraModel(){Name = "Chasis One", ImageType = ImageType.ChaisisImage });
            //gate.Cameras.Add(new CameraModel() { Name = "Chasis Two", ImageType = ImageType.ChaisisImage });
            gate.Cameras.Add(new CameraModel() { Name = "Top View", ImageType = ImageType.VehicleOverallImage });
            gate.Cameras.Add(new CameraModel() { Name = "Driver Image", ImageType = ImageType.DriverImage });
            gate.Cameras.Add(new CameraModel() { Name = "Licence Plate", ImageType = ImageType.NumberPlateImage });
            gate.ComPortName = "COM2";
            gate.VehicleNumberSaveFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            return gate;
        }
예제 #8
0
        public StringBuilder ValidateGateInformation(Gate gate)
        {
            var errorMsg = new StringBuilder();

            foreach (var camera in gate.Cameras)
            {
                if (string.IsNullOrEmpty(camera.SavePath))
                    errorMsg.AppendLine(string.Format("For Camera {0}, Save Path {1} is Empty", camera.Name, camera.SavePath));
                else if(!Directory.Exists(camera.SavePath))
                    errorMsg.AppendLine(string.Format("{0} : Save Path {1} Doesnt exists", camera.Name, camera.SavePath));
            }
            return errorMsg;
        }
예제 #9
0
        private static Gate ConstructGate()
        {
            UserManager.Instance.SetLoggedInUser("super");

            var gate = new Gate("Main Entry Gate");

            gate.Cameras.Add(new CameraModel() { Name = "Chasis One", ImageType = ImageType.ChaisisImage });
            gate.Cameras.Add(new CameraModel() { Name = "Chasis Two", ImageType = ImageType.ChaisisImage });
            gate.Cameras.Add(new CameraModel() { Name = "Top View", ImageType = ImageType.VehicleOverallImage });
            gate.Cameras.Add(new CameraModel() { Name = "Driver Image", ImageType = ImageType.DriverImage });
            gate.Cameras.Add(new CameraModel() { Name = "Licence Plate", ImageType = ImageType.NumberPlateImage });
            gate.ComPortName = "COM2";

            return gate;
        }
예제 #10
0
        public void TestGateProviderConstruct()
        {
            const string expecetedCom = "COM1";
            const int expectedCamId = 1;
            var gateModel = new Gate("one") { ComPortName = expecetedCom };
            gateModel.Cameras.Add(new CameraModel(){ID = expectedCamId});

            UserManager.Instance.SetLoggedInUser("super");

            var gateProvider = new GateProvider(gateModel);

            Assert.IsTrue(gateProvider.ComPortProvider != null);
            
            // TODO : Mock COM Provider
            //Assert.AreEqual(gateProvider.ComPortProvider.SerialPort.PortName, expecetedCom);
            
            Assert.IsTrue(gateProvider.CameraProviders.Count() == 1);
            Assert.AreEqual(gateProvider.CameraProviders.First().CameraModel.ID, expectedCamId);
        }
예제 #11
0
 public bool AddGateInfo(Gate gate)
 {
     throw new NotImplementedException();
 }
예제 #12
0
 public bool SaveGateInfo(Gate gate)
 {
     return SerializeUtility.Save(gate, GateInfoFileName);
 }
예제 #13
0
 public bool AddGateInfo(Gate gate)
 {
     return this._databaseProvider.AddGateInfo(gate);
 }
예제 #14
0
 public bool SaveGateInfo(Gate gate)
 {
     return this._dataAccessLayer.SaveGateInfo(gate);
 }
예제 #15
0
        public ObservableCollection<GateSetupItem> ConstructSavedGateSetupItems(Gate gateInfo)
        {
            Logger.Info("Found Saved Gate inforation: " + GateInfoFileName);

            try
            {
                var gateSetupItems = new ObservableCollection<GateSetupItem>
                {
                    new GateNameSetupItem(gateInfo.Name),
                    new GateComPortSetupItem(gateInfo.ComPortName),
                    new GateVehicleNumberSaveLoc(gateInfo.VehicleNumberSaveFolder)
                };

                foreach (var camera in gateInfo.Cameras)
                {
                    gateSetupItems.Add(new GateCameraSetupItem(camera));
                }

                return gateSetupItems;
            }
            catch (Exception exception)
            {
                Logger.Fatal("Reading saved gate information failed", exception);
                // Fall back
                return ConstructSavedGateSetupItems(this._dataAccessLayer.ReadGateInfo());
            }
        }
예제 #16
0
 public bool AddGateInfo(Gate gate)
 {
     return true;
 }