| | |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Xml.Linq; |
| | | using WIDESEA_Comm.DBItem; |
| | | using WIDESEA_Comm.ItemDB; |
| | | using WIDESEA_Core.EFDbContext; |
| | |
| | | client.Connect(); |
| | | return; |
| | | } |
| | | client.WriteByOrder("W_Palpitate", client.ReadByOrder<bool>("R_Palpitate", "å¿è·³")); |
| | | Gantry gantry = new Gantry(); |
| | | gantry.QueryWheeldata(client); |
| | | gantry.QueryOrder(client); |
| | | gantry.QueryWheeldata(client); |
| | | gantry.Layofflevel(client); |
| | | gantry.Stupidproofmeasure(client); |
| | | } |
| | | |
| | | #region |
| | | static List<MachineDB> MachineDBs = new List<MachineDB>(); |
| | | static List<WheelDataDB> wheelDataDBs = new List<WheelDataDB>(); |
| | | private void DoAction(PLCClient client) |
| | | { |
| | | try |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context); |
| | | Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context); |
| | | |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | var numbers = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep).GroupBy(x => x.plcdetail_number).ToList(); |
| | | foreach (var number in numbers) |
| | | { |
| | | if (number.Key.Contains("è¾é䏿")) |
| | | { |
| | | PropertyInfo[] propertyInfos = typeof(WheelDataDB).GetProperties();//è·åææå±æ§ |
| | | WheelDataDB dBItem = wheelDataDBs.Where(x => x.R_Name == number.Key).FirstOrDefault(); |
| | | if (dBItem == null) |
| | | { |
| | | dBItem = new(); |
| | | dBItem.OnReadSignal += HandleReadSignal; |
| | | wheelDataDBs.Add(dBItem); |
| | | } |
| | | List<dt_plcinfodetail> details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == number.Key).ToList(); |
| | | for (int i = 0; i < propertyInfos.Length; i++) |
| | | { |
| | | if (i == 0) |
| | | { |
| | | dBItem.R_Name = number.Key; |
| | | } |
| | | else |
| | | { |
| | | object readData = DBExtension.Read(details.Where(x => x.plcdetail_name == propertyInfos[i].Name).FirstOrDefault(), client); |
| | | if (readData != null) { } |
| | | object obj = propertyInfos[i].GetValue(dBItem); |
| | | if (obj != readData) |
| | | propertyInfos[i].SetValue(dBItem, readData); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | PropertyInfo[] propertyInfos = typeof(MachineDB).GetProperties();//è·åææå±æ§ |
| | | MachineDB dBItem = MachineDBs.Where(x => x.R_Name == number.Key).FirstOrDefault(); |
| | | if (dBItem == null) |
| | | { |
| | | dBItem = new(); |
| | | dBItem.OnReadSignal += HandleReadSignal; |
| | | MachineDBs.Add(dBItem); |
| | | } |
| | | List<dt_plcinfodetail> details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == number.Key).ToList(); |
| | | for (int i = 0; i < propertyInfos.Length; i++) |
| | | { |
| | | if (i == 0) |
| | | { |
| | | dBItem.R_Name = number.Key; |
| | | } |
| | | else |
| | | { |
| | | object readData = DBExtension.Read(details.Where(x => x.plcdetail_name == propertyInfos[i].Name).FirstOrDefault(), client); |
| | | if (readData != null) { } |
| | | object obj = propertyInfos[i].GetValue(dBItem); |
| | | if (obj != readData) |
| | | propertyInfos[i].SetValue(dBItem, readData); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | } |
| | | #endregion |
| | | public void HandleReadSignal(string type, MachineDB DBItem) |
| | | { |
| | | switch (type) |
| | | { |
| | | case OperationType.OperationType_Record: |
| | | |
| | | break; |
| | | case OperationType.OperationType_Processor: |
| | | |
| | | break; |
| | | case OperationType.OperationType_WheelData: |
| | | |
| | | break; |
| | | } |
| | | } |
| | | public void HandleReadSignal(string type, WheelDataDB DBItem) |
| | | { |
| | | switch (type) |
| | | { |
| | | case OperationType.OperationType_Record: |
| | | |
| | | break; |
| | | case OperationType.OperationType_Processor: |
| | | |
| | | break; |
| | | case OperationType.OperationType_WheelData: |
| | | |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |