示例#1
0
        private bool loggingFlag;                  // indicates that a ready message should be logged


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public DevHttpNotifLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig)
            : base(commContext, lineContext, deviceConfig)
        {
            CanSendCommands    = true;
            ConnectionRequired = false;

            stopwatch    = new Stopwatch();
            config       = new NotifDeviceConfig();
            addressBook  = null;
            paramUri     = null;
            paramContent = null;
            httpClient   = null;
            isReady      = false;
            loggingFlag  = 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);
            }
        }