Пример #1
0
        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;
            }
        }
        private void ReadInputDataXML(ref SafetySensorData temp, XmlElement element)
        {
            bool            a         = true;
            bool            readLevel = false;
            EnumSafetyLevel level     = EnumSafetyLevel.Normal;

            bool   readTag = false;
            string tag     = "";

            foreach (XmlNode item in element.ChildNodes)
            {
                switch (item.Name)
                {
                case "MIPCTagName":
                    if (localData.MIPCData.AllDataByMIPCTagName.ContainsKey(item.InnerText))
                    {
                        tag     = item.InnerText;
                        readTag = true;
                    }
                    else
                    {
                        WriteLog(1, "", String.Concat("Tag : ", item.InnerText, " not find in AllDataByMIPCTagName"));
                    }

                    break;

                case "SafetyLevel":
                    if (Enum.TryParse(item.InnerText, out level))
                    {
                        readLevel = true;
                    }
                    else
                    {
                        WriteLog(3, "", String.Concat("無此SafetyLevel : ", item.InnerText));
                    }

                    break;

                case "AB":
                    if (item.InnerText == "B")
                    {
                        a = false;
                    }

                    break;

                default:
                    break;
                }
            }

            if (readTag && readLevel)
            {
                temp.InputSafetyLevelList.Add(level);
                temp.MIPCTagNmaeInput.Add(tag);
                temp.ABList.Add(a);
            }
        }
        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;
            }
        }
Пример #5
0
 public void ByPassBySafetyLevel(EnumSafetyLevel byPassLevel)
 {
 }