Exemplo n.º 1
0
        /// <summary>
        /// 夹件|松件信号
        /// </summary>
        /// <param name="number"></param>
        /// <param name="enable"></param>
        public IDevice Clamp(int number, bool enable = true)
        {
            eSwitchOption clamp;

            switch (number)
            {
            case 0: clamp = eSwitchOption.Clamp0; Bit.Clr(_status, eSwitchState.Unclamped0); break;

            case 1: clamp = eSwitchOption.Clamp1; Bit.Clr(_status, eSwitchState.Unclamped0); break;

            case 2: clamp = eSwitchOption.Clamp2; break;

            case 3: clamp = eSwitchOption.Clamp3; break;

            case 4: clamp = eSwitchOption.Clamp4; break;

            case 5: clamp = eSwitchOption.Clamp5; break;

            default: return(this);
            }

            byte[] result;
            lock (_port)
            {
                _option = enable ? Bit.Set(_option, clamp) : Bit.Clr(_option, clamp);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 2 * 16, (ushort)_option)))
                .Read(out result);
            }
#if DEBUG
            var res = _serialize.Deserialize <WriteRandomResult>(result);
            Logger.LogInfo($"Switch:{clamp.ToString()} {enable}, code:{res.Code.ToString()}");
#endif
            return(this);
        }
Exemplo n.º 2
0
        public IProductionStage Work(object args, out object result)
        {
            bool stageDone;

            stageDone = false;
            var context = (HuiJinYunProductionContext)args;

            while (eHuiJinYunStagePosition.Vulcanization != context.Position)
            {
                ;
            }

            try
            {
                Bit.Clr(_vulcanize.Status, eVulcanizeState.AGVInLeave);
                while (!Bit.Tst(_vulcanize.Status, eVulcanizeState.AGVInLeave))
                {
                    Thread.Sleep(1000);
                }
                Thread.Sleep(1000);
                _vulcanize.AGVInWaiting(false);
                context.CurrentAGV.Export(eHuiJinYunStagePosition.Initial, 1, false);
            }
            catch {
            }
            context.CurrentAGV.State = eHuiJinYunAGVState.Empty;
            result = null;
            return(this);
        }
Exemplo n.º 3
0
        public override void Reset(bool force = false)
        {
            byte[] result;
            lock (_port)
            {
                _option = force ? Bit.Set(_option, eVulcanizeOption.Reset) : Bit.Clr(_option, eVulcanizeOption.Reset);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 5 * 16, (ushort)_option)));
                _port.Read(out result);
            }
#if DEBUG
            var res = _serialize.Deserialize <WriteRandomResult>(result);
            Logger.LogInfo($"Vulcanize:Reset, code:{res.Code.ToString()}");
#endif
        }
Exemplo n.º 4
0
        /// <summary>
        /// 报警解除(
        /// </summary>
        /// <returns></returns>
        public IDevice AlarmRelease(bool enable = true)
        {
            byte[] result;
            lock (_port)
            {
                _option = enable ? Bit.Set(_option, eVulcanizeOption.AlarmRelease) : Bit.Clr(_option, eVulcanizeOption.AlarmRelease);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 5 * 16, (ushort)_option)));
                _port.Read(out result);
            }
#if DEBUG
            var res = _serialize.Deserialize <WriteRandomResult>(result);
            Logger.LogInfo($"Vulcanize:AlarmRelease, code:{res.Code.ToString()}");
#endif
            return(this);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 夹件|松件
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        public IDevice Placing(bool enable = true)
        {
            byte[] result;
            lock (_port)
            {
                _option = enable ? Bit.Set(_option, eWrapOption.Placing) : Bit.Clr(_option, eWrapOption.Placing);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 2 * 16, (ushort)_option)));
                _port.Read(out result);
            }
#if DEBUG
            var res = _serialize.Deserialize <WriteRandomResult>(result);
            Logger.LogInfo($"Wrap:Placing, code:{res.Code.ToString()}");
#endif
            return(this);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 急停
        /// </summary>
        /// <returns></returns>
        public IDevice EStop(bool enable)
        {
            byte[] result;
            lock (_port)
            {
                _option = enable ? Bit.Set(_option, eSwitchOption.EStop) : Bit.Clr(_option, eSwitchOption.EStop);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 2 * 16, (ushort)_option)))
                .Read(out result);
            }
#if DEBUG
            var res = _serialize.Deserialize <WriteRandomResult>(result);
            Logger.LogInfo($"Switch:estop {enable}, code:{res.Code.ToString()}");
