private void InitializeData()
        {
            IModuleService    moduleService    = IocContainerFactory.GetUnityContainer().Resolve <IModuleService>();
            IDataPointService dataPointService = IocContainerFactory.GetUnityContainer().Resolve <IDataPointService>();
            IModbusService    modbusService    = IocContainerFactory.GetUnityContainer().Resolve <IModbusService>();

            GetAllModuleRequest  getAllModuleRequest  = new GetAllModuleRequest();
            GetAllModuleResponse getAllModuleResponse = moduleService.GetAllModules(getAllModuleRequest);

            foreach (var moduleView in getAllModuleResponse.ModuleViews)
            {
                GetDataPointByModuleRequest getDataPointByModuleRequest = new GetDataPointByModuleRequest();
                getDataPointByModuleRequest.ModuleId = moduleView.ModuleId;

                GetDataPointByModuleResponse getDataPointByModuleResponse =
                    dataPointService.GetDataPointInfoByModule(getDataPointByModuleRequest);

                if (getDataPointByModuleResponse.ResponseSucceed)
                {
                    foreach (var dataPointInfoView in getDataPointByModuleResponse.DataPointInfoViews)
                    {
                        DataPointViewModel dataPointViewModel = dataPointInfoView.ConvertToDataPointViewModel();

                        dataPointViewModel.ModuleNumber      = moduleView.Number;
                        dataPointViewModel.ModuleName        = moduleView.Name;
                        dataPointViewModel.ModuleDescription = moduleView.Description;

                        this.DataPoints.Add(dataPointViewModel);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 初始化日志系统
        /// </summary>
        private void InitializeLogger()
        {
            log4net.Config.XmlConfigurator.Configure();

            ILogger logger = IocContainerFactory.GetUnityContainer().Resolve <ILogger>();

            LoggingFactory.InitializeLogFactory(logger);
        }
Exemple #3
0
        private void InitializeDataForView()
        {
            IModbusConfigService modbusConfigService =
                IocContainerFactory.GetUnityContainer().Resolve <IModbusConfigService>();
            GetDataAnalyzeModeResponse response = modbusConfigService.GetDataAnalyzeMode();

            if (response.ResponseSucceed)
            {
                this.CurrentDataAnalyzeMode = response.DataAnalyzeMode;
            }
        }
Exemple #4
0
        public DataPointInformationView()
        {
            InitializeComponent();

            this.dgDataPiontInformation.ColumnWidth = DataGridLength.SizeToCells;

            //非Ioc,要写这写代码,很是繁琐。
            //IUnitOfWork unitOfWork = new NHUnitOfWork();
            //IDataPointRepository dataPointRepository = new DataPointRepository(unitOfWork);
            //dataPointService = new DataPointService(dataPointRepository);

            this.dataPointService = IocContainerFactory.GetUnityContainer().Resolve <IDataPointService>();
        }
Exemple #5
0
        private void ImportModbusConfigToDataBaseCommandExecute()
        {
            IModbusConfigService modbusConfigService =
                IocContainerFactory.GetUnityContainer().Resolve <IModbusConfigService>();

            SetModbusConfigToDataBaseResponse response = modbusConfigService.SetModbusConfigToDataBase();

            if (response.ResponseSucceed)
            {
                MessageBox.Show("导入成功");
            }
            else
            {
                MessageBox.Show(response.Message);
            }
        }
        private void InitializeDataForView()
        {
            IDataBaseConfigService dataBaseConfigService =
                IocContainerFactory.GetUnityContainer().Resolve <IDataBaseConfigService>();

            GetCurrentDataBaseLoginInfoResponse response =
                dataBaseConfigService.GetCurrentDataBaseLoginInfoAndConnetStatus();

            if (response.ResponseSucceed)
            {
                this.DataBaseIp       = response.Ip;
                this.DataBaseAccount  = response.Account;
                this.DataBasePassword = response.Password;

                this.DataBaseConnectSuccess = response.DataBaseConnecting;
            }
        }
Exemple #7
0
        private void SaveDataAnalyzeModeCommandExecute()
        {
            IModbusConfigService modbusConfigService =
                IocContainerFactory.GetUnityContainer().Resolve <IModbusConfigService>();

            SetDataAnalyzeModeRequest request = new SetDataAnalyzeModeRequest();

            request.DataAnalyzeMode = this.CurrentDataAnalyzeMode;

            SetDataAnalyzeModeResponse response = modbusConfigService.SetDataAnalyzeMode(request);

            if (!response.ResponseSucceed)
            {
                this.CurrentDataAnalyzeMode = this.oldDataAnalyzeMode;
                MessageBox.Show("设置数据解析方式失败!");
            }
        }
Exemple #8
0
        public SerialPortConfigerViewModel()
        {
            this.modbusService = (ModbusService)IocContainerFactory.GetUnityContainer().Resolve <IModbusService>();



            this.OpenOrCloseSerialPortCommand = new DelegateCommand(new Action(this.OpenOrCloseSerialPortCommandExecute));

            SerialPort serialPort = this.modbusService.GetCurrentSerialPort();

            this.PortName             = serialPort.PortName;
            this.BaudRate             = serialPort.BaudRate;
            this.Parity               = serialPort.Parity;
            this.DataBits             = serialPort.DataBits;
            this.StopBits             = serialPort.StopBits;
            this.SerialPortConnecting = serialPort.IsOpen;
        }
        public void SetValueToModusCommandExecute()
        {
            IModbusService modbusService = IocContainerFactory.GetUnityContainer().Resolve <IModbusService>();

            if (null != this.SeleteItem)
            {
                DataPointViewModel dataPointViewModel = this.SeleteItem as DataPointViewModel;
                if (null != dataPointViewModel)
                {
                    SetDataPointValueRequest request           = new SetDataPointValueRequest();
                    DataPointInfoView        dataPointInfoView = dataPointViewModel.ConvertToDataPointInfoView();
                    request.DataPointsToSetValue.Add(dataPointInfoView);

                    modbusService.SetDataPointValue(request);
                }
            }
            else
            {
                MessageBox.Show("先选中一行");
            }
        }
        private bool InitDataBase()
        {
            bool success = true;

            IDataBaseConfigService dataBaseConfigService =
                IocContainerFactory.GetUnityContainer().Resolve <IDataBaseConfigService>();
            IApplicationSettings applicationSettings =
                IocContainerFactory.GetUnityContainer().Resolve <IApplicationSettings>();

            string initDataBaseSqcritFileRelativePath
                = applicationSettings.NumericalControlSystemDataBaseSqcritFilePath;

            if (!string.IsNullOrWhiteSpace(initDataBaseSqcritFileRelativePath))
            {
                string initDataBaseSqcritFileAbsolutePath =
                    System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory,
                                           initDataBaseSqcritFileRelativePath);

                ExecuteSqlScriptRequest request = new ExecuteSqlScriptRequest();
                request.SqlScriptFiles.Add(initDataBaseSqcritFileAbsolutePath);
                ExecuteSqlScriptResponse response = dataBaseConfigService.ExecuteSqlScript(request);

                if (response.ResponseSucceed)
                {
                    success = true;
                }
                else
                {
                    success = false;
                    MessageBox.Show(response.Message);
                }
            }
            else
            {
                success = false;
                MessageBox.Show("无法获取初始化脚本文件!");
            }

            return(success);
        }
        public void ReadingDataPointRealTimeValue(object obj, EventArgs e)
        {
            IModbusService modbusService = IocContainerFactory.GetUnityContainer().Resolve <IModbusService>();

            lock (objReadingDataPointRealTimeValueLock)
            {
                GetAllDataPointsRealTimeDataResponse response = null;
                response = modbusService.GetAllDataPointsRealTimeData();

                if (null != response && response.ResponseSucceed)
                {
                    List <DataPointRealTimeDataView> dataPointRealTimeDataViews = response.AllDataPointsRealTimeData;
                    foreach (var dataPointRealTimeDataView in dataPointRealTimeDataViews)
                    {
                        DataPointViewModel dataPointViewModel = this.DataPoints.Find(p => p.Id == dataPointRealTimeDataView.DataPointId);
                        if (null != dataPointViewModel)
                        {
                            dataPointViewModel.RealTimeValue = dataPointRealTimeDataView.DataPointRealTimeValue;
                        }
                    }
                }
            }
        }
        private void ConnectDataBaseCommandCommandExecute()
        {
            IDataBaseConfigService dataBaseConfigService =
                IocContainerFactory.GetUnityContainer().Resolve <IDataBaseConfigService>();

            TestConnetDataBaseRequest request = new TestConnetDataBaseRequest();

            request.SaveConfig = true;
            request.Ip         = this.dataBaseIp;
            request.Account    = this.dataBaseAccount;
            request.Password   = this.dataBasePassword;

            TestConnetDataBaseResponse response = dataBaseConfigService.TestConnetDataBase(request);

            if (response.ResponseSucceed)
            {
                this.DataBaseConnectSuccess = true;
            }
            else
            {
                this.DataBaseConnectSuccess = false;
                MessageBox.Show(response.Message);
            }
        }
Exemple #13
0
 /// <summary>
 /// 初始化服务
 /// </summary>
 private void InitializeServices()
 {
     IModbusConfigService         modbusConfigService         = IocContainerFactory.GetUnityContainer().Resolve <IModbusConfigService>();
     IModbusService               modbusService               = IocContainerFactory.GetUnityContainer().Resolve <IModbusService>();
     IDataPointHistoryDataService dataPointHistoryDataService = IocContainerFactory.GetUnityContainer().Resolve <IDataPointHistoryDataService>();
 }
Exemple #14
0
        /// <summary>
        /// 初始化程序配置
        /// </summary>
        private static void InitializeApplicationSetting()
        {
            IApplicationSettings applicationSettings = IocContainerFactory.GetUnityContainer().Resolve <IApplicationSettings>();

            ApplicationSettingsFactory.InitializeApplicationSettingsFactory(applicationSettings);
        }