private void FrmConfig_Load(object sender, EventArgs e) { // translate the form if (Localization.LoadDictionaries(appDirs.LangDir, "KpHttpNotif", out string errMsg)) { Translator.TranslateForm(this, GetType().FullName); } else { ScadaUiUtils.ShowError(errMsg); } Text = string.Format(Text, kpNum); // load a configuration configFileName = DeviceConfig.GetFileName(appDirs.ConfigDir, kpNum); if (File.Exists(configFileName) && !config.Load(configFileName, out errMsg)) { ScadaUiUtils.ShowError(errMsg); } // display the configuration ConfigToControls(); Modified = false; }
private void FrmConfig_Load(object sender, EventArgs e) { // translate the form if (Localization.LoadDictionaries(appDirs.LangDir, "KpOpcUa", out string errMsg)) { Translator.TranslateForm(this, GetType().FullName, toolTip); } else { ScadaUiUtils.ShowError(errMsg); } Text = string.Format(Text, kpNum); KpPhrases.Init(); // load a configuration configFileName = DeviceConfig.GetFileName(appDirs.ConfigDir, kpNum); if (File.Exists(configFileName) && !deviceConfig.Load(configFileName, out errMsg)) { ScadaUiUtils.ShowError(errMsg); } // display the configuration ConfigToControls(); SetConnButtonsEnabled(); SetServerButtonsEnabled(); SetDeviceButtonsEnabled(); Modified = false; }
/// <summary> /// Performs actions when starting a communication line. /// </summary> public override void OnCommLineStart() { isReady = false; flagLoggingRequired = false; // load device configuration deviceConfig = new DeviceConfig(); string fileName = DeviceConfig.GetFileName(AppDirs.ConfigDir, Number); string errMsg; if (File.Exists(fileName)) { if (!deviceConfig.Load(fileName, out errMsg)) { WriteToLog(errMsg); } } else { // get URI from command line for backward compatibility deviceConfig.Uri = ReqParams.CmdLine; } // initialize variables if the configuration is valid if (ValidateConfig(deviceConfig, out errMsg)) { if (deviceConfig.ParamEnabled) { paramUri = new ParamString(deviceConfig.Uri, deviceConfig.ParamBegin, deviceConfig.ParamEnd); paramContent = new ParamString(deviceConfig.Content, deviceConfig.ParamBegin, deviceConfig.ParamEnd); } else { paramUri = null; paramContent = null; } addressBook = AbUtils.GetAddressBook(AppDirs.ConfigDir, CommonProps, WriteToLog); SetCurData(TagIndex.NotifCounter, 0, 1); // reset notification counter isReady = true; flagLoggingRequired = true; } else { WriteToLog(errMsg); } }
/// <summary> /// Performs actions after adding the device to a communication line. /// </summary> public override void OnAddedToCommLine() { deviceConfig = new DeviceConfig(); if (deviceConfig.Load(DeviceConfig.GetFileName(AppDirs.ConfigDir, Number), out string errMsg)) { InitDeviceTags(); // fill the command dictionary cmdByNum = new Dictionary <int, CommandConfig>(); deviceConfig.Commands.ForEach((CommandConfig c) => cmdByNum[c.CmdNum] = c); } else { deviceConfig = null; WriteToLog(errMsg); WriteToLog(Localization.UseRussian ? "Взаимодействие с OPC-сервером невозможно, т.к. конфигурация КП не загружена" : "Interaction with OPC server is impossible because device configuration is not loaded"); } }