Esempio n. 1
0
 public Plateform(External ExternalSign, StationInitialize stationIni, StationOperate stationOpe)
 {
     externalSign      = ExternalSign;
     stationInitialize = stationIni;
     stationOperate    = stationOpe;
 }
Esempio n. 2
0
 public Station1(External ExternalSign, StationInitialize stationIni, StationOperate stationOpe)
     : base(ExternalSign, stationIni, stationOpe, typeof(Station1))
 {
     InterlockingClass = new InterlockingClass();
 }
Esempio n. 3
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            UserLevelChangeEvent += UserLevelChange;
            Global.userLevel      = UserLevel.操作员;
            OnUserLevelChange(Global.userLevel);

            new Thread(new ThreadStart(() =>
            {
                frmStarting loading = new frmStarting(8);
                LoadingMessage     += new Action <string>(loading.ShowMessage);
                loading.ShowDialog();
            })).Start();
            Thread.Sleep(500);

            Config.Instance = SerializerManager <Config> .Instance.Load(AppConfig.ConfigIntrinsicProductPathdName);

            AxisParameter.Instance = SerializerManager <AxisParameter> .Instance.Load(AppConfig.ConfigIntrinsicParamAxisCardName);

            #region  加载板卡

            LoadingMessage("加载板卡信息");
            try
            {
                IoPoints.ApsController.Initialize();
                if (!IoPoints.ApsController.LoadParamFromFile(AppConfig.ConfigAxisCardName("Param0.cfg")))
                {
                    AppendText("配置文件失败:请将轴卡的配置文件" + ".cfg " + "拷贝到当前型号的路径下" + AppConfig.ConfigAxisCardName("Param0.cfg"));
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message);
                AppendText("板卡初始化失败!请检查硬件!");
                timer1.Enabled = false;
            }
            #endregion

            #region 气缸信息

            LoadingMessage("加载气缸资源");
            var SwichCylinder = new DoubleCylinder(IoPoints.S15, IoPoints.S16, IoPoints.Y13, IoPoints.Y14)
            {
                Name      = "切换气缸",
                Delay     = Delay.Instance.SwitchCylinderDelay,
                Condition = new CylinderCondition(() => { return(true); }, () => { return(true); })
                {
                    External = m_External
                }
            };
            var LeftCylinder = new DoubleCylinder(IoPoints.S15, IoPoints.S16, IoPoints.Y13, IoPoints.Y14)
            {
                Name      = "左负压",
                Delay     = Delay.Instance.LeftCylinderDelay,
                Condition = new CylinderCondition(() => { return(true); }, () => { return(true); })
                {
                    External = m_External
                }
            };
            var RightCylinder = new DoubleCylinder(IoPoints.S15, IoPoints.S16, IoPoints.Y13, IoPoints.Y14)
            {
                Name      = "右负压",
                Delay     = Delay.Instance.RightCylinderDelay,
                Condition = new CylinderCondition(() => { return(true); }, () => { return(true); })
                {
                    External = m_External
                }
            };
            #endregion
            DM50S = new DM50S()
            {
                Name = "扫描枪"
            };
            try
            {
                DM50S.SetConnectionParam(Config.Instance.ReadCodePortConnectParam);
                DM50S.DeviceDataReceiveCompelete += new DataReceiveCompleteEventHandler(DealWithScrewDeviceReceiveData);
                DM50S.DeviceOpen();
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}连接失败:{1}", DM50S.Name, ex.Message));
            }

            #region 轴信息

            LoadingMessage("加载轴控制资源");

            var XaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 0,
                Transmission      = AxisParameter.Instance.XTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeXVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.XVelocityCurve,
                Speed             = 11,
                Name              = "相机X轴"
            };
            XaxisServo._condition = new Func <bool>(() =>
            {
                return(true);
            });
            var YaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 1,
                Transmission      = AxisParameter.Instance.YTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeYVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.YVelocityCurve,
                Speed             = 11,
                Name              = "治具Y轴"
            };
            YaxisServo._condition = new Func <bool>(() => { return(true); });

            var ZaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 2,
                Transmission      = AxisParameter.Instance.ZTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeZVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.ZVelocityCurve,
                Speed             = 11,
                Name              = "升降Z轴"
            };
            ZaxisServo._condition = new Func <bool>(() => { return(true); });
            var LFXaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 3,
                Transmission      = AxisParameter.Instance.LFXTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeLFXVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.LFXVelocityCurve,
                Speed             = 11,
                Name              = "相机左前X轴"
            };
            LFXaxisServo._condition = new Func <bool>(() => { return(true); });
            var LFYaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 4,
                Transmission      = AxisParameter.Instance.LFYTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeLFYVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.LFYVelocityCurve,
                Speed             = 11,
                Name              = "相机左前Y轴"
            };
            LFYaxisServo._condition = new Func <bool>(() => { return(true); });
            var LRXaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 5,
                Transmission      = AxisParameter.Instance.LRXTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeLRXVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.LRXVelocityCurve,
                Speed             = 11,
                Name              = "相机左后X轴"
            };
            LRXaxisServo._condition = new Func <bool>(() => { return(true); });
            var LRYaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 6,
                Transmission      = AxisParameter.Instance.LRYTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeLRYVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.LRYVelocityCurve,
                Speed             = 11,
                Name              = "相机左后Y轴"
            };
            LRYaxisServo._condition = new Func <bool>(() => { return(true); });
            var RYaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 7,
                Transmission      = AxisParameter.Instance.RYTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeRYVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.RYVelocityCurve,
                Speed             = 11,
                Name              = "相机右Y轴"
            };
            RYaxisServo._condition = new Func <bool>(() => { return(true); });
            #endregion


            #region 工站模组操作

            LoadingMessage("加载模组操作资源");

            var Station1Initialize = new StationInitialize(
                () => { return(!ManualAutoMode); },
                () => { return(Station1IsAlarm.IsAlarm); });
            var Station1Operate = new StationOperate(
                () => { return(Station1Initialize.InitializeDone); },
                () => { return(Station1IsAlarm.IsAlarm); });



            MachineOperation = new MachineOperate(() =>
            {
                return(Station1Initialize.InitializeDone);
            }, () =>
            {
                return(Station1IsAlarm.IsAlarm | MachineIsAlarm.IsAlarm);
            });
            #endregion

            #region 雅马哈机器人
            yamaha = new Yamaha();
            if (!yamaha.Connect(Config.Instance.YamahaIP, Config.Instance.Port))
            {
                AppendText("机器人连接失败!");
            }
            #endregion

            #region 模组信息加载、启动

            LoadingMessage("加载模组信息");
            m_station1 = new Station1(m_External, Station1Initialize, Station1Operate)
            {
                mAlarmManage  = mAlarmManage,
                XaxisServo    = XaxisServo,
                YaxisServo    = YaxisServo,
                ZaxisServo    = ZaxisServo,
                LFXaxisServo  = LFXaxisServo,
                LFYaxisServo  = LFYaxisServo,
                LRXaxisServo  = LRXaxisServo,
                LRYaxisServo  = LRYaxisServo,
                RYaxisServo   = RYaxisServo,
                YAMAHA        = yamaha,
                SwichCylinder = SwichCylinder,
                LeftVacuum    = LeftCylinder,
                RightVacuum   = RightCylinder
            };
            m_station1.AddPart();
            m_station1.Run(RunningModes.Online);

            #endregion

            LoadingMessage("加载MES资源");
            #region 加载信号灯资源
            StartButton = new LightButton(IoPoints.S1, IoPoints.Y1);
            ResetButton = new LightButton(IoPoints.S2, IoPoints.Y10);
            PauseButton = new LightButton(IoPoints.S5, IoPoints.Y11);
            EstopButton = new EventButton(IoPoints.S3);
            StopButton  = new LightButton(IoPoints.S4, IoPoints.Y12);


            layerLight = new LayerLight(IoPoints.Y11, IoPoints.Y10, IoPoints.Y9, IoPoints.Y12);

            StartButton.Pressed  += btnStart_MouseDown;
            StartButton.Released += btnStart_MouseUp;
            PauseButton.Pressed  += btnPause_MouseDown;
            PauseButton.Released += btnPause_MouseUp;
            ResetButton.Pressed  += btnReset_MouseDown;
            ResetButton.Released += btnReset_MouseUp;

            MachineOperation.StartButton = StartButton;
            MachineOperation.PauseButton = PauseButton;
            MachineOperation.StopButton  = StopButton;
            MachineOperation.ResetButton = ResetButton;
            MachineOperation.EstopButton = EstopButton;
            #endregion
            ManualAutoMode = false;
            LoadingMessage("加载线程资源");
            SerialStart();

            timer1.Enabled = true;
        }