public void CleanUp() { management = new AlarmManagement(); entityManagement = new EntityManagement(); management.DeleteAll(); entityManagement.DeleteAllEntities(); }
private void ResetAll_bt_Click(object sender, EventArgs e) { Transaction Txn; foreach (AlarmInfo eachA in AlarmManagement.GetAll()) { if (!eachA.NeedReset) { AlarmManagement.Remove(eachA); } } //foreach (Node node in NodeManagement.GetList()) //{ // node.State = node.LastState; //} var NodeList = AlarmManagement.GetAll().GroupBy(t => t.NodeName); foreach (var group in NodeList) { string Message = ""; Txn = new Transaction(); Txn.Method = Transaction.Command.RobotType.Reset; Txn.TaskId = ""; //NodeManagement.Get(group.First().NodeName).State = "Alarm"; NodeManagement.Get(group.First().NodeName).SendCommand(Txn, out Message); AlarmManagement.Remove(group.First().NodeName); } //NodeStatusUpdate.UpdateCurrentState("Idle"); AlarmUpdate.UpdateAlarmList(AlarmManagement.GetAll()); }
public void On_Connection_Error(string DIOName, string ErrorMsg) { //斷線 發ALARM logger.Debug("On_Error_Occurred"); AlarmInfo CurrentAlarm = new AlarmInfo(); CurrentAlarm.NodeName = DIOName; CurrentAlarm.AlarmCode = "00200001"; CurrentAlarm.NeedReset = false; try { AlarmMessage Detail = AlmMapping.Get("DIO", CurrentAlarm.AlarmCode); CurrentAlarm.SystemAlarmCode = Detail.CodeID; CurrentAlarm.Desc = Detail.Code_Cause; CurrentAlarm.EngDesc = Detail.Code_Cause_English; CurrentAlarm.Type = Detail.Code_Type; CurrentAlarm.IsStop = Detail.IsStop; if (CurrentAlarm.IsStop) { //RouteCtrl.Stop(); } } catch (Exception e) { CurrentAlarm.Desc = "未定義"; logger.Error(DIOName + "(GetAlarmMessage)" + e.Message + "\n" + e.StackTrace); } CurrentAlarm.TimeStamp = DateTime.Now; AlarmManagement.Add(CurrentAlarm); AlarmUpdate.UpdateAlarmList(AlarmManagement.GetAll()); AlarmUpdate.UpdateAlarmHistory(AlarmManagement.GetHistory()); }
private void AbortTask(TaskFlowManagement.CurrentProcessTask TaskJob, Node Node, string Message) { _TaskReport.On_Alarm_Happen(AlarmManagement.NewAlarm(Node, Message)); _TaskReport.On_TaskJob_Aborted(TaskJob); _TaskReport.On_Message_Log("CMD", TaskJob.TaskName.ToString() + " " + (TaskJob.Params.ContainsKey("@Target") ? TaskJob.Params["@Target"] : "") + " Aborted"); }
public void On_Command_TimeOut(Node Node, Transaction Txn) { logger.Debug("On_Command_TimeOut"); AlarmInfo CurrentAlarm = new AlarmInfo(); CurrentAlarm.NodeName = Node.Name; CurrentAlarm.AlarmCode = "00200002"; CurrentAlarm.NeedReset = false; try { AlarmMessage Detail = AlmMapping.Get("SYSTEM", CurrentAlarm.AlarmCode); CurrentAlarm.SystemAlarmCode = Detail.CodeID; CurrentAlarm.Desc = Detail.Code_Cause; CurrentAlarm.EngDesc = Detail.Code_Cause_English; CurrentAlarm.Type = Detail.Code_Type; CurrentAlarm.IsStop = Detail.IsStop; if (CurrentAlarm.IsStop) { //RouteCtrl.Stop(); } } catch (Exception e) { CurrentAlarm.Desc = "未定義"; logger.Error(Node.Controller + "-" + Node.AdrNo + "(GetAlarmMessage)" + e.Message + "\n" + e.StackTrace); } CurrentAlarm.TimeStamp = DateTime.Now; AlarmManagement.Add(CurrentAlarm); AlarmUpdate.UpdateAlarmList(AlarmManagement.GetAll()); AlarmUpdate.UpdateAlarmHistory(AlarmManagement.GetHistory()); }
public void On_Command_Error(Node Node, Transaction Txn, CommandReturnMessage Msg) { switch (Txn.FormName) { case "FormManual": switch (Node.Type) { case "LOADPORT": //ManualPortStatusUpdate.LockUI(false); break; } break; } logger.Debug("On_Command_Error"); AlarmInfo CurrentAlarm = new AlarmInfo(); CurrentAlarm.NodeName = Node.Name; CurrentAlarm.AlarmCode = Msg.Value; CurrentAlarm.NeedReset = true; try { AlarmMessage Detail = AlmMapping.Get(Node.Name, CurrentAlarm.AlarmCode); CurrentAlarm.SystemAlarmCode = Detail.CodeID; CurrentAlarm.Desc = Detail.Code_Cause; CurrentAlarm.EngDesc = Detail.Code_Cause_English; CurrentAlarm.Type = Detail.Code_Type; CurrentAlarm.IsStop = Detail.IsStop; if (CurrentAlarm.IsStop) { // RouteCtrl.Stop(); } } catch (Exception e) { CurrentAlarm.Desc = "未定義"; logger.Error(Node.Controller + "-" + Node.AdrNo + "(GetAlarmMessage)" + e.Message + "\n" + e.StackTrace); } CurrentAlarm.TimeStamp = DateTime.Now; AlarmManagement.Add(CurrentAlarm); AlarmUpdate.UpdateAlarmList(AlarmManagement.GetAll()); AlarmUpdate.UpdateAlarmHistory(AlarmManagement.GetHistory()); }
public void On_TaskJob_Aborted(TaskJobManagment.CurrentProceedTask Task, string NodeName, string ReportType, string Message) { if (Task.Id.Equals("FormManual")) { ManualPortStatusUpdate.LockUI(false); } AlarmInfo CurrentAlarm = new AlarmInfo(); CurrentAlarm.NodeName = "SYSTEM"; CurrentAlarm.AlarmCode = Message; CurrentAlarm.NeedReset = false; try { AlarmMessage Detail = AlmMapping.Get("SYSTEM", CurrentAlarm.AlarmCode); if (!Detail.Code_Group.Equals("UNDEFINITION")) { CurrentAlarm.SystemAlarmCode = Detail.CodeID; CurrentAlarm.Desc = Detail.Code_Cause; CurrentAlarm.EngDesc = Detail.Code_Cause_English; CurrentAlarm.Type = Detail.Code_Type; CurrentAlarm.IsStop = Detail.IsStop; if (CurrentAlarm.IsStop) { //RouteCtrl.Stop(); } CurrentAlarm.TimeStamp = DateTime.Now; AlarmManagement.Add(CurrentAlarm); AlarmUpdate.UpdateAlarmList(AlarmManagement.GetAll()); AlarmUpdate.UpdateAlarmHistory(AlarmManagement.GetHistory()); } } catch (Exception e) { CurrentAlarm.Desc = "未定義"; logger.Error("(GetAlarmMessage)" + e.Message + "\n" + e.StackTrace); } }
private void AlarmFrom_Load(object sender, EventArgs e) { AlarmUpdate.UpdateAlarmList(AlarmManagement.GetAll()); }
public void Start(object node) { int AddrOffset = 1280; int CstRobotStation = 9; Node Target = (Node)node; //SpinWait.SpinUntil(() => Target.GetController().GetStatus().Equals("Connected"), 9999999); //McProtocolTcp PLC = new McProtocolTcp("192.168.3.39", 2000); McProtocolTcp PLC = new McProtocolTcp(this.IPAdress, this.Port); this._IsConnected = true; byte[] result = new byte[512]; int[] WResult = new int[32]; bool isInit = false; int RecieveIndex_1 = 0; int RecieveIndex_2 = 0; //PLC.SetBitDevice(PlcDeviceType.Y, new Dictionary<int, byte>() { { 1280,1}, { 1281, 1 }, { 1285, 1 } }); while (true) { try { if (!isInit) { PLC.Open(); //INIT result = new byte[512]; PLC.GetBitDevice(PlcDeviceType.Y, AddrOffset, 512, result); Target.SetIO("OUTPUT", result); result = new byte[512]; Target.SetIO("OUTPUT_OLD", result); result = new byte[512]; PLC.GetBitDevice(PlcDeviceType.X, AddrOffset, 512, result); Target.SetIO("INPUT", result); result = new byte[512]; Target.SetIO("INPUT_OLD", result); WResult = new int[32]; PLC.ReadDeviceBlock(PlcDeviceType.D, 24576 + 1, 32, WResult); result = ConvertToBit(WResult); Target.SetIO("PRESENCE", result); result = new byte[512]; Target.SetIO("PRESENCE_OLD", result); WResult = new int[2]; PLC.ReadDeviceBlock(PlcDeviceType.D, 25856, 2, WResult); RecieveIndex_1 = WResult[0]; RecieveIndex_2 = WResult[1]; isInit = true; } if (!ch1Send.Equals("")) { int[] SendDataBytes = ByteArrayToIntArray(Encoding.ASCII.GetBytes(ch1Send)); PLC.WriteDeviceBlock(PlcDeviceType.D, 24848, SendDataBytes.Length, SendDataBytes); PLC.WriteDeviceBlock(PlcDeviceType.D, 24834, 1, new int[] { SendDataBytes.Length }); PLC.SetBitDevice(PlcDeviceType.Y, 1776, 1, new byte[] { 1 }); ch1Send = ""; } if (!ch2Send.Equals("")) { int[] SendDataBytes = ByteArrayToIntArray(Encoding.ASCII.GetBytes(ch2Send)); PLC.WriteDeviceBlock(PlcDeviceType.D, 25104, SendDataBytes.Length, SendDataBytes); PLC.WriteDeviceBlock(PlcDeviceType.D, 25090, 1, new int[] { SendDataBytes.Length }); PLC.SetBitDevice(PlcDeviceType.Y, 1778, 1, new byte[] { 1 }); ch2Send = ""; } //SpinWait.SpinUntil(() => false, 10); WResult = new int[90]; PLC.ReadDeviceBlock(PlcDeviceType.D, 25856, 2, WResult); if (RecieveIndex_1 != WResult[0]) { RecieveIndex_1 = WResult[0]; int[] WResult1 = new int[90]; PLC.ReadDeviceBlock(PlcDeviceType.D, 25360, 90, WResult1); string rData1 = ""; foreach (int dec in WResult1) { rData1 += dec.ToString("X4").Substring(2, 2) + dec.ToString("X4").Substring(0, 2); } rData1 = Encoding.ASCII.GetString(StringToByteArray(rData1)).Trim('\0'); //On_Connection_Message(rData1); ThreadPool.QueueUserWorkItem(new WaitCallback(On_Connection_Message), rData1); } if (RecieveIndex_2 != WResult[1]) { RecieveIndex_2 = WResult[1]; int[] WResult1 = new int[90]; PLC.ReadDeviceBlock(PlcDeviceType.D, 25616, 90, WResult1); string rData2 = ""; foreach (int dec in WResult1) { rData2 += dec.ToString("X4").Substring(2, 2) + dec.ToString("X4").Substring(0, 2); } rData2 = Encoding.ASCII.GetString(StringToByteArray(rData2)).Trim('\0'); //On_Connection_Message(rData2); ThreadPool.QueueUserWorkItem(new WaitCallback(On_Connection_Message), rData2); } if (!Target.GetIO("OUTPUT").SequenceEqual(Target.GetIO("OUTPUT_OLD"))) { Dictionary <int, byte> changedList = new Dictionary <int, byte>(); for (int i = 0; i < Target.GetIO("OUTPUT").Length; i++) { if (Target.GetIO("OUTPUT")[i] != Target.GetIO("OUTPUT_OLD")[i]) { changedList.Add(i + AddrOffset, Target.GetIO("OUTPUT")[i]); //_TaskReport.On_Message_Log("IO", "Y Area [" + (i + AddrOffset).ToString("X4") + "] " + Target.GetIO("OUTPUT_OLD")[i] + "->" + Target.GetIO("OUTPUT")[i]); Target.SetIO("OUTPUT_OLD", i, Target.GetIO("OUTPUT")[i]); //UpdateUI("OUTPUT", i, Target.GetIO("OUTPUT")[i], Target); _ReportTarget.On_DIO_Data_Chnaged(i.ToString(), Target.GetIO("OUTPUT")[i].ToString(), "OUTPUT"); } } PLC.SetBitDevice(PlcDeviceType.Y, changedList); } PLC.GetBitDevice(PlcDeviceType.X, AddrOffset, 512, result); Target.SetIO("INPUT", result); if (!Target.GetIO("INPUT").SequenceEqual(Target.GetIO("INPUT_OLD"))) { for (int i = 0; i < Target.GetIO("INPUT").Length; i++) { if (Target.GetIO("INPUT")[i] != Target.GetIO("INPUT_OLD")[i]) { //_TaskReport.On_Message_Log("IO", "X Area [" + (i + AddrOffset).ToString("X4") + "] " + Target.GetIO("INPUT_OLD")[i] + "->" + Target.GetIO("INPUT")[i]); //UpdateUI("INPUT", i, Target.GetIO("INPUT")[i], Target); _ReportTarget.On_DIO_Data_Chnaged(i.ToString(), Target.GetIO("INPUT")[i].ToString(), "INPUT"); } } if (Target.GetIO("INPUT")[6 + (CstRobotStation - 1) * 32] == 1 && Target.GetIO("INPUT_OLD")[6 + (CstRobotStation - 1) * 32] == 0) { string errAry = ""; for (int i = 32; i <= 64; i++) { errAry += Target.GetIO("INPUT")[i + (CstRobotStation - 1) * 32].ToString(); } string error = new String(errAry.Reverse().ToArray()); error = Convert.ToInt32(error, 2).ToString("X"); _ReportTarget.On_Alarm_Happen(AlarmManagement.NewAlarm(Target, error, "")); } Target.SetIO("INPUT_OLD", Target.GetIO("INPUT")); } WResult = new int[32]; PLC.ReadDeviceBlock(PlcDeviceType.D, 24576 + 1, 32, WResult); result = ConvertToBit(WResult); Target.SetIO("PRESENCE", result); if (!Target.GetIO("PRESENCE").SequenceEqual(Target.GetIO("PRESENCE_OLD"))) { for (int i = 0; i < Target.GetIO("PRESENCE").Length; i++) { if (Target.GetIO("PRESENCE")[i] != Target.GetIO("PRESENCE_OLD")[i]) { //_TaskReport.On_Message_Log("IO", "X Area [" + (i + AddrOffset).ToString("X4") + "] " + Target.GetIO("INPUT_OLD")[i] + "->" + Target.GetIO("INPUT")[i]); //UpdateUI("PRESENCE", i, Target.GetIO("PRESENCE")[i], Target); _ReportTarget.On_DIO_Data_Chnaged(i.ToString(), Target.GetIO("PRESENCE")[i].ToString(), "PRESENCE"); } } Target.SetIO("PRESENCE_OLD", Target.GetIO("PRESENCE")); } } catch (Exception e) { _ReportTarget.On_Message_Log("IO", "Lost connection with PLC"); SpinWait.SpinUntil(() => false, 5000); try { if (isInit) { PLC.Open(); } } catch (Exception eeee) { _ReportTarget.On_Message_Log("IO", eeee.StackTrace); } } } }
public void On_Command_Excuted(Node Node, Transaction Txn, CommandReturnMessage Msg) { logger.Debug("On_Command_Excuted"); string Message = ""; Transaction SendTxn = new Transaction(); if (Txn.Method == Transaction.Command.LoadPortType.Reset) { AlarmUpdate.UpdateAlarmList(AlarmManagement.GetAll()); } switch (Node.Type) { case "LOADPORT": switch (Txn.Method) { case Transaction.Command.LoadPortType.GetMapping: case Transaction.Command.LoadPortType.Unload: case Transaction.Command.LoadPortType.MappingUnload: case Transaction.Command.LoadPortType.DoorUp: case Transaction.Command.LoadPortType.InitialPos: case Transaction.Command.LoadPortType.ForceInitialPos: WaferAssignUpdate.RefreshMapping(Node.Name); MonitoringUpdate.UpdateNodesJob(Node.Name); RunningUpdate.UpdateNodesJob(Node.Name); break; case Transaction.Command.LoadPortType.GetCassetteSize: ManualPortStatusUpdate.UpdateParameter("CASSETTE_SIZE_tb", Msg.Value); break; case Transaction.Command.LoadPortType.GetSlotOffset: ManualPortStatusUpdate.UpdateParameter("SLOT_OFFSET_tb", Msg.Value); break; case Transaction.Command.LoadPortType.GetWaferOffset: ManualPortStatusUpdate.UpdateParameter("WAFER_OFFSET_tb", Msg.Value); break; case Transaction.Command.LoadPortType.GetTweekDistance: ManualPortStatusUpdate.UpdateParameter("TWEEK_tb", Msg.Value); break; case Transaction.Command.LoadPortType.GetSlotPitch: ManualPortStatusUpdate.UpdateParameter("SLOT_PITCH_tb", Msg.Value); break; } break; case "ROBOT": switch (Txn.Method) { case Transaction.Command.RobotType.GetMapping: WaferAssignUpdate.RefreshMapping(Node.CurrentPosition); MonitoringUpdate.UpdateNodesJob(Node.CurrentPosition); RunningUpdate.UpdateNodesJob(Node.CurrentPosition); break; } break; } switch (Txn.FormName) { case "FormStatus": Util.StateUtil.UpdateSTS(Node.Name, Msg.Value); break; case "PauseProcedure": break; case "FormManual": switch (Node.Type) { case "SMARTTAG": if (!Txn.Method.Equals(Transaction.Command.SmartTagType.GetLCDData)) { //ManualPortStatusUpdate.LockUI(false); } break; case "LOADPORT": if (!Txn.CommandType.Equals("MOV") && !Txn.CommandType.Equals("HCS")) { //ManualPortStatusUpdate.LockUI(false); } else { if (Txn.Method.Equals(Transaction.Command.LoadPortType.Reset)) { // ManualPortStatusUpdate.LockUI(false); } } ManualPortStatusUpdate.UpdateLog(Node.Name, Msg.Command + " Excuted"); switch (Txn.Method) { case Transaction.Command.LoadPortType.ReadVersion: ManualPortStatusUpdate.UpdateVersion(Node.Name, Msg.Value); break; case Transaction.Command.LoadPortType.GetLED: ManualPortStatusUpdate.UpdateLED(Node.Name, Msg.Value); break; case Transaction.Command.LoadPortType.ReadStatus: ManualPortStatusUpdate.UpdateSmifStatus(Node.Name, Msg.Value); break; case Transaction.Command.LoadPortType.GetCount: break; case Transaction.Command.LoadPortType.GetMapping: ManualPortStatusUpdate.UpdateMapping(Node.Name, Msg.Value); break; } break; case "OCR": switch (Txn.Method) { case Transaction.Command.OCRType.GetOnline: //OCRUpdate.UpdateOCRStatus(Node.Name, Msg.Value); break; } break; case "ROBOT": switch (Txn.Method) { case Transaction.Command.RobotType.Speed: case Transaction.Command.RobotType.Mode: case Transaction.Command.RobotType.Reset: case Transaction.Command.RobotType.Servo: ManualRobotStatusUpdate.UpdateGUI(Txn, Node.Name, Msg.Value); //update 手動功能畫面 break; case Transaction.Command.RobotType.GetSpeed: case Transaction.Command.RobotType.GetRIO: case Transaction.Command.RobotType.GetError: case Transaction.Command.RobotType.GetMode: case Transaction.Command.RobotType.GetStatus: case Transaction.Command.RobotType.GetSV: ManualRobotStatusUpdate.UpdateGUI(Txn, Node.Name, Msg.Value); //update 手動功能畫面 break; case Transaction.Command.RobotType.GetCombineStatus: ManualRobotStatusUpdate.UpdateGUI(Txn, Node.Name, Msg.Command); //update 手動功能畫面 break; } break; case "ALIGNER": switch (Txn.Method) { case Transaction.Command.AlignerType.Speed: case Transaction.Command.AlignerType.Mode: case Transaction.Command.AlignerType.Reset: case Transaction.Command.AlignerType.Servo: //Thread.Sleep(500); ////向Aligner 詢問狀態 //Node aligner = NodeManagement.Get(Node.Name); //String script_name = aligner.Brand.ToUpper().Equals("SANWA") ? "AlignerStateGet" : "AlignerStateGet(Kawasaki)"; ////aligner.ExcuteScript(script_name, "FormManual", out Message); //ManualAlignerStatusUpdate.UpdateGUI(Txn, Node.Name, Msg.Value);//update //break; case Transaction.Command.AlignerType.GetMode: case Transaction.Command.AlignerType.GetSV: case Transaction.Command.AlignerType.GetStatus: case Transaction.Command.AlignerType.GetSpeed: case Transaction.Command.AlignerType.GetRIO: case Transaction.Command.AlignerType.GetError: ManualAlignerStatusUpdate.UpdateGUI(Txn, Node.Name, Msg.Value); //update 手動功能畫面 break; case Transaction.Command.RobotType.GetCombineStatus: ManualAlignerStatusUpdate.UpdateGUI(Txn, Node.Name, Msg.Command); //update 手動功能畫面 break; } break; } break; default: break; } }
private void FormAlarmHis_Load(object sender, EventArgs e) { From.Value = DateTime.Now.AddDays(-1); To.Value = DateTime.Now; AlarmUpdate.UpdateAlarmHistory(AlarmManagement.GetHistory(From.Value, To.Value)); }
public static void UpdateCurrentState(string State) { try { Form form = Application.OpenForms["FormMain"]; if (form == null) { return; } Button state_btn = form.Controls.Find("CurrentState_btn", true).FirstOrDefault() as Button; if (state_btn == null) { return; } if (state_btn.InvokeRequired) { UpdateState ph = new UpdateState(UpdateCurrentState); state_btn.BeginInvoke(ph, State); } else { if (SignalSetting == null) { InitialSetting(); } state_btn.Text = State; Dictionary <string, string> Params = new Dictionary <string, string>(); var findSetting = from Setting in SignalSetting where Setting.Eqp_Status.Equals(State.ToUpper()) && Setting.Is_Alarm == (AlarmManagement.GetAll().Count != 0) select Setting; if (findSetting.Count() != 0) { Setting each = findSetting.First(); if (!each.Blue.Equals("BLINK")) { Params.Add("BLUE", each.Blue); } else { RouteControl.Instance.DIO.SetBlink("BLUE", "True"); } if (!each.Green.Equals("BLINK")) { Params.Add("GREEN", each.Green); } else { RouteControl.Instance.DIO.SetBlink("GREEN", "True"); } if (!each.Red.Equals("BLINK")) { Params.Add("RED", each.Red); } else { RouteControl.Instance.DIO.SetBlink("RED", "True"); } if (!each.Orange.Equals("BLINK")) { Params.Add("ORANGE", each.Orange); } else { RouteControl.Instance.DIO.SetBlink("ORANGE", "True"); } RouteControl.Instance.DIO.SetIO(Params); } } } catch (Exception e) { logger.Error("UpdateCurrentState: Update fail.:" + e.StackTrace); } }