Esempio n. 1
0
        private void FrmConfig_Load(object sender, EventArgs e)
        {
            // translate form
            FormTranslator.Translate(this, GetType().FullName);
            Text = string.Format(Text, deviceNum);

            // load configuration
            if (File.Exists(configFileName) && !config.Load(configFileName, out string errMsg))
            {
                ScadaUiUtils.ShowError(errMsg);
            }

            // display configuration
            ConfigToControls();
            Modified = false;
        }
Esempio n. 2
0
        /// <summary>
        /// Performs actions when starting a communication line.
        /// </summary>
        public override void OnCommLineStart()
        {
            isReady     = false;
            loggingFlag = false;

            // load device configuration
            string fileName = NotifDeviceConfig.GetFileName(DeviceNum);
            string errMsg;

            if (Storage.GetFileInfo(DataCategory.Config, fileName).Exists)
            {
                if (!config.Load(Storage, fileName, out errMsg))
                {
                    Log.WriteLine(errMsg);
                }
            }
            else
            {
                // get URI from command line for backward compatibility
                config.Uri = PollingOptions.CmdLine;
            }

            // initialize variables if configuration is valid
            if (ValidateDeviceConfig(out errMsg))
            {
                if (config.ParamEnabled)
                {
                    paramUri     = new ParamString(config.Uri, config.ParamBegin, config.ParamEnd);
                    paramContent = new ParamString(config.Content, config.ParamBegin, config.ParamEnd);
                }
                else
                {
                    paramUri     = null;
                    paramContent = null;
                }

                addressBook = AddressBookUtils.GetOrLoad(LineContext.SharedData, Storage, Log);
                isReady     = true;
                loggingFlag = true;
            }
            else
            {
                Log.WriteLine(errMsg);
            }
        }