/// <summary> /// отправить в ПЛК задание /// </summary> public void SendTask(ProductionTaskExtended task) { Log.logThis($"SendTask: {task.Task.TaskNumber}"); using (OpcClient client = new OpcClient(endpoint)) { try { client.Connect(); object[] result = client.CallMethod( "ns=3;s=\"OpcUaMethodSendNewTask\"", "ns=3;s=\"OpcUaMethodSendNewTask\".Method", (Int32)task.Task.ID, (string)task.Task.TaskNumber, (Int16)task.Task.Diameter, (Int16)task.Task.Thickness, (float)task.Task.PieceLength1, (Int16)task.Task.PieceQuantity1, (Int16)task.serialLabel.StartSerial, (string)task.Task.Labeling1Piece1, (string)task.Task.Labeling2Piece1, (string)task.serialLabel.EndLabel ); } catch (Exception e) { Log.logThis(e.Message); } } }
/// <summary> Отправить задание в ПЛК </summary> public bool SendTask(ProductionTaskExtended task) { opc.SendTask(task); return(true); //try //{ // opc.SendTask(task); // errorScroller?.RemoveError(plcConnectionError); // return true; //} //catch (Exception ex) //{ // errorScroller?.AddError(plcConnectionError); // Log.logThis(ex.Message); // return false; //} }
public void Check() { using (Trubodetal189Entities local = new Trubodetal189Entities()) { int LastID = local.ProductionTasks.Max(p => p.ID); using (ASUTPEntities asutp = new ASUTPEntities()) { IQueryable <Tasker.Task> query = from b in asutp.Tasks where b.ID > LastID && (b.Status == "0" || b.Status == "1") select b; foreach (Task task in query) { task.Status = "1"; ProductionTaskExtended productionTask = new ProductionTaskExtended(task); Log.logThis($"Считали идентификатор: {task.ID}"); local.ProductionTasks.Add(productionTask.Task); } asutp.SaveChanges(); IQueryable <ProductionTask> currentTasks = from b in local.ProductionTasks where b.Status == "1" select b; foreach (ProductionTask productionTask in currentTasks) { try { Task task = asutp.Tasks.Single(t => t.ID == productionTask.ID); if (task.Status != "1") { productionTask.Status = task.Status; } } catch { } } local.SaveChanges(); } } }