/// <summary> /// Отдельный поток.Загружает данные с весов /// Также устанавливает соединение если нет такового /// <param name="loadMsg">Загружать ли сообщения</param> /// </summary> private static void loadfromscale(bool loadMsg) { _logger.DebugFormat("loadFromScale"); //Если с весами работает другой поток(StartListen), то надо подождать. while (CasLP16.Instance.Loading) { Thread.Sleep(1000); } if (!CasLP16.Instance.Connected) { CasLP16.Instance.SetScaleAddress(ScaleOpt.GetStrOpt(ScaleOpt.OptType.ScaleAddres), ScaleOpt.GetIntOpt(ScaleOpt.OptType.ScalePort)); _lastAnswer = CasLP16.Instance.Connect(); _logger.DebugFormat("Connection: {0:d}", _lastAnswer); if (_lastAnswer != ReturnCode.SUCCESS) { return; } } _lastAnswer = CasLP16.Instance.LoadPLUs(ScaleOpt.GetIntOpt(ScaleOpt.OptType.ScanPLUFrom), ScaleOpt.GetIntOpt(ScaleOpt.OptType.ScanPLUUntil)); _logger.DebugFormat("loadPLU: {0:d}", _lastAnswer); if (_lastAnswer != ReturnCode.SUCCESS) { return; } if (loadMsg) { _lastAnswer = CasLP16.Instance.LoadMSGs(ScaleOpt.GetIntOpt(ScaleOpt.OptType.ScanMSGFrom), ScaleOpt.GetIntOpt(ScaleOpt.OptType.ScanMSGUntil)); _logger.DebugFormat("loadMSG: {0:d}", _lastAnswer); if (_lastAnswer != ReturnCode.SUCCESS) { return; } } }
private void tabControl1_Selected(object sender, TabControlEventArgs e) { if (tabControl1.SelectedTab == tpOptions) { tbAddress.Text = ScaleOpt.GetStrOpt(ScaleOpt.OptType.ScaleAddres); tbPort.Text = ScaleOpt.GetStrOpt(ScaleOpt.OptType.ScalePort); tbSF.Text = ScaleOpt.GetStrOpt(ScaleOpt.OptType.ScanPLUFrom); tbSU.Text = ScaleOpt.GetStrOpt(ScaleOpt.OptType.ScanPLUUntil); nudScanFreq.Value = ScaleOpt.GetIntOpt(ScaleOpt.OptType.ScanDelay); tbMSGsf.Text = ScaleOpt.GetStrOpt(ScaleOpt.OptType.ScanMSGFrom); tbMSGsu.Text = ScaleOpt.GetStrOpt(ScaleOpt.OptType.ScanMSGUntil); chMonitor.Checked = nudScanFreq.Enabled = ScaleOpt.GetBoolOpt(ScaleOpt.OptType.Monitoring); } }
public static void listener() { while (_scanSmrs) { if (!CasLP16.Instance.Loading) { loadfromscale(false); saveSummarys(); } Thread.Sleep(ScaleOpt.GetIntOpt(ScaleOpt.OptType.ScanDelay) * 1000); } if (!_scaleFormActive) { CasLP16.Instance.Disconnect(); } }