#endif
            return(this);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 周转盘松开
        /// </summary>
        /// <param name="enable"></param>
        /// <returns></returns>
        public IDevice UnRevolvingDisc(bool enable = true)
        {
            byte[] result;
            lock (_port)
            {
                _option = enable ? Bit.Set(_option, eEnlaceOption.UnRevolvingDisc) : Bit.Clr(_option, eEnlaceOption.UnRevolvingDisc);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 3 * 16, (ushort)_option)))
                .Read(out result);
            }
#if DEBUG
            var res = _serialize.Deserialize <WriteRandomResult>(result);
            Logger.LogInfo($"Enlace:UnRevolvingDisc {enable}, code:{res.Code.ToString()}");
#endif
            return(this);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 工控机控制
        /// </summary>
        /// <param name="enable"></param>
        /// <returns></returns>
        public IDevice IPCCMD(bool enable = true)
        {
            byte[] result;
            lock (_port)
            {
                _option = Bit.Clr(_option, eVulcanizeViceOption.IPCCMD);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 3 * 16, (ushort)_option)));
                _port.Read(out result);
            }

#if DEBUG
            var res = _serialize.Deserialize <WriteRandomResult>(result);
            Logger.LogInfo($"VulcanizeVice:IPCCMD, code:{res.Code.ToString()}");
#endif

            return(this);
        }
Exemplo n.º 9
0
        public override void Reset(bool force = false)
        {
            byte[] result;
            lock (_port)
            {
                _option = Bit.Clr(_option, eEnlaceOption.Reset);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 3 * 16, (ushort)_option)));
                _option = Bit.Set(_option, eEnlaceOption.Reset);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 3 * 16, (ushort)_option)));
                _port.Read(out result);
                _option = default(eEnlaceOption);
                Status  = default(eEnlaceState);
            }
#if DEBUG
            var res = _serialize.Deserialize <WriteRandomResult>(result);
            Logger.LogInfo($"Enlace:reset, code:{res.Code.ToString()}");
#endif
        }
Exemplo n.º 10
0
        /// <summary>
        /// 旋转
        /// </summary>
        /// <returns></returns>
        public IDevice Rotate(bool enable = true)
        {
            byte[] result;
            lock (_port)
            {
                Bit.Clr(_status, eSwitchState.Rotate);
                _option = enable ? Bit.Set(_option, eSwitchOption.Rotate) : Bit.Clr(_option, eSwitchOption.Rotate);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 2 * 16, (ushort)_option)))
                .Read(out result);
                //_option = Bit.Clr(_option, eSwitchOption.Rotate);
                //_port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 2 * 16, (ushort)_option)));
                //_option = enable ? Bit.Set(_option, eSwitchOption.Rotate);
                //_port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 2 * 16, (ushort)_option)));
                //_port.Read(out result);
            }
#if DEBUG
            var res = _serialize.Deserialize <WriteRandomResult>(result);
            Logger.LogInfo($"Switch:rotate, code:{res.Code.ToString()}");
#endif
            return(this);
        }
