public bool SetConfig([FromUri] bool isMockupMode, [FromUri] bool isTimerOn, [FromUri] int refreshTimerPeriod, [FromUri] bool readCasOkNg) { Logger.Info($"isMockupMode: {isMockupMode}, isTimerOn: {isTimerOn},timerPeriod: {refreshTimerPeriod}"); RunConfig.IsMockupMode = isMockupMode; RunConfig.IsRefreshTimerOn = isTimerOn; RunConfig.RefreshTimerPeriod = refreshTimerPeriod; RunConfig.IsReadOkNgTime = readCasOkNg; //RunConfig.PortReadTimeout = portReadTimeout; //RunConfig.RelaxTime = relaxTime; if (isTimerOn) { SlevyrService.StartWorker(); } else { SlevyrService.StopWorker(); } return(true); }
static SlevyrController() { Logger.Info("+"); var unitAddrs = Settings.Default.UnitAddrs.Split(';').Select(int.Parse); RunConfig = new RunConfig { IsMockupMode = Settings.Default.MockupMode, IsRefreshTimerOn = Settings.Default.IsRefreshTimerOn, IsReadOkNgTime = Settings.Default.IsReadOkNgTime, RefreshTimerPeriod = Settings.Default.RefreshTimerPeriod, WorkerSleepPeriod = Settings.Default.WorkerSleepPeriod, RelaxTime = Settings.Default.RelaxTime, ReadResultTimeOut = Settings.Default.ReadResultTimeOut, SendCommandTimeOut = Settings.Default.SendCommandTimeOut, DataFilePath = Settings.Default.JsonFilePath, UnitAddrs = unitAddrs, IsWriteEmptyToLog = Settings.Default.IsWriteEmptyToLog }; PortConfig = new SerialPortConfig { Port = Settings.Default.Port, BaudRate = Settings.Default.BaudRate, Parity = System.IO.Ports.Parity.None, DataBits = 8, StopBits = System.IO.Ports.StopBits.One, ReceiveLength = 11 }; SlevyrService.Init(PortConfig, RunConfig); Logger.Info("unit count: " + SlevyrService.UnitCount); if (RunConfig.IsRefreshTimerOn) { SlevyrService.StartWorker(); } }