Beispiel #1
0
        public JobConfigModes()
        {
            InitializeComponent();

            m_LayerSettings = PubFunc.LoadJobModesFromFile();
            Bind();
        }
Beispiel #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                newLayerSettings = new JobModes();
                for (int i = 0; i < cbxPrintMode.Items.Count; i++)
                {
                    if (cbxPrintMode.GetItemChecked(i))
                    {
                        newLayerSettings.Items.Add((JobMode)cbxPrintMode.Items[i]);
                    }
                }

                var    doc = new SelfcheckXmlDocument();
                string xml = string.Empty;
                xml += PubFunc.SystemConvertToXml(newLayerSettings, typeof(JobModes));

                doc.InnerXml = xml;
                doc.Save(fileName);

                MessageBox.Show("Export print mode successfully!");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Export JobConfig Error:" + ex.Message);
            }
        }
Beispiel #3
0
        private void ImportMode_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Filter           = "Job Files (*.xml)|*.xml";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string fileName = openFileDialog.FileName;

                if (File.Exists(fileName))
                {
                    var doc = new SelfcheckXmlDocument();
                    doc.Load(fileName);
                    JobModes importModes = (JobModes)PubFunc.SystemConvertFromXml(doc.InnerXml, typeof(JobModes));

                    for (int i = 0; i < importModes.Items.Count; i++)
                    {
                        foreach (JobMode item in m_LayerSettings.Items)
                        {
                            if (importModes.Items[i].Name.Trim().ToLower() == item.Name.Trim().ToLower())
                            {
                                m_LayerSettings.Items.Remove(item);
                                break;
                            }
                        }

                        m_LayerSettings.Items.Add(importModes.Items[i]);
                    }

                    Bind();
                }
            }
        }
Beispiel #4
0
        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;
                }
            }
        }
Beispiel #5
0
 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;
 }
Beispiel #6
0
        public ControllerStatusMessage(uint ControllerId, JobModes JobMode, 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.JobMode      = JobMode;

            this.State = new StateValues(State.OpMode, JobMode, State.OperatorId, State.JobCardId, State.MoldId);
        }
Beispiel #7
0
        public ControllerStatusMessage(uint ControllerId, JobModes JobMode, 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.JobMode      = JobMode;
        }
Beispiel #8
0
        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;
        }
Beispiel #9
0
        public ExportJobConfig(JobModes obj)
        {
            m_LayerSettings = obj;
            InitializeComponent();

            fileName = @"C:\JobMode_" + DateTime.Now.ToString("yyMMddHHmmss") + ".xml";

            textBox1.Text = fileName;

            cbxPrintMode.DataSource    = m_LayerSettings.Items;
            cbxPrintMode.DisplayMember = "Name";
            cbxPrintMode.ValueMember   = "Name";

            for (int i = 0; i < cbxPrintMode.Items.Count; i++)
            {
                cbxPrintMode.SetItemChecked(i, true);
            }
        }
Beispiel #10
0
 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)
 {
 }
Beispiel #11
0
 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)
 {
 }
Beispiel #12
0
        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;
        }