Exemplo n.º 11
0
        public IProductionStage Work(object args, out object result)
        {
            Update(args);

            var context        = (HuiJinYunProductionContext)args;
            var switchWatcher  = new NotifyWatcher(_switch);
            var longmenWatcher = new NotifyWatcher(_longmen);
            var enlaceWatcher  = new NotifyWatcher(_enlace);
            var crswitch       = new NotifyWatcher(_crswitch);

#if DEBUG
            Logger.LogInfo($"EncapsulationStage Start");
#endif

            //(包胶周转台) 工控控制
            _switch.Operate(false); Thread.Sleep(100);
            _crswitch.Operate(false);

            _switch.EStop(true); Thread.Sleep(2000);
            _switch.EStop(false);

            _crswitch.Clamp(3, true); Thread.Sleep(2000);
            _crswitch.Clamp(3, false); Thread.Sleep(100);

            //(周转台) 输出取盘命令
            _crswitch.Clamp(1, true);

            Bit.Clr(_crswitch.Status, eSwitchState.Clamped0);
            //(缠绕六工位) 检测取盘完成
            while (!Bit.Tst(_crswitch.Status, eSwitchState.Clamped0))
            {
                Thread.Sleep(2000);
            }

            //(周转台) 输出取盘命令  关闭
            _crswitch.Clamp(1, false);


            for (int i = 0; i < 6; i++)
            //for (int i = 0; i <= 3; i++)
            //for (int i = 0; i < 1; i++)
            {
                _enlace.Reset(true); Thread.Sleep(100);
                _enlace.Reset(false);
                #region Encapsulation longmen
                if (i < 6)
                //if (i < 3)
                //if (i < 1)
                {
                    _longmen.BeginPickup(0);
                    while (!Bit.Tst(_longmen.Status, eLongMenState.InitialPickup))
                    {
                        Thread.Sleep(1000);
                    }

                    _switch.Clamp(i, true);
                    switch (i)
                    {
                    case 0:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped0);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped0))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 1:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped1);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped1))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 2:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped2);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped2))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 3:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped3);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped3))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 4:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped4);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped4))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 5:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped5);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped5))
                        {
                            Thread.Sleep(1000);
                        }
                        break;
                    }

                    _longmen.EndPickup(0);

                    while (!Bit.Tst(_longmen.Status, eLongMenState.InitialReady))
                    {
                        Thread.Sleep(1000);
                    }


                    //选择工位
                    while (context.EncapsulationDevice.Count < 1)
                    {
                        ;
                    }
                    Thread.Sleep(1000);

                    Encapsulation en = context.EncapsulationDevice[0];

                    //_enlace.Reset(true); Thread.Sleep(100);
                    //_enlace.Reset(false);

                    //(龙门) 输出工位信号和工位等待信号(PC-O0)
                    _longmen.BeginPlace(en.Id + 1, 1);

                    while (!Bit.Tst(_longmen.Status, eLongMenState.StationPickUp))
                    {
                        Thread.Sleep(1000);
                    }

                    //(包胶机) 包胶机卡盘松爪
                    _warps[en.Id].Placing(true); Thread.Sleep(3000);

                    //(龙门) 取件完成信号(PC-O14)
                    _longmen.EndPlace(en.Id + 1, 1); Thread.Sleep(100);

                    //(包胶机) 龙门夹件完成
                    _warps[en.Id].Clamped(true); Thread.Sleep(3000);
                    _warps[en.Id].Clamped(false);


                    //(龙门) 检测工位卡盘开爪(PC-I4)
                    while (!Bit.Tst(_longmen.Status, eLongMenState.StationClampOpen))
                    {
                        Thread.Sleep(1000);
                    }

                    //(龙门)卡盘开爪完成信号(PC-O15)
                    _longmen.EndPlace(en.Id + 1, 2); Thread.Sleep(3000);

                    //(龙门)卡盘可以闭爪(PC-I5)
                    _warps[en.Id].Placing(false); Thread.Sleep(2000);

                    //(龙门)卡盘闭爪完成信号(PC-O16)
                    _longmen.EndPlace(en.Id + 1, 3);

                    _warps[en.Id].EStop(true); Thread.Sleep(1000);

                    _warps[en.Id].EStop(false);

                    while (!Bit.Tst(_longmen.Status, eLongMenState.StationReady))
                    {
                        Thread.Sleep(1000);
                    }

                    //(周转台) 输出气缸松开爪信号
                    _switch.Clamp(i, true);
                    switch (i)
                    {
                    case 0:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped0);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped0))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 1:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped1);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped1))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 2:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped2);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped2))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 3:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped3);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped3))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 4:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped4);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped4))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 5:
                        Bit.Clr(_switch.Status, eSwitchState.Unclamped5);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped5))
                        {
                            Thread.Sleep(1000);
                        }
                        break;
                    }

                    _longmen.BeginPlace(en.Id + 1, 2);
                    while (!Bit.Tst(_longmen.Status, eLongMenState.StationPlace))
                    {
                        Thread.Sleep(1000);
                    }

                    _switch.Clamp(i, false);
                    switch (i)
                    {
                    case 0:
                        Bit.Clr(_switch.Status, eSwitchState.Clamped0);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Clamped0))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 1:
                        Bit.Clr(_switch.Status, eSwitchState.Clamped1);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Clamped1))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 2:
                        Bit.Clr(_switch.Status, eSwitchState.Clamped2);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Clamped2))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 3:
                        Bit.Clr(_switch.Status, eSwitchState.Clamped3);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Clamped3))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 4:
                        Bit.Clr(_switch.Status, eSwitchState.Clamped4);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Clamped4))
                        {
                            Thread.Sleep(1000);
                        }
                        break;

                    case 5:
                        Bit.Clr(_switch.Status, eSwitchState.Clamped5);
                        while (!Bit.Tst(_switch.Status, eSwitchState.Clamped5))
                        {
                            Thread.Sleep(1000);
                        }
                        break;
                    }
                    _longmen.EndPlace(i + 1, 4);

                    //_warps[en.Id].EStop(true); Thread.Sleep(1000);

                    //_warps[en.Id].EStop(false);
                    Thread.Sleep(1000);
                    //移除操作工位
                    context.EncapsulationDevice.Remove(en);
                }

                while (!Bit.Tst(_longmen.Status, eLongMenState.InitialStation))
                {
                    Thread.Sleep(1000);
                }
                #endregion

                if (i <= 5)
                {
                    //(周转台) 输出气工位旋转
                    _switch.Rotate(); Thread.Sleep(10000);

                    Bit.Clr(_switch.Status, eSwitchState.Rotate);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Rotate))
                    {
                        Thread.Sleep(1000);
                    }
                }

                //(周转台) 输出气工位旋转信号 关闭
                _switch.Rotate(false);

                #region Enlace

                _enlace.RevolvingDiscInPlace(); Thread.Sleep(3000);

                //if (i < 1)
                //{
                //    if (context.isStart)
                //    {
                //        //(缠绕机) 输出启动
                //        _enlace.Start(); Thread.Sleep(1000);
                //        context.isStart = false;
                //    }
                //}

                //(缠绕机) 输出周转盘旋转到位 信号取消
                _enlace.RevolvingDiscInPlace(false); Thread.Sleep(100);

                Bit.Clr(_enlace.Status, eEnlaceState.TurntableUndone);
                while (!Bit.Tst(_enlace.Status, eEnlaceState.TurntableUndone))
                {
                    Thread.Sleep(1000);
                }

                //(周转台) 输出气缸松开爪信号
                _switch.Clamp(i, true);
                switch (i)
                {
                case 0:
                    Bit.Clr(_switch.Status, eSwitchState.Unclamped0);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped0))
                    {
                        Thread.Sleep(1000);
                    }
                    break;

                case 1:
                    Bit.Clr(_switch.Status, eSwitchState.Unclamped1);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped1))
                    {
                        Thread.Sleep(1000);
                    }
                    break;

                case 2:
                    Bit.Clr(_switch.Status, eSwitchState.Unclamped2);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped2))
                    {
                        Thread.Sleep(1000);
                    }
                    break;

                case 3:
                    Bit.Clr(_switch.Status, eSwitchState.Unclamped3);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped3))
                    {
                        Thread.Sleep(1000);
                    }
                    break;

                case 4:
                    Bit.Clr(_switch.Status, eSwitchState.Unclamped4);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped4))
                    {
                        Thread.Sleep(1000);
                    }
                    break;

                case 5:
                    Bit.Clr(_switch.Status, eSwitchState.Unclamped5);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Unclamped5))
                    {
                        Thread.Sleep(1000);
                    }
                    break;
                }

                _enlace.UnRevolvingDisc(); Thread.Sleep(1000);

                //(缠绕机) 检测周转盘夹紧
                Bit.Clr(_enlace.Status, eEnlaceState.TurntableClamping);

                while (!Bit.Tst(_enlace.Status, eEnlaceState.TurntableClamping))
                {
                    Thread.Sleep(1000);
                }

                //(缠绕机) 输出周转盘夹紧
                _switch.Clamp(i, false);

                switch (i)
                {
                case 0:
                    Bit.Clr(_switch.Status, eSwitchState.Clamped0);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Clamped0))
                    {
                        Thread.Sleep(1000);
                    }
                    break;

                case 1:
                    Bit.Clr(_switch.Status, eSwitchState.Clamped1);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Clamped1))
                    {
                        Thread.Sleep(1000);
                    }
                    break;

                case 2:
                    Bit.Clr(_switch.Status, eSwitchState.Clamped2);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Clamped2))
                    {
                        Thread.Sleep(1000);
                    }
                    break;

                case 3:
                    Bit.Clr(_switch.Status, eSwitchState.Clamped3);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Clamped3))
                    {
                        Thread.Sleep(1000);
                    }
                    break;

                case 4:
                    Bit.Clr(_switch.Status, eSwitchState.Clamped4);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Clamped4))
                    {
                        Thread.Sleep(1000);
                    }
                    break;

                case 5:
                    Bit.Clr(_switch.Status, eSwitchState.Clamped5);
                    while (!Bit.Tst(_switch.Status, eSwitchState.Clamped5))
                    {
                        Thread.Sleep(1000);
                    }
                    break;
                }

                _enlace.TurntableClampingReady();

                //(缠绕机) 周转盘旋转信号
                Bit.Clr(_enlace.Status, eEnlaceState.RevolvingDiskRotation);
                while (!Bit.Tst(_enlace.Status, eEnlaceState.RevolvingDiskRotation))
                {
                    Thread.Sleep(1000);
                }

                //  旋转(缠绕六工位)
                _crswitch.Clamp(0, true); Thread.Sleep(2000);

                //(缠绕六工位) 周转盘旋转信号
                Bit.Clr(_crswitch.Status, eSwitchState.Unclamped0);
                Thread.Sleep(3000);
                while (!Bit.Tst(_crswitch.Status, eSwitchState.Unclamped0))
                {
                    Thread.Sleep(1000);
                }

                //  旋转(缠绕六工位)
                _crswitch.Clamp(0, false);
                #endregion

                //_enlace.Reset(true); Thread.Sleep(100);
                //_enlace.Reset(false);
            }

            /*
             * //  旋转(缠绕六工位)
             * _crswitch.Clamp(0, true); Thread.Sleep(2000);
             *
             * //(缠绕六工位) 周转盘旋转信号
             * while (!Bit.Tst(_crswitch.Status, eSwitchState.Unclamped0)) Thread.Sleep(100);
             *
             * //  旋转(缠绕六工位)
             * _crswitch.Clamp(0, false);
             */
            Thread.Sleep(10000);

            //(周转台) 输出放盘命令
            _crswitch.Clamp(2, true);
            Bit.Clr(_crswitch.Status, eSwitchState.Unclamped1);
            Thread.Sleep(3000);
            //(缠绕六工位) 周转盘旋转信号
            while (!Bit.Tst(_crswitch.Status, eSwitchState.Unclamped1))
            {
                Thread.Sleep(1000);
            }

            //(周转台) 输出放盘命令 关闭
            _crswitch.Clamp(2, false);

            // Encapsulation And Enlace End
            Status = eProductionStageState.Ready;
            context.CurrentAGV.State = eHuiJinYunAGVState.Tray;
            Status = eProductionStageState.Finish;

            result = null;
