private void SetLabelTextAndColor(Label label, EnumSafetyLevel type) { label.Text = type.ToString(); switch (type) { case EnumSafetyLevel.Alarm: case EnumSafetyLevel.EMO: case EnumSafetyLevel.IPCEMO: label.ForeColor = Color.DarkRed; break; case EnumSafetyLevel.EMS: case EnumSafetyLevel.SlowStop: label.ForeColor = Color.Red; break; case EnumSafetyLevel.LowSpeed_Low: label.ForeColor = Color.OrangeRed; break; case EnumSafetyLevel.LowSpeed_High: label.ForeColor = Color.Yellow; break; default: label.ForeColor = Color.Green; break; } }
public void ByPassBySafetyLevel(EnumSafetyLevel byPassLevel) { switch (byPassLevel) { case EnumSafetyLevel.Alarm: if (!localData.MIPCData.AllByPassLevel.ContainsKey(byPassLevel)) { localData.MIPCData.AllByPassLevel.Add(byPassLevel, 0); SendAlarmCode(EnumMIPCControlErrorCode.SensorSafety_AlarmByPass); } break; case EnumSafetyLevel.IPCEMO: if (!localData.MIPCData.AllByPassLevel.ContainsKey(byPassLevel)) { localData.MIPCData.AllByPassLevel.Add(byPassLevel, 0); SendAlarmCode(EnumMIPCControlErrorCode.SensorSafety_IPCEMOByPass); } break; case EnumSafetyLevel.EMS: if (!localData.MIPCData.AllByPassLevel.ContainsKey(byPassLevel)) { localData.MIPCData.AllByPassLevel.Add(byPassLevel, 0); SendAlarmCode(EnumMIPCControlErrorCode.SensorSafety_EMSByPass); } break; case EnumSafetyLevel.SlowStop: if (!localData.MIPCData.AllByPassLevel.ContainsKey(byPassLevel)) { localData.MIPCData.AllByPassLevel.Add(byPassLevel, 0); SendAlarmCode(EnumMIPCControlErrorCode.SensorSafety_SlowStopByPass); } break; default: WriteLog(5, "", String.Concat("無Bypass ", byPassLevel.ToString(), " 的功能")); break; } }
public void UpdateAllSafetySensor() { #region SafetySensor區域設定. EnumMovingDirection tempDirection = localData.MIPCData.MoveControlDirection; switch (tempDirection) { case EnumMovingDirection.Front: if (localData.MIPCData.BypassFront) { tempDirection = EnumMovingDirection.None; } break; case EnumMovingDirection.Back: if (localData.MIPCData.BypassBack) { tempDirection = EnumMovingDirection.None; } break; case EnumMovingDirection.Left: if (localData.MIPCData.BypassLeft) { tempDirection = EnumMovingDirection.None; } break; case EnumMovingDirection.Right: if (localData.MIPCData.BypassRight) { tempDirection = EnumMovingDirection.None; } break; case EnumMovingDirection.FrontLeft: if (localData.MIPCData.BypassFront && localData.MIPCData.BypassLeft) { tempDirection = EnumMovingDirection.None; } else if (localData.MIPCData.BypassFront) { tempDirection = EnumMovingDirection.Left; } else if (localData.MIPCData.BypassLeft) { tempDirection = EnumMovingDirection.Front; } break; case EnumMovingDirection.FrontRight: if (localData.MIPCData.BypassFront && localData.MIPCData.BypassRight) { tempDirection = EnumMovingDirection.None; } else if (localData.MIPCData.BypassFront) { tempDirection = EnumMovingDirection.Right; } else if (localData.MIPCData.BypassRight) { tempDirection = EnumMovingDirection.Front; } break; case EnumMovingDirection.BackLeft: if (localData.MIPCData.BypassBack && localData.MIPCData.BypassLeft) { tempDirection = EnumMovingDirection.None; } else if (localData.MIPCData.BypassBack) { tempDirection = EnumMovingDirection.Left; } else if (localData.MIPCData.BypassLeft) { tempDirection = EnumMovingDirection.Back; } break; case EnumMovingDirection.BackRight: if (localData.MIPCData.BypassBack && localData.MIPCData.BypassRight) { tempDirection = EnumMovingDirection.None; } else if (localData.MIPCData.BypassBack) { tempDirection = EnumMovingDirection.Right; } else if (localData.MIPCData.BypassRight) { tempDirection = EnumMovingDirection.Back; } break; default: break; } if (tempDirection != lastDirection) { WriteLog(7, "", String.Concat("MovingDirection : ", lastDirection.ToString(), " change to ", tempDirection.ToString())); for (int i = 0; i < AllSafetySensor.Count; i++) { AllSafetySensor[i].ChangeMovingDirection(lastDirection); } lastDirection = tempDirection; } #endregion uint tempStatus = 0; for (int i = 0; i < AllSafetySensor.Count; i++) { AllSafetySensor[i].UpdateStatus(); tempStatus = tempStatus | AllSafetySensor[i].Status; } AllStatus = tempStatus; EnumSafetyLevel newLevel = EnumSafetyLevel.Normal; for (int i = safetyLevelCount - 1; i >= 0; i--) { if ((tempStatus & (1 << i)) != 0 && ((EnumSafetyLevel)i) != EnumSafetyLevel.Warn) { newLevel = ((EnumSafetyLevel)i); break; } } if (newLevel != localData.MIPCData.safetySensorStatus) { if (newLevel == EnumSafetyLevel.IPCEMO) { WriteLog(7, "", String.Concat("動力電斷電")); mipcControl.SendMIPCDataByIPCTagName(new List <EnumMecanumIPCdefaultTag>() { EnumMecanumIPCdefaultTag.MIPCReady }, new List <float>() { 0 }); } WriteLog(7, "", String.Concat("safetySensorStatus 從 ", localData.MIPCData.safetySensorStatus.ToString(), " 切換至 ", newLevel.ToString())); localData.MIPCData.SafetySensorStatus = newLevel; } }