Beispiel #13
0
        /// <summary>获取/设置 字段值</summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        public override Object this[String name]
        {
            get
            {
                switch (name)
                {
                case __.ID: return(_ID);

                case __.AppID: return(_AppID);

                case __.Name: return(_Name);

                case __.DisplayName: return(_DisplayName);

                case __.Mode: return(_Mode);

                case __.Topic: return(_Topic);

                case __.MessageCount: return(_MessageCount);

                case __.Start: return(_Start);

                case __.End: return(_End);

                case __.Step: return(_Step);

                case __.MinStep: return(_MinStep);

                case __.MaxStep: return(_MaxStep);

                case __.StepRate: return(_StepRate);

                case __.BatchSize: return(_BatchSize);

                case __.Offset: return(_Offset);

                case __.MaxTask: return(_MaxTask);

                case __.MaxError: return(_MaxError);

                case __.MaxRetry: return(_MaxRetry);

                case __.MaxTime: return(_MaxTime);

                case __.MaxRetain: return(_MaxRetain);

                case __.MaxIdle: return(_MaxIdle);

                case __.ErrorDelay: return(_ErrorDelay);

                case __.Total: return(_Total);

                case __.Success: return(_Success);

                case __.Error: return(_Error);

                case __.Times: return(_Times);

                case __.Speed: return(_Speed);

                case __.FetchSpeed: return(_FetchSpeed);

                case __.Enable: return(_Enable);

                case __.Description: return(_Description);

                case __.CreateUserID: return(_CreateUserID);

                case __.CreateUser: return(_CreateUser);

                case __.CreateTime: return(_CreateTime);

                case __.CreateIP: return(_CreateIP);

                case __.UpdateUserID: return(_UpdateUserID);

                case __.UpdateUser: return(_UpdateUser);

                case __.UpdateTime: return(_UpdateTime);

                case __.UpdateIP: return(_UpdateIP);

                default: return(base[name]);
                }
            }
            set
            {
                switch (name)
                {
                case __.ID: _ID = value.ToInt(); break;

                case __.AppID: _AppID = value.ToInt(); break;

                case __.Name: _Name = Convert.ToString(value); break;

                case __.DisplayName: _DisplayName = Convert.ToString(value); break;

                case __.Mode: _Mode = (JobModes)value.ToInt(); break;

                case __.Topic: _Topic = Convert.ToString(value); break;

                case __.MessageCount: _MessageCount = value.ToInt(); break;

                case __.Start: _Start = value.ToDateTime(); break;

                case __.End: _End = value.ToDateTime(); break;

                case __.Step: _Step = value.ToInt(); break;

                case __.MinStep: _MinStep = value.ToInt(); break;

                case __.MaxStep: _MaxStep = value.ToInt(); break;

                case __.StepRate: _StepRate = value.ToInt(); break;

                case __.BatchSize: _BatchSize = value.ToInt(); break;

                case __.Offset: _Offset = value.ToInt(); break;

                case __.MaxTask: _MaxTask = value.ToInt(); break;

                case __.MaxError: _MaxError = value.ToInt(); break;

                case __.MaxRetry: _MaxRetry = value.ToInt(); break;

                case __.MaxTime: _MaxTime = value.ToInt(); break;

                case __.MaxRetain: _MaxRetain = value.ToInt(); break;

                case __.MaxIdle: _MaxIdle = value.ToInt(); break;

                case __.ErrorDelay: _ErrorDelay = value.ToInt(); break;

                case __.Total: _Total = value.ToLong(); break;

                case __.Success: _Success = value.ToLong(); break;

                case __.Error: _Error = value.ToInt(); break;

                case __.Times: _Times = value.ToInt(); break;

                case __.Speed: _Speed = value.ToInt(); break;

                case __.FetchSpeed: _FetchSpeed = value.ToInt(); break;

                case __.Enable: _Enable = value.ToBoolean(); break;

                case __.Description: _Description = Convert.ToString(value); break;

                case __.CreateUserID: _CreateUserID = value.ToInt(); break;

                case __.CreateUser: _CreateUser = Convert.ToString(value); break;

                case __.CreateTime: _CreateTime = value.ToDateTime(); break;

                case __.CreateIP: _CreateIP = Convert.ToString(value); break;

                case __.UpdateUserID: _UpdateUserID = value.ToInt(); break;

                case __.UpdateUser: _UpdateUser = Convert.ToString(value); break;

                case __.UpdateTime: _UpdateTime = value.ToDateTime(); break;

                case __.UpdateIP: _UpdateIP = Convert.ToString(value); break;

                default: base[name] = value; break;
                }
            }
        }
Beispiel #14
0
        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;
        }
Beispiel #15
0
        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();
        }
Beispiel #16
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;
        }