Example #1
0
        public OperateResult Write(FanucRobotDataConfig dataConfig, string dataValue)
        {
            try
            {
                var ret = false;
                switch (dataConfig.DataType)
                {
                case FanucRobotDataTypeEnum.DI:
                    bool bTemp;
                    ret = bool.TryParse(dataValue, out bTemp);
                    if (ret == true)
                    {
                        ret = WriteDI(dataConfig.DataAdr, bTemp);
                    }
                    break;

                case FanucRobotDataTypeEnum.GI:
                    ushort iTemp;
                    ret = ushort.TryParse(dataValue, out iTemp);
                    if (ret == true)
                    {
                        ret = WriteGI(dataConfig.DataAdr, iTemp);
                    }
                    break;

                default:
                    break;
                }

                if (ret == false)
                {
                    return(new OperateResult <string>("机器人通讯写入信号失败"));
                }

                return(OperateResult.CreateSuccessResult());
            }
            catch
            {
                return(new OperateResult <string>("机器人通讯写入信号发生致命错误"));
            }
        }
Example #2
0
        public OperateResult <string> Read(FanucRobotDataConfig dataConfig)
        {
            OperateResult <string> isRead = new OperateResult <string> {
                IsSuccess = false
            };

            try
            {
                bool ret = false;
                switch (dataConfig.DataType)
                {
                case FanucRobotDataTypeEnum.DI:
                    bool bTemp = false;
                    ret = ReadDI(dataConfig.DataAdr, ref bTemp);
                    if (ret == true)
                    {
                        isRead.IsSuccess = true;
                        isRead.Content   = bTemp.ToString();
                    }
                    break;

                case FanucRobotDataTypeEnum.DO:
                    bTemp = false;
                    ret   = ReadDO(dataConfig.DataAdr, ref bTemp);
                    if (ret == true)
                    {
                        isRead.IsSuccess = true;
                        isRead.Content   = bTemp.ToString();
                    }
                    break;

                case FanucRobotDataTypeEnum.GI:
                    ushort iTemp = 0;
                    ret = ReadGI(dataConfig.DataAdr, ref iTemp);
                    if (ret == true)
                    {
                        isRead.IsSuccess = true;
                        isRead.Content   = iTemp.ToString();
                    }
                    break;

                case FanucRobotDataTypeEnum.GO:
                    iTemp = 0;
                    ret   = ReadGO(dataConfig.DataAdr, ref iTemp);
                    if (ret == true)
                    {
                        isRead.IsSuccess = true;
                        isRead.Content   = iTemp.ToString();
                    }
                    break;

                default:
                    break;
                }

                return(isRead);
            }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
            catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
            {
                return(new OperateResult <string>("机器人读取信号发生致命错误"));
            }
        }