public bool CheckEquality(IDeviceConfiguration deviceConfigurationToCheck)
        {
            if (deviceConfigurationToCheck.RootConfigurationItemList.Count == RootConfigurationItemList.Count)
            {
                foreach (IConfigurationItem configurationItem in deviceConfigurationToCheck.RootConfigurationItemList)
                {
                    if (configurationItem.Name ==
                        RootConfigurationItemList[
                            deviceConfigurationToCheck.RootConfigurationItemList.IndexOf(configurationItem)].Name)
                    {
                        if (!CheckItemRecursive(configurationItem,
                                                RootConfigurationItemList[
                                                    deviceConfigurationToCheck.RootConfigurationItemList.IndexOf(configurationItem)]))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        public void SaveConfiguration(IDeviceConfiguration deviceConfiguration)
        {
            var sysConfFileName = Path.Combine(_configurationDestinationDirectoryPath, "SYSCONF.BIN");

            if (File.Exists(sysConfFileName))
            {
                throw new Exception("SYSCONF.BIN file allready exist in destination directory");
            }

            var rpdConfFileName = Path.Combine(_configurationDestinationDirectoryPath, "RPDCONF.BIN");

            if (File.Exists(rpdConfFileName))
            {
                throw new Exception("RPDCONF.BIN file allready exist in destination directory");
            }

            /*using (var stream = File.Create(sysConfFileName)) {
             *      var fileMask = new byte[106496]; // 104kB for SYSCONF.BIN file
             *      stream.Write(fileMask, 0, fileMask.Length);
             *      stream.Seek(0, SeekOrigin.Begin);
             *      stream.Close();
             * }*/

            ISystemConfiguration      sysconfig      = new SystemConfigurationBuilderFromHighLevelDeviceConfiguration(deviceConfiguration, 0).BuildConfiguration();
            ISystemConfigurationSaver sysconfigSaver = new SystemConfigurationSaverBinary(sysConfFileName, true);

            sysconfigSaver.SaveConfiguration(sysconfig);

            ICustomConfiguration      cusconfig      = new CustomConfigurationBuilderFromHighDeviceConfig(deviceConfiguration).BuildConfiguration();
            ICustomConfigurationSaver cusconfigSaver = new CustomConfigurationSaverToRpdConfFile(rpdConfFileName);

            cusconfigSaver.SaveConfiguration(cusconfig);
        }
Example #3
0
        public ConnectionTests()
        {
            _typesContainer =
                new TypesContainer(Program.GetApp().Container.Resolve(typeof(IUnityContainer)) as IUnityContainer);
            _device        = Program.GetDevice();
            _configuration = _device.DeviceFragments.First(fragment => fragment.StrongName == "Configuration") as
                             IDeviceConfiguration;

            _shell = _typesContainer.Resolve <ShellViewModel>();
            _deviceViewModelFactory = _typesContainer.Resolve <IDeviceViewModelFactory>();
            var deviceMemory = new DeviceMemory();

            _typesContainer.Resolve <IDevicesContainerService>()
            .AddConnectableItem(_device);
            _device.DeviceMemory            = deviceMemory;
            _deviceViewModel                = _shell.ProjectBrowserViewModel.DeviceViewModels[0];
            _configurationFragmentViewModel = null;
            _configurationFragmentViewModel = _shell.ProjectBrowserViewModel.DeviceViewModels[0].FragmentViewModels
                                              .First(model => model.NameForUiKey == "Configuration") as
                                              RuntimeConfigurationViewModel;
            _measuringMonitorViewModel = _shell.ProjectBrowserViewModel.DeviceViewModels[0].FragmentViewModels
                                         .First(model => model.NameForUiKey == "MeasuringMonitor") as
                                         MeasuringMonitorViewModel;

            _readCommand = _configurationFragmentViewModel.FragmentOptionsViewModel.FragmentOptionGroupViewModels
                           .First(model => model.NameKey == "Device").FragmentOptionCommandViewModels
                           .First(model => model.TitleKey == ApplicationGlobalNames.UiCommandStrings.READ_STRING_KEY)
                           .OptionCommand as RelayCommand;
        }
Example #4
0
 public MemoryWriterVisitor(DeviceContext deviceContext, List <ushort> writtenAddresses,
                            IDeviceConfiguration configuration, int offset)
 {
     _configuration    = configuration;
     _offset           = offset;
     _deviceContext    = deviceContext;
     _writtenAddresses = writtenAddresses;
 }
 public AzureImagePersister(IConfiguration configuration, IDeviceConfiguration deviceConfiguration)
 {
     _configuration       = configuration;
     _deviceConfiguration = deviceConfiguration;
     _deviceClient        = DeviceClient.Create(configuration.IotHubUrl,
                                                new DeviceAuthenticationWithRegistrySymmetricKey(deviceConfiguration.DeviceIdString,
                                                                                                 deviceConfiguration.DeviceKey));
 }
Example #6
0
 public MemoryReaderVisitor(IDeviceConfiguration configuration, DeviceContext deviceContext, int offset,
                            bool triggerSubscriptions = true)
 {
     _configuration        = configuration;
     _deviceContext        = deviceContext;
     _offset               = offset;
     _triggerSubscriptions = triggerSubscriptions;
 }
Example #7
0
 public Worker(ILogger <Worker> logger,
               IDeviceConfiguration deviceConfiguration,
               IRequest request)
 {
     _logger = logger;
     _deviceConfiguration = deviceConfiguration;
     _request             = request;
 }
Example #8
0
 public ConfigurationMemoryAccessor(IDeviceConfiguration configuration, DeviceContext deviceContext,
                                    MemoryAccessEnum memoryAccessEnum, bool triggerSubscriptions)
 {
     _configuration        = configuration;
     _deviceContext        = deviceContext;
     _memoryAccessEnum     = memoryAccessEnum;
     _triggerSubscriptions = triggerSubscriptions;
 }
 public GetPicturesForm(IPictureDialog pictureDialog) : this()
 {
     hwSearcher         = new DeviceSearchFactory(pictureDialog.GetDeviceType());
     devicesFactory     = new DeviceWorkFactory(pictureDialog.GetDeviceConfiguration());
     config             = pictureDialog.GetDeviceConfiguration();
     this.Text          = pictureDialog.GetHeaderText();
     this.GetImage.Text = pictureDialog.GetButtonText(RetryCounter);
     this.pictureDialog = pictureDialog;
 }
Example #10
0
        private void fillRpdMeters(IDeviceConfiguration deviceConfiguration, IRpdConfigurator rpdConfigurator)
        {
            RpdMeters = new ObservableCollection <RpdMeterViewModel>();

            foreach (var meter in deviceConfiguration.RpdMeters)
            {
                RpdMeters.Add(new RpdMeterViewModel(meter, rpdConfigurator, ConnectionPoints));
            }
        }
Example #11
0
        private void fillPsnMeters(IDeviceConfiguration deviceConfiguration)
        {
            PsnMeters = new ObservableCollection <PsnMeterViewModel>();

            foreach (var psnMeter in deviceConfiguration.PsnMeters)
            {
                PsnMeters.Add(new PsnMeterViewModel(psnMeter));
            }
        }
Example #12
0
 public Request(IConfiguration configuration,
                IJsonManager jsonManager,
                IDeviceConfiguration deviceConfiguration)
 {
     _configuration       = configuration;
     _jsonManager         = jsonManager;
     _deviceConfiguration = deviceConfiguration;
     SetUpBaseAddress();
 }
Example #13
0
        public static bool IsEqualTo(this IDeviceConfiguration config1, IDeviceConfiguration config2)
        {
            if (config1.Address != config2.Address)
            {
                return(false);
            }
            if (config1.Comment != config2.Comment)
            {
                return(false);
            }
            if (!config1.Diagnostic.IsEqualTo(config2.Diagnostic))
            {
                return(false);
            }
            if (config1.LocomotiveName != config2.LocomotiveName)
            {
                return(false);
            }
            if (config1.LogPsn != config2.LogPsn)
            {
                return(false);
            }
            if (config1.NetAddress != config2.NetAddress)
            {
                return(false);
            }

            if (config1.RpdMeters.Count != config2.RpdMeters.Count)
            {
                return(false);
            }
            for (int i = 0; i < config1.RpdMeters.Count; ++i)
            {
                if (!config1.RpdMeters[i].IsEqualTo(config2.RpdMeters[i]))
                {
                    return(false);
                }
            }
            if (config1.ResetFaultsDump != config2.ResetFaultsDump)
            {
                return(false);
            }
            if (config1.SaveByteInterval != config2.SaveByteInterval)
            {
                return(false);
            }
            if (config1.SectionNumber != config2.SectionNumber)
            {
                return(false);
            }
            if (config1.UseHammingForNand != config2.SaveByteInterval)
            {
                return(false);
            }
            return(true);
        }
Example #14
0
 private void linkRpdMetersModelAndViewModel(IDeviceConfiguration deviceConfiguration, IRpdConfigurator rpdConfigurator)
 {
     // Связываем коллекцию моделей представления измерителей с коллекцией измерителей из модели данных.
     rpdMetersLinker = new ObservableCollectionsLinker <IRpdMeter, RpdMeterViewModel>
                           (deviceConfiguration.RpdMeters, RpdMeters,
                           (meter) =>
     {
         return(new RpdMeterViewModel(meter, rpdConfigurator, ConnectionPoints));
     });
 }
Example #15
0
        public void CreatBeamSet()
        {
            IDeviceConfiguration deviceConfiguration = device.GetConfiguration();

            ultrasoundConfiguration = deviceConfiguration.GetUltrasoundConfiguration();
            digitizerTechnology     = ultrasoundConfiguration.GetDigitizerTechnology(UltrasoundTechnology.Conventional);
            IBeamSetFactory beamSetFactory = digitizerTechnology.GetBeamSetFactory();

            beamSet = beamSetFactory.CreateBeamSetConventional("Conventional");
        }
Example #16
0
        private void fillPsnMeters(IDeviceConfiguration deviceConfiguration)
        {
            PsnMeters = new ObservableCollection <PsnMeterViewModel>();


            /* TODO: разобраться куда делись PsnMeters
             * foreach (var psnMeter in deviceConfiguration.PsnMeters)
             *  PsnMeters.Add(new PsnMeterViewModel(psnMeter));
             */
        }
Example #17
0
        public void CreatPABeamSet(ProbeModel probe)
        {
            IDeviceConfiguration deviceConfiguration = device.GetConfiguration();

            ultrasoundConfiguration = deviceConfiguration.GetUltrasoundConfiguration();
            digitizerTechnology     = ultrasoundConfiguration.GetDigitizerTechnology(UltrasoundTechnology.PhasedArray);
            IBeamSetFactory beamSetFactory = digitizerTechnology.GetBeamSetFactory();
            var             beamFormations = GetBeamFormationCollection(beamSetFactory, probe);

            beamSet = beamSetFactory.CreateBeamSetPhasedArray("Phased Array", beamFormations);
        }
Example #18
0
        public MainViewModel(IDeviceConfiguration deviceConfiguration, IRpdConfigurator rpdConfigurator)
        {
            this.deviceConfiguration = deviceConfiguration;
            this.rpdConfigurator     = rpdConfigurator;

            ProgressVisible = false;

            _connectionPointsViewModel = new ConnectionPointsViewModel(new ConnectionPointsDescription());

            initializeCommands();

            reinitializeDeviceConfigurationViewModel();
        }
        /// <summary>
        /// Initializes a new instance of SingleDeviceUptimeManagementDaemon
        /// </summary>
        public SingleDeviceUptimeManagementDaemon(IDeviceConfiguration device, ICalendarFactory calendarFactory)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            if (calendarFactory == null)
            {
                throw new ArgumentNullException(nameof(calendarFactory));
            }

            this.m_Device = device;
            this.m_UptimeRequestProvider = new UptimeManagement(m_Device, calendarFactory);
        }
        /// <summary>
        /// Initializes a new instance of UptimeManagementClient
        /// </summary>
        /// <param name="device">Configuration for the device being managed</param>
        /// <param name="calendarFactory">CalendarFactory to instantiate instances of calendar clients</param>
        public UptimeManagementClient(IDeviceConfiguration device, ICalendarFactory calendarFactory)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            if (calendarFactory == null)
            {
                throw new ArgumentNullException(nameof(calendarFactory));
            }

            this.DeviceName = device.Name;
            this.m_UptimeManagement = new UptimeManagement(device, calendarFactory);
        }
Example #21
0
        /// <summary>
        /// Device-side конструктор
        /// </summary>
        /// <param name="configuration">Конфигурация устройства</param>
        /// <param name="name">Название аварии</param>
        /// <param name="number">Номер аварии</param>
        public FaultLog(IDeviceConfiguration configuration, string name, int number)
        {
            Name   = name;
            Number = number;

            Signals      = new ObservableCollection <ISignal>();
            RpdMeters    = new ObservableCollection <IRpdMeter>();
            OwnerSection = null;
            AccuredAt    = DateTime.Now;

            _deviceConfig = configuration;

            HeaderPageIndex = -1;

            Reason = new FaultReason(null, null);
        }
Example #22
0
        /// <summary>
        /// Initializes a new instance of UptimeManagement
        /// </summary>
        public UptimeManagement(IDeviceConfiguration device, ICalendarFactory calendarFactory)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            if (calendarFactory == null)
            {
                throw new ArgumentNullException(nameof(calendarFactory));
            }

            this.m_Device = device;
            this.m_Calendar = calendarFactory.GetCalendar(m_Device.UptimeCalendarType.ToCalendarCalendarType(),
                m_Device.CalendarProviderSettingsDirectory,
                m_Device.UptimeCalendarName);
        }
Example #23
0
 private void ButtonGetDeviceInfoClick(object sender, EventArgs e)
 {
     try {
         if (comboBoxDrives.SelectedItem != null)
         {
             LockInterface();
             var loader = new Loader(new WinFormsUiNotifier(this));
             _lastReadedConf = loader.CreateDeviceConfiguration();
             _lastReadedConf.Read(comboBoxDrives.SelectedItem.ToString(), OnConfigReadComplete);
         }
         else
         {
             LogStatusMessage("Ошибка: сперва необходимо выбрать устройство");
         }
     }
     catch (Exception ex) {
         MessageBox.Show(ex.ToString());
     }
 }
        public MainWindowController(AnalyzeImgArgs imgIdent, IDeviceConfiguration configuration)
            : this(configuration)
        {
            System.Configuration.ConfigurationManager.RefreshSection("appSettings");
            this.PythonPath = System.Configuration.ConfigurationManager.AppSettings["PythonDetectorPath"];

            this.TaskImageIdents = imgIdent;

            //this.ImageAnalyzer = new ImageAnalyzer(PythonPath);
            //this.ImageAnalyzer.AnalyzeCompleted += ImageAnalyzer_AnalyzeCompleted;
            //this.ImageAnalyzer.AnalyzeImage += ImageAnalyzer_AnalyzeImage;

            this.ImgDlg = new GetPictureDialogFactory(configuration);

            devicesFactory = new DeviceWorkFactory(configuration);

            ChangeDefaultScanner();
            ChangeDefaultWebCam();
        }
Example #25
0
        public AgentHost(
            IDeviceConfiguration deviceConfiguration,
            IUptimeProvider uptimeProvider,
            DeviceStateProvider deviceStateProvider,
            IPathFactory pathFactory,
            DeviceApiClient deviceApiClient,
            ApplicationUpdateService applicationUpdateService,
            IRootFileSystemUpdateService rootFileSystemUpdateService,
            AgentUpdateService agentUpdateService,
            IDockerClient dockerClient,
            ApplicationLogSucker applicationLogSucker,
            ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            _deviceApiClient             = deviceApiClient ?? throw new ArgumentNullException(nameof(deviceApiClient));
            _applicationUpdateService    = applicationUpdateService ?? throw new ArgumentNullException(nameof(applicationUpdateService));
            _rootFileSystemUpdateService = rootFileSystemUpdateService ?? throw new ArgumentNullException(nameof(rootFileSystemUpdateService));
            _agentUpdateService          = agentUpdateService ?? throw new ArgumentNullException(nameof(agentUpdateService));
            _dockerClient         = dockerClient ?? throw new ArgumentNullException(nameof(dockerClient));
            _applicationLogSucker = applicationLogSucker ?? throw new ArgumentNullException(nameof(applicationLogSucker));
            _logger = logger.ForContext(GetType());
            _deviceStateProvider = deviceStateProvider ?? throw new ArgumentNullException(nameof(deviceStateProvider));
            _uptimeProvider      = uptimeProvider ?? throw new ArgumentNullException(nameof(uptimeProvider));
            _deviceConfiguration = deviceConfiguration;

            //Config
            _logger.Information("Docker Endpoint: {DockerSocket}", pathFactory.DockerEndpoint);
            _logger.Information("DeviceId: {DeviceId}", deviceConfiguration?.DeviceId);
            _logger.Information("DeviceApi Url: {DeviceApiUrl}", deviceConfiguration?.DeviceApiUrl);

            //The agent should be updated before the application
            _updateServices = new UpdateService[]
            {
                _agentUpdateService,
                _applicationUpdateService
            };
        }
Example #26
0
        public async Task OnSetup()
        {
            Program.RefreshProject();
            _typesContainer =
                new TypesContainer(Program.GetApp().Container.Resolve(typeof(IUnityContainer)) as IUnityContainer);

            _device        = Program.GetDevice();
            _configuration =

                _device.DeviceFragments.First(fragment => fragment.StrongName == "Configuration") as
                IDeviceConfiguration;

            _shell = _typesContainer.Resolve <ShellViewModel>();
            var deviceMemory = new DeviceMemory();


            _device.DeviceMemory            = deviceMemory;
            _configurationFragmentViewModel = null;

            _configurationFragmentViewModel = _shell.ProjectBrowserViewModel.DeviceViewModels[0].FragmentViewModels
                                              .First(model => model.NameForUiKey == "Configuration") as
                                              RuntimeConfigurationViewModel;
            _readCommand = _configurationFragmentViewModel.FragmentOptionsViewModel.FragmentOptionGroupViewModels
                           .First(model => model.NameKey == "Device").FragmentOptionCommandViewModels
                           .First(model => model.TitleKey == ApplicationGlobalNames.UiCommandStrings.READ_STRING_KEY)
                           .OptionCommand as RelayCommand;
            await _typesContainer.Resolve <IDevicesContainerService>()
            .ConnectDeviceAsync(_device, new MockConnection());

            _shell.ActiveFragmentViewModel = new FragmentPaneViewModel()
            {
                FragmentViewModel = _configurationFragmentViewModel
            };
            await _configurationFragmentViewModel.SetFragmentOpened(true);

            _measuringMonitorViewModel = _shell.ProjectBrowserViewModel.DeviceViewModels[0].FragmentViewModels
                                         .First(model => model.NameForUiKey == "MeasuringMonitor") as
                                         MeasuringMonitorViewModel;
        }
Example #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pathFactory"></param>
        /// <param name="deviceConfiguration"></param>
        /// <param name="customModule">Must provide IRootFileSysteUpdateService.</param>
        /// <returns></returns>
        public static IContainer Create(IPathFactory pathFactory, IDeviceConfiguration deviceConfiguration, Module customModule = null)
        {
            if (pathFactory == null)
            {
                throw new ArgumentNullException(nameof(pathFactory));
            }
            if (deviceConfiguration == null)
            {
                throw new ArgumentNullException(nameof(deviceConfiguration));
            }

            var builder = new ContainerBuilder();

            //Device api
            builder.Register(context => new DeviceApiClient(
                                 deviceConfiguration.DeviceId,
                                 deviceConfiguration.DeviceKey,
                                 deviceConfiguration.DeviceApiUrl)).SingleInstance();

            builder.RegisterInstance(pathFactory);
            builder.RegisterInstance(deviceConfiguration);

            if (customModule != null)
            {
                builder.RegisterModule(customModule);
            }

            builder.RegisterModule <AgentModule>();

            var container = builder.Build();

            //TODO: Find less horribly hacky way to do this.
            var deviceApiClient = container.Resolve <DeviceApiClient>();
            var sink            = container.Resolve <AgentLogSink>();

            sink.DeviceApiClient = deviceApiClient;

            return(container);
        }
        private MainWindowController(IDeviceConfiguration configuration)
        {
            this.Configuration = configuration;
            try
            {
                MAX_RETRY_COUNT = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MaxRetry"]);
                scanner_dpi     = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ScannerDpi"]);
                if (System.Configuration.ConfigurationManager.AppSettings["AllowReScan"] == "1")
                {
                    this.AllowReScan = true;
                }
                else
                {
                    this.AllowReScan = false;
                }
            }
            catch (Exception ex)
            {
                logger.Error("Ошибка параметров приложения. Проверьте правильность ввода MaxRetry, AllowReScan. Error message : \n " + ex);
                Console.WriteLine("Ошибка параметров app.config. Проверь имя и значение");
            }

            ScannerState = new ScanStartState(this);
            ScannerState = ScannerState.ChangeState();

            //  проверка на то, что файлы или камера

            WebCamState = new WebCamStartState(this);
            WebCamState = WebCamState.ChangeState();

            //            webCam = new HDDDriveDevice("path to folder");


            MediaDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "MediaFolder");
            if (!Directory.Exists(MediaDirectory))
            {
                Directory.CreateDirectory(MediaDirectory);
            }
        }
