コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public FrmConfig(AppDirs appDirs, int deviceNum)
     : this()
 {
     this.appDirs   = appDirs ?? throw new ArgumentNullException(nameof(appDirs));
     this.deviceNum = deviceNum;
     config         = new NotifDeviceConfig();
     configFileName = Path.Combine(appDirs.ConfigDir, NotifDeviceConfig.GetFileName(deviceNum));
     modified       = false;
 }
コード例 #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);
            }
        }