#if DEBUG
            Logger.LogInfo($"EncapsulationStage Finish");
#endif
            return(this);
        }
Exemplo n.º 12
0
        public void ViceSync(object sender, byte[] args, eVulcanizeViceState state)
        {
            var cmd = _serialize.Serialize(new WriteCommand(eElementCode.D, 50, 24))
                      .Concat(args).ToArray();

            lock (_port)
            {
                _port.Write(cmd)
                .Read(out byte[] result);
                var data = _serialize.Deserialize <PlcResultBase>(result);
            }

            lock (_port)
            {
                //硫化门已升
                _option = (Bit.Tst(state, eVulcanizeViceState.VulcanizationDoorUpReady) ? Bit.Set(_option, eVulcanizeOption.VulcanizationDoorUpReady) : Bit.Clr(_option, eVulcanizeOption.VulcanizationDoorUpReady));
                //出盘已准备
                _option = (Bit.Tst(state, eVulcanizeViceState.OutDiscReady) ? Bit.Set(_option, eVulcanizeOption.OutDiscReady) : Bit.Clr(_option, eVulcanizeOption.OutDiscReady));
                //硫化门已降
                _option = (Bit.Tst(state, eVulcanizeViceState.VulcanizationDoorDownReady) ? Bit.Set(_option, eVulcanizeOption.VulcanizationDoorDownReady) : Bit.Clr(_option, eVulcanizeOption.VulcanizationDoorDownReady));
                //出口到小车
                _option = (Bit.Tst(state, eVulcanizeViceState.ExitToAGV) ? Bit.Set(_option, eVulcanizeOption.ExitToAGV) : Bit.Clr(_option, eVulcanizeOption.ExitToAGV));
                //硫化到冷却已完成
                _option = (Bit.Tst(state, eVulcanizeViceState.CoolerReady) ? Bit.Set(_option, eVulcanizeOption.CoolerReady) : Bit.Clr(_option, eVulcanizeOption.CoolerReady));

                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 5 * 16, (ushort)_option)));
                _port.Read(out byte [] result);

