Esempio n. 1
0
        public ControllerStatusMessage(uint ControllerId, OpModes OpMode, StateValues State = default(StateValues), DateTime TimeStamp = default(DateTime), int Priority = 0) : base(Priority)
        {
            this.ControllerId = (ControllerId > 0) ? ControllerId : throw new ArgumentOutOfRangeException(nameof(ControllerId));
            this.TimeStamp    = (TimeStamp == default(DateTime)) ? DateTime.Now : TimeStamp;
            this.OpMode       = OpMode;

            this.State = new StateValues(OpMode, State.JobMode, State.OperatorId, State.JobCardId, State.MoldId);
        }
Esempio n. 2
0
        internal ControllerStatusMessage(string ID, long Sequence, uint ControllerId, DateTime TimeStamp, Controller Controller, string DisplayName, bool IsDisconnected, OpModes OpMode, JobModes JobMode, uint?OperatorId, string OperatorName, string JobCardId, string MoldId, KeyValuePair <string, bool> Alarm, KeyValuePair <string, double> Audit, KeyValuePair <string, double> Variable, StateValues State, int Priority) : base(ID, Sequence, Priority)
        {
            if (DisplayName != null && string.IsNullOrWhiteSpace(DisplayName))
            {
                throw new ArgumentNullException(nameof(DisplayName));
            }

            // The OperatorName, JobCardId and MoldId properties...
            //   when missing, should be treated as string.Empty, but enter here as null (default value without running NullToEmptyStringConverter)
            //   when actually null, should be treated as null, but enter here as string.Empty (via NullValueToEmptyStringConverter)
            // Therefore, we need to swap the null and string.Empty values.

            if (OperatorName == null)
            {
                OperatorName = string.Empty;
            }
            else if (string.IsNullOrWhiteSpace(OperatorName))
            {
                OperatorName = null;
            }

            if (JobCardId == null)
            {
                JobCardId = string.Empty;
            }
            else if (string.IsNullOrWhiteSpace(JobCardId))
            {
                JobCardId = null;
            }

            if (MoldId == null)
            {
                MoldId = string.Empty;
            }
            else if (string.IsNullOrWhiteSpace(MoldId))
            {
                MoldId = null;
            }

            if (!OperatorId.HasValue)
            {
                OperatorName = string.Empty;
            }
            else if (OperatorId.Value == 0)
            {
                OperatorName = null;
            }

            this.ControllerId   = (ControllerId > 0) ? ControllerId : throw new ArgumentOutOfRangeException(nameof(ControllerId));
            this.TimeStamp      = (TimeStamp == default(DateTime)) ? DateTime.Now : TimeStamp;
            this.DisplayName    = DisplayName;
            this.IsDisconnected = IsDisconnected;
            this.OpMode         = OpMode;
            this.JobMode        = JobMode;
            this.OperatorId     = OperatorId;
            this.OperatorName   = OperatorName;
            this.JobCardId      = JobCardId;
            this.MoldId         = MoldId;
            this.Alarm          = new KeyValuePair <string, bool>(Alarm.Key, Alarm.Value);
            this.Audit          = new KeyValuePair <string, double>(Audit.Key, Audit.Value);
            this.Variable       = new KeyValuePair <string, double>(Variable.Key, Variable.Value);
            this.Controller     = Controller;

            this.State = State;
        }
Esempio n. 3
0
        public ControllerStatusMessage(uint ControllerId, string VariableName, double VariableValue, uint OperatorId, StateValues State = default(StateValues), bool IsAudit = true, DateTime TimeStamp = default(DateTime), int Priority = 0) : base(Priority)
        {
            if (string.IsNullOrWhiteSpace(VariableName))
            {
                throw new ArgumentNullException(nameof(VariableName));
            }

            this.ControllerId = (ControllerId > 0) ? ControllerId : throw new ArgumentOutOfRangeException(nameof(ControllerId));
            this.TimeStamp    = (TimeStamp == default(DateTime)) ? DateTime.Now : TimeStamp;
            this.OperatorId   = OperatorId;

            if (IsAudit)
            {
                this.Audit = new KeyValuePair <string, double>(VariableName, VariableValue);
            }
            else
            {
                this.Variable = new KeyValuePair <string, double>(VariableName, VariableValue);
            }

            this.State = State;
        }
Esempio n. 4
0
        public ControllerStatusMessage(uint ControllerId, uint OperatorId, string OperatorName, StateValues State = default(StateValues), DateTime TimeStamp = default(DateTime), int Priority = 0) : base(Priority)
        {
            if (OperatorName != null && string.IsNullOrWhiteSpace(OperatorName))
            {
                OperatorName = null;
            }

            this.ControllerId = (ControllerId > 0) ? ControllerId : throw new ArgumentOutOfRangeException(nameof(ControllerId));
            this.TimeStamp    = (TimeStamp == default(DateTime)) ? DateTime.Now : TimeStamp;
            this.OperatorId   = OperatorId;
            this.OperatorName = OperatorName;

            this.State = new StateValues(State.OpMode, State.JobMode, OperatorId, JobCardId, State.MoldId);
        }
Esempio n. 5
0
        public ControllerStatusMessage(uint ControllerId, string AlarmName, bool AlarmValue, StateValues State = default(StateValues), DateTime TimeStamp = default(DateTime), int Priority = 0) : base(Priority)
        {
            if (string.IsNullOrWhiteSpace(AlarmName))
            {
                throw new ArgumentNullException(nameof(AlarmName));
            }

            this.ControllerId = (ControllerId > 0) ? ControllerId : throw new ArgumentOutOfRangeException(nameof(ControllerId));
            this.TimeStamp    = (TimeStamp == default(DateTime)) ? DateTime.Now : TimeStamp;
            this.Alarm        = new KeyValuePair <string, bool>(AlarmName, AlarmValue);

            this.State = State;
        }