Example #29
0
 ICalendar GetCalendar(IDeviceConfiguration device)
 {
     ICalendar calendar;
     try
     {
         var calendarFactory = new CalendarFactory();
         calendar = calendarFactory.GetCalendar(device.UptimeCalendarType, device.CalendarProviderSettingsDirectory, device.UptimeCalendarName);
     }
     catch (CalendarException ex)
     {
         throw new LockManagerException("Error accessing calendar", ex);
     }
     return calendar;
 }
Example #30
0
 public DeviceWorkFactory(IDeviceConfiguration config)
 {
     this.config = ((ConfigurationSettings)config).GetConfiguration();
 }
Example #31
0
 public void LoadDeviceConfiguration(IDeviceConfiguration devManagerConfiguration)
 {
     DeviceList = devManagerConfiguration.Devices;
 }
Example #32
0
 /// <summary>
 /// Loads device configuration
 /// </summary>
 /// <param name="devManConfiguration"></param>
 public void LoadDeviceConfiguration(IDeviceConfiguration devManConfiguration)
 {
     DeviceList = devManConfiguration.Devices;
 }
Example #33
0
 public GetScanerImagePictureDialog(IDeviceConfiguration config) : base(config, DeviceType.Scanner)
 {
 }
 /// <summary>
 /// Loads device configuration
 /// </summary>
 /// <param name="devManConfiguration"></param>
 public void LoadDeviceConfiguration(IDeviceConfiguration devManConfiguration)
 {
     this.DeviceList = devManConfiguration.Devices;
 }
 public SystemConfigurationBuilderFromHighLevelDeviceConfiguration(IDeviceConfiguration deviceConfiguration, int rpdFaultsCount)
 {
     _deviceConfiguration = deviceConfiguration;
     _rpdFaultsCount      = rpdFaultsCount;
 }
Example #36
0
 public ScannerFormProperties(IDeviceConfiguration config) : base(config, DeviceType.Scanner)
 {
 }
 public static ICalendar GetCalendar(this ICalendarFactory factory, IDeviceConfiguration device)
 {
     return factory.GetCalendar(device.UptimeCalendarType, device.CalendarProviderSettingsDirectory, device.UptimeCalendarName);
 }