#if DEBUG
                var res = _serialize.Deserialize <WriteRandomResult>(result);

                Logger.LogInfo($"Vulcanize:ViceSync, code:{state.ToString()}");
                Logger.LogInfo($"Vulcanize:ViceSync, code:{res.Code.ToString()}");
#endif
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 手动冷却传送带动
        /// </summary>
        /// <returns></returns>
        public IDevice HandOpertionCoolerTransmission(bool enable = true)
        {
            byte[] result;
            lock (_port)
            {
                _option = enable ? Bit.Set(_option, eVulcanizeViceOption.HandOpertionCoolerTransmission) : Bit.Clr(_option, eVulcanizeViceOption.HandOpertionCoolerTransmission);
                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 3 * 16, (ushort)_option)))
                .Read(out result);
            }
#if DEBUG
            var res = _serialize.Deserialize <WriteRandomResult>(result);
            Logger.LogInfo($"VulcanizeVice:HandOpertionCoolerTransmission, code:{res.Code.ToString()}");
#endif

            return(this);
        }
Exemplo n.º 14
0
        public void Sync(object sender, eVulcanizeState state)
        {
            lock (_port)
            {
                //冷却到出口
                _option = (Bit.Tst(state, eVulcanizeState.CoolerToExit) ? Bit.Set(_option, eVulcanizeViceOption.CoolerToExit) : Bit.Clr(_option, eVulcanizeViceOption.CoolerToExit));

                //硫化门升
                _option = (Bit.Tst(state, eVulcanizeState.VulcanizationDoorUp) ? Bit.Set(_option, eVulcanizeViceOption.VulcanizationDoorUp) : Bit.Clr(_option, eVulcanizeViceOption.VulcanizationDoorUp));

                //冷却门升
                _option = (Bit.Tst(state, eVulcanizeState.CoolerDoorUp) ? Bit.Set(_option, eVulcanizeViceOption.CoolerDoorUp) : Bit.Clr(_option, eVulcanizeViceOption.CoolerDoorUp));

                //硫化到冷却
                _option = (Bit.Tst(state, eVulcanizeState.VulcanizationToCooler) ? Bit.Set(_option, eVulcanizeViceOption.CoolerReady) : Bit.Clr(_option, eVulcanizeViceOption.CoolerReady));

                //硫化门降
                _option = (Bit.Tst(state, eVulcanizeState.VulcanizationDoorDown) ? Bit.Set(_option, eVulcanizeViceOption.VulcanizationDoorDown) : Bit.Clr(_option, eVulcanizeViceOption.VulcanizationDoorDown));

                //冷却门降
                _option = (Bit.Tst(state, eVulcanizeState.CoolerDoorDown) ? Bit.Set(_option, eVulcanizeViceOption.CoolerDoorDown) : Bit.Clr(_option, eVulcanizeViceOption.CoolerDoorDown));

                //手动冷却传送带动
                _option = (Bit.Tst(state, eVulcanizeState.HandOpertionCoolerTransmission) ? Bit.Set(_option, eVulcanizeViceOption.HandOpertionCoolerTransmission) : Bit.Clr(_option, eVulcanizeViceOption.HandOpertionCoolerTransmission));

                //出口到小车
                _option = (Bit.Tst(state, eVulcanizeState.OutToAGV) ? Bit.Set(_option, eVulcanizeViceOption.OutToAGV) : Bit.Clr(_option, eVulcanizeViceOption.OutToAGV));

                //急停
                _option = (Bit.Tst(state, eVulcanizeState.Estop) ? Bit.Set(_option, eVulcanizeViceOption.EStop) : Bit.Clr(_option, eVulcanizeViceOption.EStop));

                //从机复位
                _option = (Bit.Tst(state, eVulcanizeState.ViceReset) ? Bit.Set(_option, eVulcanizeViceOption.ViceReset) : Bit.Clr(_option, eVulcanizeViceOption.ViceReset));

                _port.Write(_serialize.Serialize(new WriteRandomCommand(eElementCode.M, 3 * 16, (ushort)_option)));
                _port.Read(out byte[] result);
#if DEBUG
                var res = _serialize.Deserialize <WriteRandomResult>(result);
                Logger.LogInfo($"VulcanizeVice:Sync, code:{state.ToString()}");

                Logger.LogInfo($"VulcanizeVice:Sync, code:{res.Code.ToString()}");
#endif
            }
        }