示例#1
0
        public bool GetInfo()
        {
            lock (this)
            {
                if (!this.Plc.IsPingSuccess)
                {
                    this.Plc.IsAlive = false;
                    LogHelper.WriteError("无法连接到 " + this.Plc.IP);
                    return(false);
                }

                string msg = string.Empty;
                try
                {
                    var bOutputs0 = new ushort[] { };
                    if (!this.Plc.GetInfo(true, "D3000", (ushort)999, out bOutputs0, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                        return(false);
                    }

                    for (int j = 0; j < this.Floors.Count; j++)
                    {
                        switch (bOutputs0[209 - j * 104])
                        {
                        case 1: this.Floors[j].DoorStatusNotFinal = DoorStatus.关闭; this.Floors[j].DoorIsClosing = false; break;

                        case 2: this.Floors[j].DoorStatusNotFinal = DoorStatus.打开; this.Floors[j].DoorIsOpenning = false; break;

                        default: this.Floors[j].DoorStatusNotFinal = DoorStatus.异常; break;
                        }

                        for (int k = 0; k < this.Floors[j].Stations.Count; k++)
                        {
                            if (bOutputs0[210 - j * 104 + k] == 1)
                            {
                                if (this.Floors[j].Stations[k].Id == Current.Task.FromStationId && Current.Task.Status == TaskStatus.正取)
                                {
                                }
                                else
                                {
                                    this.Floors[j].Stations[k].ClampStatus = this.Floors[j].Stations[k].ClampStatus == ClampStatus.空夹具 ? ClampStatus.空夹具 : ClampStatus.满夹具;
                                }
                            }
                            else
                            {
                                this.Floors[j].Stations[k].ClampStatus = ClampStatus.无夹具;
                            }
                        }

                        this.Floors[j].IsNetControlOpen = bOutputs0[692 - 44 * j] == 0;

                        this.Floors[j].ProcessTemperSet  = bOutputs0[463 - 36 * j] / 10;
                        this.Floors[j].PreheatTimeSet    = bOutputs0[465 - 36 * j];
                        this.Floors[j].BakingTimeSet     = bOutputs0[466 - 36 * j];
                        this.Floors[j].BreathingCycleSet = bOutputs0[474 - 36 * j];

                        this.Floors[j].RunMinutes = bOutputs0[687 - 44 * j];
                        this.Floors[j].Vacuum     = bOutputs0[689 - 44 * j] + bOutputs0[690 - 44 * j] * 65535;
                        this.Floors[j].IsVacuum   = this.Floors[j].Vacuum < Current.option.VacuumStandard;

                        if (j == 0)
                        {
                            switch (bOutputs0[693])
                            {
                            case 1: this.TriLamp = TriLamp.Red; break;

                            case 2: this.TriLamp = TriLamp.Yellow; break;

                            case 3: this.TriLamp = TriLamp.Green; break;

                            default: this.TriLamp = TriLamp.Unknown; break;
                            }
                        }

                        var output = OmronPLC.GetBitStr(bOutputs0[250 - 104 * j], 8);
                        this.Floors[j].IsBaking = bOutputs0[688 - 44 * j] == 1 || output.Substring(2, 1) == "1" && output.Substring(3, 1) == "1";
                    }


                    var bOutputs1 = new ushort[] { };
                    if (!this.Plc.GetInfo(true, "D3500", (ushort)999, out bOutputs1, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                        return(false);
                    }

                    for (int j = 0; j < this.Floors.Count; j++)
                    {
                        for (int n = 0; n < Option.TemperaturePointCount; n++)
                        {
                            this.Floors[j].Stations[0].Temperatures[n] = bOutputs1[587 - 128 * j + n] / 10f;
                        }
                        for (int n = 0; n < Option.TemperaturePointCount; n++)
                        {
                            this.Floors[j].Stations[1].Temperatures[n] = bOutputs1[651 - 128 * j + n] / 10f;
                        }
                    }

                    #region 报警信息


                    if (this.TriLamp == TriLamp.Red)
                    {
                        var bOutputs2 = new ushort[] { };
                        if (!this.Plc.GetInfo(true, "D4600", (ushort)400, out bOutputs2, out msg))
                        {
                            Error.Alert(msg);
                            this.Plc.IsAlive = false;
                            return(false);
                        }

                        StringBuilder sb = new StringBuilder();
                        for (int n = 0; n < bOutputs2.Length; n++)
                        {
                            sb.Append(_Convert.Revert(OmronPLC.GetBitStr(bOutputs2[n], 16)));
                        }

                        this.Alarm2BinString = sb.ToString();
                    }
                    else
                    {
                        this.Alarm2BinString = new String('0', 6400);
                    }


                    if (this.Alarm2BinString != this.PreAlarm2BinString)
                    {
                        this.AlarmStr = string.Empty;
                        for (int j = 0; j < this.Floors.Count; j++)
                        {
                            this.Floors[j].AlarmStr = string.Empty;
                        }

                        List <AlarmLog> alarmLogs = new List <AlarmLog>();

                        for (int x = 0; x < this.Alarm2BinString.Length; x++)
                        {
                            if (x > Alarm.Alarms.Count - 1)
                            {
                                break;
                            }
                            char c    = this.Alarm2BinString[x];
                            char cPre = this.PreAlarm2BinString.Length < this.Alarm2BinString.Length ? '0' : this.PreAlarm2BinString[x];
                            if (c == '1')
                            {
                                Alarm alarm = (from a in Alarm.Alarms where a.Id == x + 1 select a).ToList()[0];
                                if (alarm.FloorNum == 0)
                                {
                                    if (cPre == '0')
                                    {
                                        AlarmLog.Stop(AlarmType.Oven, x + 1, this.Id, out msg);
                                    }
                                }
                                else if (alarm.FloorNum > 0 && alarm.FloorNum <= this.Floors.Count)
                                {
                                    this.Floors[alarm.FloorNum - 1].AlarmStr += alarm.AlarmStr + ",";

                                    if (cPre == '0')
                                    {
                                        AlarmLog alarmLog = new AlarmLog();
                                        alarmLog.AlarmId   = x + 1;
                                        alarmLog.AlarmType = AlarmType.Floor;
                                        alarmLog.TypeId    = this.Floors[alarm.FloorNum - 1].Id;
                                        alarmLog.Clamp1Id  = this.Floors[alarm.FloorNum - 1].Stations[0].ClampId > 0 ? this.Floors[alarm.FloorNum - 1].Stations[0].ClampId : 60;
                                        alarmLog.Clamp2Id  = this.Floors[alarm.FloorNum - 1].Stations[1].ClampId > 0 ? this.Floors[alarm.FloorNum - 1].Stations[1].ClampId : 60;
                                        alarmLogs.Add(alarmLog);
                                    }
                                }
                            }
                            else if (c == '0')
                            {
                                Alarm alarm = (from a in Alarm.Alarms where a.Id == x + 1 select a).ToList()[0];
                                if (alarm.FloorNum == 0)
                                {
                                    this.AlarmStr += alarm.AlarmStr + ",";
                                    if (cPre == '1')
                                    {
                                        AlarmLog alarmLog = new AlarmLog();
                                        alarmLog.AlarmId   = x + 1;
                                        alarmLog.AlarmType = AlarmType.Oven;
                                        alarmLog.TypeId    = this.Id;
                                        alarmLogs.Add(alarmLog);
                                    }
                                }
                                else if (alarm.FloorNum > 0 && alarm.FloorNum <= this.Floors.Count)
                                {
                                    if (cPre == '1')
                                    {
                                        AlarmLog.Stop(AlarmType.Floor, x + 1, this.Floors[alarm.FloorNum - 1].Id, out msg);
                                    }
                                }
                            }
                        }

                        if (!AlarmLog.Add(alarmLogs, out msg))
                        {
                            Error.Alert(msg);
                        }
                    }

                    this.PreAlarm2BinString = this.Alarm2BinString;

                    #endregion

                    #region 写指令 控制开关门、启动运行、抽破真空
                    for (int j = 0; j < this.Floors.Count; j++)
                    {
                        if (this.Floors[j].DoorIsOpenning && this.Floors[j].DoorStatusNotFinal != DoorStatus.打开)
                        {
                            this.Floors[j].DoorStatus = DoorStatus.正在打开;
                        }
                        else if (this.Floors[j].DoorIsClosing && this.Floors[j].DoorStatusNotFinal != DoorStatus.关闭)
                        {
                            this.Floors[j].DoorStatus = DoorStatus.正在关闭;
                        }
                        else
                        {
                            this.Floors[j].DoorStatus = this.Floors[j].DoorStatusNotFinal;
                        }

                        #region 控制开门
                        if (this.Floors[j].DoorStatus == DoorStatus.打开)
                        {
                            this.Floors[j].toOpenDoor = false;
                        }

                        if (this.Floors[j].toOpenDoor)
                        {
                            var addr = Current.option.OvenOpenDoorAddrVals.Split(',')[j].Split(':')[0];
                            var val  = Convert.ToUInt16(Current.option.OvenOpenDoorAddrVals.Split(',')[j].Split(':')[1]);

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }
                            LogHelper.WriteInfo(string.Format("成功发送开门指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenOpenDoorAddrVals.Split(',')[j]));
                            this.Floors[j].toOpenDoor     = false;
                            this.Floors[j].DoorIsOpenning = true;
                        }
                        #endregion

                        #region 控制关门
                        if (this.Floors[j].DoorStatus == DoorStatus.关闭)
                        {
                            this.Floors[j].toCloseDoor = false;
                        }

                        if (this.Floors[j].toCloseDoor)
                        {
                            //关门前判断该处有无任务

                            // cannotClose : 不能关门
                            bool cannotClose = false;
                            if (this.Floors[j].Stations.Count(s => s.Id == Current.Task.FromStationId) > 0 && (Current.Task.Status == TaskStatus.就绪 || Current.Task.Status == TaskStatus.可取 || Current.Task.Status == TaskStatus.正取))
                            {
                                Tip.Alert(Current.Task.FromStationName + "正在取盘,无法关门!");
                                cannotClose = true;
                            }

                            if (!cannotClose)
                            {
                                if (this.Floors[j].Stations.Count(s => s.Id == Current.Task.ToStationId) > 0 && (Current.Task.Status == TaskStatus.可放 || Current.Task.Status == TaskStatus.正放))
                                {
                                    Tip.Alert(Current.Task.FromStationName + "正在放盘,无法关门!");
                                    cannotClose = true;
                                }
                            }

                            if (cannotClose)
                            {
                                this.Floors[j].toCloseDoor = false;
                            }
                            else
                            {
                                var addr = Current.option.OvenCloseDoorAddrVals.Split(',')[j].Split(':')[0];
                                var val  = Convert.ToUInt16(Current.option.OvenCloseDoorAddrVals.Split(',')[j].Split(':')[1]);

                                if (!this.Plc.SetInfo(addr, val, out msg))
                                {
                                    Error.Alert(msg);
                                    this.Plc.IsAlive = false;
                                    return(false);
                                }

                                LogHelper.WriteInfo(string.Format("成功发送关门指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenCloseDoorAddrVals.Split(',')[j]));
                                this.Floors[j].toCloseDoor        = false;
                                this.Floors[j].DoorIsClosing      = true;
                                this.Floors[j].DoorStatusNotFinal = DoorStatus.正在关闭;
                                this.Floors[j].DoorStatus         = DoorStatus.正在关闭;
                            }
                        }
                        #endregion

                        #region 启动运行
                        if (this.Floors[j].toStartBaking)
                        {
                            var addr = Current.option.OvenStartBakingAddrVals.Split(',')[j].Split(':')[0];
                            var val  = Convert.ToUInt16(Current.option.OvenStartBakingAddrVals.Split(',')[j].Split(':')[1]);

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }

                            LogHelper.WriteInfo(string.Format("成功发送启动运行指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenStartBakingAddrVals.Split(',')[j]));
                            this.Floors[j].toStartBaking = false;
                        }
                        #endregion

                        #region 结束运行
                        if (this.Floors[j].toStopBaking)
                        {
                            var addr = Current.option.OvenStopBakingAddrVals.Split(',')[j].Split(':')[0];
                            var val  = Convert.ToUInt16(Current.option.OvenStopBakingAddrVals.Split(',')[j].Split(':')[1]);

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }

                            LogHelper.WriteInfo(string.Format("成功发送停止运行指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenStopBakingAddrVals.Split(',')[j]));
                            this.Floors[j].toStopBaking = false;
                        }
                        #endregion

                        #region 开启网控

                        #endregion

                        #region 报警复位
                        if (this.Floors[j].toAlarmReset)
                        {
                            if (!this.Plc.SetInfo("D5303", (ushort)1, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }

                            LogHelper.WriteInfo(string.Format("成功发送报警复位指令到{0}:{1}", this.Name, "D5303"));
                            this.Floors[j].toAlarmReset = false;
                        }
                        #endregion

                        #region 抽真空
                        if (this.Floors[j].toLoadVacuum)
                        {
                            var addr = Current.option.OvenLoadVacuumAddrVals.Split(',')[j].Split(':')[0];
                            var val  = Convert.ToUInt16(Current.option.OvenLoadVacuumAddrVals.Split(',')[j].Split(':')[1]);

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }

                            LogHelper.WriteInfo(string.Format("成功发送抽真空指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenLoadVacuumAddrVals.Split(',')[j]));
                            this.Floors[j].toLoadVacuum = false;
                        }
                        #endregion

                        #region 停止抽真空
                        if (this.Floors[j].toCancelLoadVacuum)
                        {
                            var addr = Current.option.OvenStopLoadVacuumAddrVals.Split(',')[j].Split(':')[0];
                            var val  = Convert.ToUInt16(Current.option.OvenStopLoadVacuumAddrVals.Split(',')[j].Split(':')[1]);

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }

                            LogHelper.WriteInfo(string.Format("成功发送取消抽真空指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenStopLoadVacuumAddrVals.Split(',')[j]));
                            this.Floors[j].toCancelLoadVacuum = false;
                        }
                        #endregion

                        #region 破真空
                        if (this.Floors[j].toUploadVacuum)
                        {
                            var addr = Current.option.OvenUploadVacuumAddrVals.Split(',')[j].Split(':')[0];
                            var val  = Convert.ToUInt16(Current.option.OvenUploadVacuumAddrVals.Split(',')[j].Split(':')[1]);

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }
                            LogHelper.WriteInfo(string.Format("成功发送破真空指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenUploadVacuumAddrVals.Split(',')[j]));
                            this.Floors[j].toUploadVacuum = false;
                        }
                        #endregion

                        #region 停止破真空
                        if (this.Floors[j].toCancelUploadVacuum)
                        {
                            var addr = Current.option.OvenStopUploadVacuumAddrVals.Split(',')[j].Split(':')[0];
                            var val  = Convert.ToUInt16(Current.option.OvenStopUploadVacuumAddrVals.Split(',')[j].Split(':')[1]);

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }
                            LogHelper.WriteInfo(string.Format("成功发送取消破真空指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenStopUploadVacuumAddrVals.Split(',')[j]));
                            this.Floors[j].toCancelUploadVacuum = false;
                        }
                        #endregion

                        #region 运行时间清零

                        #endregion
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    Error.Alert(ex);
                }

                this.Plc.IsAlive = true;

                this.getInfoNum++;
                if (getInfoNum >= 2)
                {
                    this.AlreadyGetAllInfo = true;
                }
                this.getInfoNum %= 2;
            }
            return(true);
        }
示例#2
0
        public bool GetInfo()
        {
            if (!this.Plc.IsPingSuccess)
            {
                this.Plc.IsAlive = false;
                LogHelper.WriteError("无法连接到 " + this.Plc.IP);
                return(false);
            }

            var bOutputs = new ushort[] { };

            if (!this.Plc.GetInfo("D1000", (ushort)100, out bOutputs, out string msg))
            {
                Error.Alert(msg);
                this.Plc.IsAlive = false;
                return(false);
            }

            //心跳
            if (bOutputs[0] == 0)
            {
                this.Plc.SetInfo("D1000", (ushort)1, out msg);
            }

            //手动自动信号
            this.IsAuto = bOutputs[6] == 1;

            this.IsAlreadyHasTask = bOutputs[8] > 0 || bOutputs[9] > 0;

            //报警
            this.IsAlarming = bOutputs[11] == 1 || bOutputs[60] == 4;
            //this.AlarmStr = this.IsAlarming ? this.name + "异常中" : "";

            //有无料
            //switch (bOutputs[12])
            //{
            //    case 1: this.ClampStatus = this.ClampStatus == ClampStatus.空夹具 ? ClampStatus.空夹具 : ClampStatus.满夹具; break;
            //    case 0: this.ClampStatus = ClampStatus.无夹具; break;
            //    case 3: this.ClampStatus = ClampStatus.异常; break;
            //    default: this.ClampStatus = ClampStatus.未知; break;
            //}

            //调度有效
            this.IsDispatchEnabled = bOutputs[13] == 1;

            //任务完成
            var isTaskFinished = bOutputs[15] == 1;

            if (isTaskFinished && !this.IsTaskFinished)
            {
                LogHelper.WriteInfo(string.Format("收到{0}取盘/放盘完成信号,{1}:{2}", this.Plc.Name, "D1015", 1));
            }
            this.IsTaskFinished = isTaskFinished;

            //货叉原点
            var isForkAtOriginalPoint = bOutputs[22] == 1;

            if (isForkAtOriginalPoint && !this.IsForkAtOriginalPoint)
            {
                LogHelper.WriteInfo(string.Format("收到{0}货叉回到原点信号,{1}:{2}", this.Plc.Name, "D1021", 1));
            }
            this.IsForkAtOriginalPoint = isForkAtOriginalPoint;

            //X轴位置
            this.CoordinateValue = bOutputs[20];
            if (this.CoordinateValue > 0)
            {
                if (this.CoordinateValue < this.PreCoordinateValue)
                {
                    this.MovingDirection = MovingDirection.前进; this.IsMoving = true;
                }
                else if (this.CoordinateValue > this.PreCoordinateValue)
                {
                    this.MovingDirection = MovingDirection.后退; this.IsMoving = true;
                }
                else
                {
                    this.MovingDirection = MovingDirection.停止; this.IsMoving = false;
                }
                this.PreCoordinateValue = this.CoordinateValue;
            }

            //rgv状态
            this.Status = bOutputs[60];

            this.IsReady = this.Status == 2 && this.IsDispatchEnabled && this.IsAuto;

            if (this.IsAlarming)
            {
                StringBuilder sb = new StringBuilder();
                for (int n = 30; n < 33; n++)
                {
                    sb.Append(_Convert.Revert(OmronPLC.GetBitStr(bOutputs[n], 16)));
                }

                this.Alarm2BinString = sb.ToString();

                var alarmStr = "";

                for (int x = 0; x < this.Alarms.Length; x++)
                {
                    if (this.Alarm2BinString[x] == '1')
                    {
                        alarmStr += this.Alarms[x] + ",";
                    }
                }
                this.AlarmStr = alarmStr;
            }
            else
            {
                this.AlarmStr = "";
            }

            //D1030.01    PLC异常状态异常
            //D1030.02    EtherNet / IP异常状态异常
            //D1030.03    EthenCAT状态异常
            //D1030.04    PLC总线状态异常
            //D1030.05    行走电机报警
            //D1030.06    升降电机报警
            //D1030.07    货叉电机报警
            //D1030.08    调度心跳报警
            //D1030.09    门号错误
            //D1030.10    行走.货叉同时动作
            //D1030.11    行走电机限位报警
            //D1030.12    升降电机限位报警
            //D1030.13    货叉电机限位报警
            //D1030.14    升降下降超过保护限位
            //D1030.15    货叉不在原点
            //D1031.00    行走安全位.取门号.放门号不能同时给
            //D1031.01    行走位置方向错误
            //D1031.02    升降位置方向错误
            //D1031.03    行走位置错误
            //D1031.04    升降位置错误
            //D1031.05    货叉位置错误

            this.AlreadyGetAllInfo = true;
            this.Plc.IsAlive       = true;
            return(true);
        }
示例#3
0
文件: Oven.cs 项目: jtzhang163/TengDa
        public bool GetInfo()
        {
            lock (this)
            {
                if (!this.Plc.IsPingSuccess)
                {
                    this.Plc.IsAlive = false;
                    LogHelper.WriteError("无法连接到 " + this.Plc.IP);
                    return(false);
                }

                string msg = string.Empty;
                try
                {
                    var bOutputs0 = new ushort[] { };
                    if (!this.Plc.GetInfo(true, "D4000", (ushort)99, out bOutputs0, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                        return(false);
                    }

                    for (int j = 0; j < this.Floors.Count; j++)
                    {
                        switch (bOutputs0[60 + j])
                        {
                        case 0: this.Floors[j].DoorStatusNotFinal = DoorStatus.关闭; this.Floors[j].DoorIsClosing = false; break;

                        case 1: this.Floors[j].DoorStatusNotFinal = DoorStatus.打开; this.Floors[j].DoorIsOpenning = false; break;

                        case 2: this.Floors[j].DoorStatusNotFinal = DoorStatus.异常; break;

                        default: this.Floors[j].DoorStatusNotFinal = DoorStatus.未知; break;
                        }

                        //for (int k = 0; k < this.Floors[j].Stations.Count; k++)
                        //{
                        //    if (bOutputs0[210 - j * 104 + k] == 1)
                        //    {
                        //        if (this.Floors[j].Stations[k].Id == Current.Task.FromStationId && Current.Task.Status == TaskStatus.取放中)
                        //        {

                        //        }
                        //        else
                        //        {
                        //            this.Floors[j].Stations[k].ClampStatus = this.Floors[j].Stations[k].ClampStatus == ClampStatus.空夹具 ? ClampStatus.空夹具 : ClampStatus.满夹具;
                        //        }
                        //    }
                        //    else
                        //    {
                        //        this.Floors[j].Stations[k].ClampStatus = ClampStatus.无夹具;
                        //    }

                        //}

                        //this.Floors[j].IsNetControlOpen = bOutputs0[692 - 44 * j] == 0;

                        //this.Floors[j].ProcessTemperSet = bOutputs0[463 - 36 * j] / 10;
                        //this.Floors[j].PreheatTimeSet = bOutputs0[465 - 36 * j];
                        //this.Floors[j].BakingTimeSet = bOutputs0[466 - 36 * j];
                        //this.Floors[j].BreathingCycleSet = bOutputs0[474 - 36 * j];

                        //this.Floors[j].RunMinutes = bOutputs0[687 - 44 * j];
                        //this.Floors[j].Vacuum = bOutputs0[689 - 44 * j] + bOutputs0[690 - 44 * j] * 65535;
                        //this.Floors[j].IsVacuum = this.Floors[j].Vacuum < Current.option.VacuumStandard;

                        //if (j == 0)
                        //{
                        //    switch (bOutputs0[693])
                        //    {
                        //        case 1: this.TriLamp = TriLamp.Red; break;
                        //        case 2: this.TriLamp = TriLamp.Yellow; break;
                        //        case 3: this.TriLamp = TriLamp.Green; break;
                        //        default: this.TriLamp = TriLamp.Unknown; break;
                        //    }
                        //}

                        //var output = OmronPLC.GetBitStr(bOutputs0[250 - 104 * j], 8);
                        //this.Floors[j].IsBaking = bOutputs0[688 - 44 * j] == 1 || output.Substring(2, 1) == "1" && output.Substring(3, 1) == "1";
                    }

                    this.TriLamp =
                        bOutputs0[70] == 1 ? TriLamp.Green :
                        bOutputs0[70] == 2 ? TriLamp.Yellow :
                        bOutputs0[70] == 3 ? TriLamp.Red : this.TriLamp;

                    var bOutputs1 = new ushort[] { };
                    if (!this.Plc.GetInfo(true, "D0", (ushort)200, out bOutputs1, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                        return(false);
                    }

                    for (int j = 0; j < this.Floors.Count; j++)
                    {
                        for (int n = 0; n < Option.TemperaturePointCount; n++)
                        {
                            this.Floors[j].Temperatures[n] = bOutputs1[temperAddrMatrix[j, n]] / 10f;
                        }
                        this.Floors[j].RunMinutesSet           = bOutputs1[10 + 2 * j];
                        this.Floors[j].RunMinutes              = bOutputs1[20 + 2 * j];
                        this.Floors[j].TemperSetting           = bOutputs1[30 + j] / 10;
                        this.Floors[j].PreHeatTimeSetting      = bOutputs1[100];
                        this.Floors[j].TemperOverOffsetSetting = bOutputs1[102];
                        this.Floors[j].IsAerating              = bOutputs1[81 + j] == 1;
                    }

                    #region 报警信息

                    var bOutputs2 = new ushort[] { };
                    if (!this.Plc.GetInfo(true, "C1000", (ushort)99, out bOutputs2, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                        return(false);
                    }

                    var isFinishBinString = _Convert.Revert(OmronPLC.GetBitStr(bOutputs2[21], 16));
                    for (int j = 0; j < this.Floors.Count; j++)
                    {
                        this.Floors[j].IsBakeFinished = isFinishBinString[j] == '1';
                        this.Floors[j].IsBaking       = isFinishBinString[j + 6] == '1';
                    }


                    //if (this.TriLamp == TriLamp.Red || this.Floors.Count(o => o.IsAerating) > 0)
                    //{
                    var bOutputs3 = new ushort[] { };
                    if (!this.Plc.GetInfo(true, "C1000", (ushort)11, out bOutputs3, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                        return(false);
                    }

                    StringBuilder sb = new StringBuilder();
                    for (int n = 0; n < bOutputs3.Length; n++)
                    {
                        sb.Append(_Convert.Revert(OmronPLC.GetBitStr(bOutputs3[n], 16)));
                    }
                    var alarm2BinString = sb.ToString();

                    char[] chars = alarm2BinString.ToCharArray();
                    for (int j = 0; j < 5; j++)
                    {
                        chars[8 + 32 * j] = this.Floors[j].IsAerating ? '1' : '0';
                    }

                    this.Alarm2BinString = new String(chars);
                    //}
                    //else
                    //{
                    //    this.Alarm2BinString = new String('0', 176);
                    //}


                    if (this.Alarm2BinString != this.PreAlarm2BinString)
                    {
                        this.AlarmStr = string.Empty;
                        for (int j = 0; j < this.Floors.Count; j++)
                        {
                            this.Floors[j].AlarmStr = string.Empty;
                        }

                        List <AlarmLog> alarmLogs = new List <AlarmLog>();

                        for (int x = 0; x < this.Alarm2BinString.Length; x++)
                        {
                            if (x > Alarm.Alarms.Count - 1)
                            {
                                break;
                            }
                            char c    = this.Alarm2BinString[x];
                            char cPre = this.PreAlarm2BinString.Length < this.Alarm2BinString.Length ? '0' : this.PreAlarm2BinString[x];
                            if (c == '1')
                            {
                                Alarm alarm = (from a in Alarm.Alarms where a.Id == x + 1 select a).ToList()[0];
                                if (alarm.FloorNum == 0)
                                {
                                    this.AlarmStr += alarm.AlarmStr + ",";
                                    if (cPre == '0')
                                    {
                                        AlarmLog alarmLog = new AlarmLog();
                                        alarmLog.AlarmId   = x + 1;
                                        alarmLog.AlarmType = AlarmType.Oven;
                                        alarmLog.TypeId    = this.Id;
                                        alarmLogs.Add(alarmLog);
                                    }
                                }
                                else if (alarm.FloorNum > 0 && alarm.FloorNum <= this.Floors.Count)
                                {
                                    this.Floors[alarm.FloorNum - 1].AlarmStr += alarm.AlarmStr + ",";

                                    if (cPre == '0')
                                    {
                                        AlarmLog alarmLog = new AlarmLog();
                                        alarmLog.AlarmId   = x + 1;
                                        alarmLog.AlarmType = AlarmType.Floor;
                                        alarmLog.TypeId    = this.Floors[alarm.FloorNum - 1].Id;
                                        alarmLog.Clamp1Id  = this.Floors[alarm.FloorNum - 1].Stations[0].ClampId > 0 ? this.Floors[alarm.FloorNum - 1].Stations[0].ClampId : 60;
                                        alarmLog.Clamp2Id  = this.Floors[alarm.FloorNum - 1].Stations[1].ClampId > 0 ? this.Floors[alarm.FloorNum - 1].Stations[1].ClampId : 60;
                                        alarmLogs.Add(alarmLog);
                                    }
                                }
                            }
                            else if (c == '0')
                            {
                                Alarm alarm = (from a in Alarm.Alarms where a.Id == x + 1 select a).ToList()[0];
                                if (alarm.FloorNum == 0)
                                {
                                    if (cPre == '1')
                                    {
                                        AlarmLog.Stop(AlarmType.Oven, x + 1, this.Id, out msg);
                                    }
                                }
                                else if (alarm.FloorNum > 0 && alarm.FloorNum <= this.Floors.Count)
                                {
                                    if (cPre == '1')
                                    {
                                        AlarmLog.Stop(AlarmType.Floor, x + 1, this.Floors[alarm.FloorNum - 1].Id, out msg);
                                    }
                                }
                            }
                        }

                        if (!AlarmLog.Add(alarmLogs, out msg))
                        {
                            Error.Alert(msg);
                        }
                    }

                    this.PreAlarm2BinString = this.Alarm2BinString;

                    #endregion

                    var bOutputs4 = new ushort[] { };
                    if (!this.Plc.GetInfo(true, "H0", (ushort)1, out bOutputs4, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                        return(false);
                    }

                    var isNetControlBinString = _Convert.Revert(OmronPLC.GetBitStr(bOutputs4[0], 16));
                    for (int j = 0; j < this.Floors.Count; j++)
                    {
                        this.Floors[j].IsNetControlOpen = isNetControlBinString[j + 1] == '0' && isNetControlBinString[0] == '0';
                    }

                    #region 写指令 控制开关门、启动运行、抽破真空
                    for (int j = 0; j < this.Floors.Count; j++)
                    {
                        if (this.Floors[j].DoorIsOpenning && this.Floors[j].DoorStatusNotFinal != DoorStatus.打开)
                        {
                            this.Floors[j].DoorStatus = DoorStatus.正在打开;
                        }
                        else if (this.Floors[j].DoorIsClosing && this.Floors[j].DoorStatusNotFinal != DoorStatus.关闭)
                        {
                            this.Floors[j].DoorStatus = DoorStatus.正在关闭;
                        }
                        else
                        {
                            this.Floors[j].DoorStatus = this.Floors[j].DoorStatusNotFinal;
                        }

                        #region 控制开门
                        if (this.Floors[j].DoorStatus == DoorStatus.打开)
                        {
                            this.Floors[j].toOpenDoor = false;
                        }

                        if (this.Floors[j].toOpenDoor)
                        {
                            var addr = "D0";
                            var val  = Convert.ToUInt16(2 * (j + 1));

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }
                            LogHelper.WriteInfo(string.Format("成功发送开门指令到{0}, {1}:{2}", this.Floors[j].Name, addr, val));
                            this.Floors[j].toOpenDoor     = false;
                            this.Floors[j].DoorIsOpenning = true;
                        }
                        #endregion

                        #region 控制关门
                        if (this.Floors[j].DoorStatus == DoorStatus.关闭)
                        {
                            this.Floors[j].toCloseDoor = false;
                        }

                        if (this.Floors[j].toCloseDoor)
                        {
                            var addr = "D0";
                            var val  = Convert.ToUInt16(2 * (j + 1) - 1);

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }

                            LogHelper.WriteInfo(string.Format("成功发送关门指令到{0}, {1}:{2}", this.Floors[j].Name, addr, val));
                            this.Floors[j].toCloseDoor   = false;
                            this.Floors[j].DoorIsClosing = true;
                        }
                        #endregion

                        #region 启动运行
                        if (this.Floors[j].toStartBaking)
                        {
                            var addr = "D" + (j + 1);
                            var val  = Convert.ToUInt16(1);

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }

                            LogHelper.WriteInfo(string.Format("成功发送启动运行指令到{0}, {1}:{2}", this.Floors[j].Name, addr, val));
                            this.Floors[j].toStartBaking = false;
                        }
                        #endregion

                        #region 结束运行
                        if (this.Floors[j].toStopBaking)
                        {
                            var addr = "D" + (j + 1);
                            var val  = Convert.ToUInt16(0);

                            if (!this.Plc.SetInfo(addr, val, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }

                            LogHelper.WriteInfo(string.Format("成功发送结束运行指令到{0}, {1}:{2}", this.Floors[j].Name, addr, val));
                            this.Floors[j].toStopBaking = false;
                        }
                        #endregion

                        //    #region 开启网控

                        //    #endregion

                        #region 报警复位
                        if (this.Floors[j].toAlarmReset)
                        {
                            if (!this.Plc.SetInfo("D4071", (ushort)1, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }

                            LogHelper.WriteInfo(string.Format("成功发送报警复位指令到{0}:{1}", this.Name, "D4071"));
                            this.Floors[j].toAlarmReset = false;
                        }
                        #endregion

                        //    #region 抽真空
                        //    if (this.Floors[j].toLoadVacuum)
                        //    {
                        //        var addr = Current.option.OvenLoadVacuumAddrVals.Split(',')[j].Split(':')[0];
                        //        var val = Convert.ToUInt16(Current.option.OvenLoadVacuumAddrVals.Split(',')[j].Split(':')[1]);

                        //        if (!this.Plc.SetInfo(addr, val, out msg))
                        //        {
                        //            Error.Alert(msg);
                        //            this.Plc.IsAlive = false;
                        //            return false;
                        //        }

                        //        LogHelper.WriteInfo(string.Format("成功发送抽真空指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenLoadVacuumAddrVals.Split(',')[j]));
                        //        this.Floors[j].toLoadVacuum = false;
                        //    }
                        //    #endregion

                        //    #region 停止抽真空
                        //    if (this.Floors[j].toCancelLoadVacuum)
                        //    {
                        //        var addr = Current.option.OvenStopLoadVacuumAddrVals.Split(',')[j].Split(':')[0];
                        //        var val = Convert.ToUInt16(Current.option.OvenStopLoadVacuumAddrVals.Split(',')[j].Split(':')[1]);

                        //        if (!this.Plc.SetInfo(addr, val, out msg))
                        //        {
                        //            Error.Alert(msg);
                        //            this.Plc.IsAlive = false;
                        //            return false;
                        //        }

                        //        LogHelper.WriteInfo(string.Format("成功发送取消抽真空指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenStopLoadVacuumAddrVals.Split(',')[j]));
                        //        this.Floors[j].toCancelLoadVacuum = false;
                        //    }
                        //    #endregion

                        //    #region 破真空
                        //    if (this.Floors[j].toUploadVacuum)
                        //    {
                        //        var addr = Current.option.OvenUploadVacuumAddrVals.Split(',')[j].Split(':')[0];
                        //        var val = Convert.ToUInt16(Current.option.OvenUploadVacuumAddrVals.Split(',')[j].Split(':')[1]);

                        //        if (!this.Plc.SetInfo(addr, val, out msg))
                        //        {
                        //            Error.Alert(msg);
                        //            this.Plc.IsAlive = false;
                        //            return false;
                        //        }
                        //        LogHelper.WriteInfo(string.Format("成功发送破真空指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenUploadVacuumAddrVals.Split(',')[j]));
                        //        this.Floors[j].toUploadVacuum = false;
                        //    }
                        //    #endregion

                        //    #region 停止破真空
                        //    if (this.Floors[j].toCancelUploadVacuum)
                        //    {
                        //        var addr = Current.option.OvenStopUploadVacuumAddrVals.Split(',')[j].Split(':')[0];
                        //        var val = Convert.ToUInt16(Current.option.OvenStopUploadVacuumAddrVals.Split(',')[j].Split(':')[1]);

                        //        if (!this.Plc.SetInfo(addr, val, out msg))
                        //        {
                        //            Error.Alert(msg);
                        //            this.Plc.IsAlive = false;
                        //            return false;
                        //        }
                        //        LogHelper.WriteInfo(string.Format("成功发送取消破真空指令到{0}:{1}", this.Floors[j].Name, Current.option.OvenStopUploadVacuumAddrVals.Split(',')[j]));
                        //        this.Floors[j].toCancelUploadVacuum = false;
                        //    }
                        //    #endregion

                        #region 运行时间清零
                        if (this.Floors[j].toClearRunTime)
                        {
                            var addr = "D" + (20 + 2 * j);

                            if (!this.Plc.SetInfo(addr, (ushort)0, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }

                            LogHelper.WriteInfo(string.Format("成功发送运行时间清零指令到{0}:{1}", this.Name, addr));
                            this.Floors[j].toClearRunTime = false;
                        }
                        #endregion

                        #region 开始充氮气
                        if (this.Floors[j].toAerating)
                        {
                            var addr = "D" + (81 + j);
                            if (!this.Plc.SetInfo(addr, (ushort)1, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }
                            LogHelper.WriteInfo(string.Format("成功发送充氮气指令到{0}:{1}", this.Name, addr));
                            this.Floors[j].toAerating = false;
                            this.Floors[j].IsAerating = true;
                        }
                        #endregion

                        #region 取消充氮气
                        if (this.Floors[j].toCancelAerating)
                        {
                            var addr = "D" + (81 + j);
                            if (!this.Plc.SetInfo(addr, (ushort)0, out msg))
                            {
                                Error.Alert(msg);
                                this.Plc.IsAlive = false;
                                return(false);
                            }
                            LogHelper.WriteInfo(string.Format("成功发送取消充氮气指令到{0}:{1}", this.Name, addr));
                            this.Floors[j].toCancelAerating = false;
                            this.Floors[j].IsAerating       = false;
                        }
                        #endregion
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    Error.Alert(ex);
                }

                this.Plc.IsAlive = true;

                this.getInfoNum++;
                if (getInfoNum >= 4)
                {
                    this.AlreadyGetAllInfo = true;
                }
                this.getInfoNum %= 4;
            }
            return(true);
        }