public CycleData(string uniqueId, string orgId, uint controller, OpModes opmode, JobModes jobmode, int user, string jobcard, string mold, IReadOnlyDictionary <string, double> data = null, DateTimeOffset time = default(DateTimeOffset)) : base(uniqueId, orgId, controller, time == default(DateTimeOffset) ? DateTimeOffset.UtcNow : time) { if (controller <= 0) { throw new ArgumentOutOfRangeException(nameof(controller)); } if (mold != null && string.IsNullOrWhiteSpace(mold)) { throw new ArgumentNullException(nameof(mold)); } if (jobcard != null && string.IsNullOrWhiteSpace(jobcard)) { throw new ArgumentNullException(nameof(jobcard)); } OpMode = opmode; JobMode = jobmode; OperatorId = user; JobCardId = jobcard?.Trim(); MoldId = mold?.Trim(); if (data != null) { foreach (var kv in data.Where(kv => kv.Key != Storage.Time)) { m_Data[kv.Key.Trim().ToUpperInvariant()] = kv.Value; } } }
public StateValues(OpModes OpMode = OpModes.Unknown, JobModes JobMode = JobModes.Unknown, uint OperatorId = 0, string JobCardId = null, string MoldId = null) { this.OpMode = OpMode; this.JobMode = JobMode; this.OperatorId = OperatorId; this.JobCardId = !string.IsNullOrWhiteSpace(JobCardId) ? JobCardId : null; this.MoldId = !string.IsNullOrWhiteSpace(MoldId) ? MoldId : null; }
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); }
public ControllerStatusMessage(uint ControllerId, OpModes OpMode, DateTime TimeStamp = default(DateTime), int Priority = 0) : base(Priority) { if (ControllerId <= 0) { throw new ArgumentOutOfRangeException(nameof(ControllerId)); } this.ControllerId = ControllerId; this.TimeStamp = (TimeStamp == default(DateTime)) ? DateTime.Now : TimeStamp; this.OpMode = OpMode; }
internal MoldDataMessage(string ID, long Sequence, uint ControllerId, string JobCardId, string MoldId, uint OperatorId, OpModes OpMode, JobModes JobMode, IReadOnlyDictionary <string, double> Data, DateTime TimeStamp, int Priority) : base(ID, Sequence, ControllerId, JobCardId, MoldId, OperatorId, OpMode, JobMode, Data, TimeStamp, Priority) { }
public MoldDataMessage(uint ControllerId, string JobCardId, string MoldId, uint OperatorId, OpModes OpMode, JobModes JobMode, IReadOnlyDictionary <string, double> Data, DateTime TimeStamp = default(DateTime), int Priority = 0) : base(ControllerId, JobCardId, MoldId, OperatorId, OpMode, JobMode, Data, TimeStamp, Priority) { }
partial void SetOpMode(OpModes opmode);
internal ControllerStatusMessage(long Sequence, uint ControllerId, DateTime TimeStamp, Controller Controller, string DisplayName, bool IsDisconnected, uint?OperatorId, string MoldId, KeyValuePair <string, bool> Alarm, KeyValuePair <string, double> Audit, int Priority, OpModes OpMode = OpModes.Unknown, JobModes JobMode = JobModes.Offline) : base(Sequence, Priority) { if (ControllerId <= 0) { throw new ArgumentOutOfRangeException(nameof(ControllerId)); } if (string.IsNullOrWhiteSpace(DisplayName)) { DisplayName = null; } if (MoldId != null && string.IsNullOrWhiteSpace(MoldId)) { MoldId = string.Empty; } this.ControllerId = ControllerId; this.TimeStamp = (TimeStamp == default(DateTime)) ? DateTime.Now : TimeStamp; this.DisplayName = DisplayName?.Trim(); this.IsDisconnected = IsDisconnected; this.OpMode = OpMode; this.JobMode = JobMode; this.OperatorId = OperatorId; this.MoldId = MoldId; this.Alarm = new KeyValuePair <string, bool>(Alarm.Key, Alarm.Value); this.Audit = new KeyValuePair <string, double>(Audit.Key, Audit.Value); this.Controller = Controller; }
public void SetOpMode(OpModes opmode) { }
internal CycleDataMessage(string ID, long Sequence, uint ControllerId, string JobCardId, string MoldId, uint OperatorId, OpModes OpMode, JobModes JobMode, IReadOnlyDictionary <string, double> Data, DateTime TimeStamp, int Priority) : base(ID, Sequence, ControllerId, Data, Priority) { if (JobCardId != null && string.IsNullOrWhiteSpace(JobCardId)) { throw new ArgumentNullException(nameof(JobCardId)); } if (MoldId != null && string.IsNullOrWhiteSpace(MoldId)) { throw new ArgumentNullException(nameof(MoldId)); } this.JobCardId = JobCardId?.Trim(); this.MoldId = MoldId?.Trim(); this.OperatorId = OperatorId; this.OpMode = OpMode; this.JobMode = JobMode; this.TimeStamp = (TimeStamp == default(DateTime)) ? DateTime.Now : TimeStamp; }
public Controller(uint ControllerId, string ControllerType, string Version, string Model, string IP, OpModes OpMode, JobModes JobMode, string JobCardId, string DisplayName, double?GeoLatitude = null, double?GeoLongitude = null, IReadOnlyDictionary <string, double> LastCycleData = null, IReadOnlyDictionary <string, double> Variables = null, DateTime LastConnectionTime = default(DateTime), uint OperatorId = 0, string OperatorName = null, string MoldId = null) { this.ControllerId = (ControllerId > 0) ? ControllerId : throw new ArgumentOutOfRangeException(nameof(ControllerId)); this.ControllerType = !string.IsNullOrWhiteSpace(ControllerType) ? ControllerType.Trim() : throw new ArgumentNullException(nameof(ControllerType)); this.Version = !string.IsNullOrWhiteSpace(Version) ? Version.Trim() : throw new ArgumentNullException(nameof(Version)); this.Model = !string.IsNullOrWhiteSpace(Model) ? Model.Trim() : throw new ArgumentNullException(nameof(Model)); if (string.IsNullOrWhiteSpace(IP)) { throw new ArgumentNullException(nameof(IP)); } string strIP = IP.Trim(); var match = IPRegex.Match(strIP); if (match.Success) { if (!IPAddress.TryParse(match.Groups["ip"].Value, out IPAddress addr)) { throw new ArgumentOutOfRangeException(nameof(IP)); } strIP = addr.ToString() + (match.Groups["port"].Success ? ":" + match.Groups["port"].Value : null); } else { match = SerialPortRegex.Match(strIP); if (match.Success) { strIP = "COM" + match.Groups["port"].Value; } else { match = TtyRegex.Match(strIP); if (!match.Success) { throw new ArgumentOutOfRangeException(nameof(IP)); } } } this.IP = strIP; this.OpMode = (OpMode != OpModes.Unknown) ? OpMode : throw new ArgumentOutOfRangeException(nameof(OpMode)); this.JobMode = (JobMode != JobModes.Unknown) ? JobMode : throw new ArgumentOutOfRangeException(nameof(JobMode)); this.DisplayName = !string.IsNullOrWhiteSpace(DisplayName) ? DisplayName.Trim() : throw new ArgumentNullException(nameof(DisplayName)); this.JobCardId = (JobCardId == null || !string.IsNullOrWhiteSpace(JobCardId)) ? JobCardId?.Trim() : throw new ArgumentNullException(nameof(JobCardId)); this.LastCycleData = LastCycleData?.ToDictionary(kv => kv.Key, kv => kv.Value, StringComparer.OrdinalIgnoreCase); this.Variables = Variables?.ToDictionary(kv => kv.Key, kv => kv.Value, StringComparer.OrdinalIgnoreCase); this.LastConnectionTime = LastConnectionTime; this.OperatorId = OperatorId; this.OperatorName = (OperatorName == null || !string.IsNullOrWhiteSpace(OperatorName)) ? OperatorName?.Trim() : throw new ArgumentNullException(nameof(OperatorName)); this.MoldId = (MoldId == null || !string.IsNullOrWhiteSpace(MoldId)) ? MoldId?.Trim() : throw new ArgumentNullException(nameof(MoldId)); this.GeoLatitude = GeoLatitude; this.GeoLongitude = GeoLongitude; }
private string SetOpMode(OpModes opmode) { return(""); }
public Controller(uint ControllerId, ControllerTypes ControllerType, string Version, string Model, string IP, OpModes OpMode, JobModes JobMode, string JobCardId, string DisplayName, IReadOnlyDictionary <string, double> LastCycleData = null, DateTime LastConnectionTime = default(DateTime), uint OperatorId = 0, string MoldId = null) { if (ControllerId <= 0) { throw new ArgumentOutOfRangeException(nameof(ControllerId)); } if (ControllerType < 0) { throw new ArgumentOutOfRangeException(nameof(ControllerType)); } if (string.IsNullOrWhiteSpace(Version)) { throw new ArgumentNullException(nameof(Version)); } if (string.IsNullOrWhiteSpace(Model)) { throw new ArgumentNullException(nameof(Model)); } if (string.IsNullOrWhiteSpace(IP)) { throw new ArgumentNullException(nameof(IP)); } if (string.IsNullOrWhiteSpace(DisplayName)) { throw new ArgumentNullException(nameof(DisplayName)); } if (OpMode == OpModes.Unknown) { throw new ArgumentOutOfRangeException(nameof(OpMode)); } if (JobMode == JobModes.Unknown) { throw new ArgumentOutOfRangeException(nameof(JobMode)); } if (JobCardId != null && string.IsNullOrWhiteSpace(JobCardId)) { throw new ArgumentNullException(nameof(JobCardId)); } if (MoldId != null && string.IsNullOrWhiteSpace(MoldId)) { throw new ArgumentNullException(nameof(MoldId)); } string strIP = null; var match = IPRegex.Match(IP.Trim()); if (match.Success) { IPAddress addr; if (!IPAddress.TryParse(match.Groups["ip"].Value, out addr)) { throw new ArgumentOutOfRangeException(nameof(IP)); } strIP = addr.ToString() + (match.Groups["port"].Success ? ":" + match.Groups["port"].Value : null); } else { match = SerialPortRegex.Match(IP.Trim()); if (match.Success) { strIP = "COM" + match.Groups["port"].Value; } else { throw new ArgumentOutOfRangeException(nameof(IP)); } } this.ControllerId = ControllerId; this.ControllerType = ControllerType; this.Version = Version.Trim(); this.Model = Model.Trim(); this.IP = strIP; this.OpMode = OpMode; this.JobMode = JobMode; this.DisplayName = DisplayName.Trim(); this.JobCardId = JobCardId?.Trim(); this.LastCycleData = LastCycleData?.ToDictionary(kv => kv.Key, kv => kv.Value, StringComparer.OrdinalIgnoreCase); this.LastConnectionTime = LastConnectionTime; this.OperatorId = OperatorId; this.MoldId = MoldId?.Trim(); }
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; }