Example #1
0
        /// <summary>
        /// 初始化控制卡
        /// </summary>
        /// <returns></returns>
        public s_Result InitIoCard()
        {
            s_Result result;

            try
            {
                int nCard = 0;
                nCard = IOC0640.ioc_board_init();
                if (nCard <= 0)//控制卡初始化
                {
                    result.iResultCode   = 1;
                    result.strResultInfo = "未找到IOC0640控制卡!";
                }
                else
                {
                    result.iResultCode   = 0;
                    result.strResultInfo = "控制卡初始化正常";
                }
            }
            catch (Exception ex)
            {
                result.iResultCode   = -1;
                result.strResultInfo = "控制卡初始化过程异常";
                log.LogErr(ex);
            }


            return(result);
        }
Example #2
0
        /// <summary>
        /// 按位输出信号
        /// </summary>
        /// <param name="nIndex"></param>
        /// <param name="bBit"></param>
        /// <returns></returns>
        public override bool WriteIoBit(int nIndex, bool bBit)
        {
            if (!m_bOpen)
            {
                return(false);
            }
            uint a = IOC0640.ioc_write_outbit((ushort)m_nCardNo, (ushort)nIndex, bBit ? 0 : 1);

            return(a == 0);
        }
Example #3
0
        /// <summary>
        ///按位获取输出信号
        /// </summary>
        /// <param name="nIndex"></param>
        /// <returns></returns>
        public override bool ReadIoOutBit(int nIndex)
        {
            if (!m_bOpen)
            {
                return(false);
            }
            int a = IOC0640.ioc_read_outbit((ushort)m_nCardNo, (ushort)nIndex);

            return(a == 0);
        }
Example #4
0
 /// <summary>
 /// 产线开关
 /// </summary>
 /// <param name="b"></param>
 public void SetProductionLineOn(bool b)
 {
     if (b)
     {
         IOC0640.ioc_write_outbit(0, 1, 1);
     }
     else
     {
         IOC0640.ioc_write_outbit(0, 1, 0);
     }
 }
Example #5
0
 /// <summary>
 /// 报警器绿灯开关
 /// </summary>
 /// <param name="b"></param>
 public void SetGreenLampOn(bool b)
 {
     if (b)
     {
         IOC0640.ioc_write_outbit(0, 3, 0);
     }
     else
     {
         IOC0640.ioc_write_outbit(0, 3, 1);
     }
 }
Example #6
0
 /// <summary>
 /// 报警器红灯开关
 /// </summary>
 /// <param name="b"></param>
 public void SetRedLampOn(bool b)
 {
     if (b)
     {
         IOC0640.ioc_write_outbit(0, 2, 0);
     }
     else
     {
         IOC0640.ioc_write_outbit(0, 2, 1);
     }
 }
Example #7
0
        /// <summary>
        ///按位获取输入信号
        /// </summary>
        /// <param name="nIndex"></param>
        /// <returns></returns>
        public override bool ReadIoInBit(int nIndex)
        {
            if (!m_bOpen)
            {
                return(false);
            }
            int nAxisIndex = (nIndex & 0xff00) >> 8;
            int nBitIndex  = nIndex & 0x00ff;

            int a = IOC0640.ioc_read_inbit((ushort)m_nCardNo, (ushort)nIndex);

            return(a == 0);
        }
Example #8
0
        public override bool Init()
        {
            IOC0640.ioc_board_close();
            m_bOpen = false;
            int nCard = 0;

            nCard = IOC0640.ioc_board_init();
            if (nCard <= 0)//控制卡初始化
            {
                logger.Warn(string.Format("{0} 号卡{1} 打开失败 请检查配置", m_nCardNo, m_strCardName));
                MessageBox.Show(string.Format("{0} 号卡{1} 打开失败 请检查配置", m_nCardNo, m_strCardName), "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            m_bOpen = true;
            return(true);
        }
Example #9
0
 public static void ini()
 {
     f1.模板设置.Enabled = false;
     f1.图片.Enabled   = false;
     f1.数据日志.Enabled = false;
     f1.手动运行.Enabled = false;
     f1.登出.Enabled   = false;
     try
     {
         var a = IOC0640.ioc_board_init();
         if (a > 0)
         {
             f1.textBox2.AppendText("IO卡打开成功\r\n");
         }
     }
     catch
     {
         f1.textBox2.AppendText("IO卡打开失败\r\n");
     }
 }
Example #10
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            // Enable console
//            AllocConsole();
            // this.EnableControls(false);
            UVGlue.applicationIsRunning = true;
            UVGlue.resultsThatImagesSholdBeSaved = new List<string>
                {UVGlue.resultNG, UVGlue.resultNoProduct, UVGlue.resultImageAcqFailed};

            var a = IOC0640.ioc_board_init();
            if (a > 0)
                ShowAndSaveMsg_Invoke("IO卡打开成功");
            else
                ShowAndSaveMsg_Invoke("IO卡打开失败");

            UVGlue.threadListen = new Thread(UVGlue.Listen);
            UVGlue.threadListen.Start();
            UVGlue.threadExecute = new Thread(UVGlue.ListenPos1);
            UVGlue.threadExecute.Start();
        }
Example #11
0
 public void Run()
 {
     while (true)
     {
         long Input1 = IOC0640.ioc_read_inport(0, 0);
         for (int i = 0; i < 32; i++)
         {
             Input[i] = (Input1 >> i & 1) == 0;
         }
         long Input2 = IOC0640.ioc_read_inport(1, 0);
         for (int i = 0; i < 32; i++)
         {
             Input[i + 32] = (Input2 >> i & 1) == 0;
         }
         long Input3 = IOC0640.ioc_read_inport(2, 0);
         for (int i = 0; i < 32; i++)
         {
             Input[i + 64] = (Input3 >> i & 1) == 0;
         }
         uint Output1 = 0;
         for (int i = 0; i < 32; i++)
         {
             Output1 += (uint)(Output[i] ? 0 : Math.Pow(2, i));
         }
         IOC0640.ioc_write_outport(0, 0, Output1);
         uint Output2 = 0;
         for (int i = 0; i < 32; i++)
         {
             Output2 += (uint)(Output[i + 32] ? 0 : Math.Pow(2, i));
         }
         IOC0640.ioc_write_outport(1, 0, Output2);
         uint Output3 = 0;
         for (int i = 0; i < 32; i++)
         {
             Output3 += (uint)(Output[i + 64] ? 0 : Math.Pow(2, i));
         }
         IOC0640.ioc_write_outport(2, 0, Output3);
         System.Threading.Thread.Sleep(10);
     }
 }
Example #12
0
        private bool QueryIOPort()
        {
            int    n   = IOC0640.ioc_read_outport(0, 0);
            string Str = Convert.ToString(n, 2).PadLeft(32, '0');

            Str = Reverse(Str);
            for (int j = 0; j < 32; j++)
            {
                string str1  = "Lable" + "DO" + (j + 1).ToString();
                Label  lable = (Label)this.Controls.Find(str1, true)[0];
                if (Str.Substring(j, 1) == "1")
                {
                    lable.BackColor = Color.Red;
                }
                else
                {
                    lable.BackColor = Color.LimeGreen;
                }
            }
            int    m    = IOC0640.ioc_read_inport(0, 0);
            string Str2 = Convert.ToString(m, 2).PadLeft(32, '0');

            Str2 = Reverse(Str2);
            for (int i = 0; i < 32; i++)
            {
                string str3  = "Lable" + "DI" + (i + 1).ToString();
                Label  lable = (Label)this.Controls.Find(str3, true)[0];
                if (Str2.Substring(i, 1) == "1")
                {
                    lable.BackColor = Color.Red;
                }
                else
                {
                    lable.BackColor = Color.LimeGreen;
                }
            }
            return(true);
        }
Example #13
0
        public static void listen()
        {
            var currentSignalRead = 1;


            //  try
            // {
            del del = Light;

            while (application_isRunning)
            {
                try
                {
                    f1.Invoke(del, "2", f1.label3);
                }
                catch (Exception)
                {
                }

                var incomingSignal = IOC0640.ioc_read_inbit(0, 1);
                if (incomingSignal != currentSignalRead)
                {
                    currentSignalRead = incomingSignal;
                    if (currentSignalRead == 0)
                    {
                        f1.label3.Invoke(del, "1", f1.label3);
                        lock (mu_runSignal)
                        {
                            toolBlockIsReadyToRun = true;
                        }
                    }
                }

                Thread.Sleep(20);
            }
        }
Example #14
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            // Enable console
//            AllocConsole();
           // this.EnableControls(false);
            UVGlue.applicationIsRunning = true;
            UVGlue.resultsThatImagesSholdBeSaved = new List<string>(){UVGlue.resultNG, UVGlue.resultNoProduct};
   
            int a = IOC0640.ioc_board_init();
            if (a > 0)
            {
                ShowAndSaveMsg_Invoke("IO卡打开成功");
            }
            else
            {
                ShowAndSaveMsg_Invoke("IO卡打开失败");
            }
           
            UVGlue.threadListen = new Thread(UVGlue.Listen);
            UVGlue.threadListen.Start();
            UVGlue.threadExecute = new Thread(UVGlue.ListenPos1);
            UVGlue.threadExecute.Start();


            // store summery buttons to a list
            _chartFormButtons = new List<Button>
            {
                btnX1,
                btnX2,
                btnY1,
                btnY2,
                btnAngle
            };
            _chartFormMarshaller = new ChartFormMarshaller(this, _legends, _sigmas, _numSamples, _chartFormButtons, btnReset, _reversed);

        }
Example #15
0
 /// <summary>
 /// 关闭io卡
 /// </summary>
 public void CloseIoCard()
 {
     IOC0640.ioc_board_close();
 }
Example #16
0
 public bool GetSensor2()
 {
     return(IOC0640.ioc_read_inbit(0, 2) == 0 ? true : false);
 }
Example #17
0
 public int Connect()
 {
     return(IOC0640.ioc_board_init());
 }
Example #18
0
 /// <summary>
 ///释放IO卡
 /// </summary>
 public override void DeInit()
 {
     IOC0640.ioc_board_close();
 }
Example #19
0
        public static void run()
        {
            f1.Invoke(new Action(() =>
            {
                block.Run();

                f1.cogRecordDisplay1.StaticGraphics.Clear();
                f1.cogRecordDisplay1.InteractiveGraphics.Clear();
                f1.cogRecordDisplay1.Image = null;

                var icg = block.CreateLastRunRecord();
                f1.cogRecordDisplay1.Record  = icg.SubRecords["CogIPOneImageTool1.OutputImage"];
                f1.cogRecordDisplay1.AutoFit = true;
            }));

            del del2 = Light;

            // f1.label4.Invoke(del2, "2", f1.label4);


            if (block.RunStatus.Result == CogToolResultConstants.Accept)
            {
                f1.label4.Invoke(del2, "1", f1.label4);
                GCF(f1.cogRecordDisplay1, "#", "微软雅黑", 20, 100, 100, "OK", CogColorConstants.Green,
                    CogGraphicLabelAlignmentConstants.TopLeft);
                IOC0640.ioc_write_outbit(0, out_OK_bit, 0);
                Thread.Sleep(100);
                IOC0640.ioc_write_outbit(0, out_OK_bit, 1);
                f1.label4.Invoke(del2, "2", f1.label4);
            }

            if (block.RunStatus.Result != CogToolResultConstants.Accept)
            {
                f1.label4.Invoke(del2, "1", f1.label5);
                GCF(f1.cogRecordDisplay1, "#", "微软雅黑", 20, 100, 100, "NG", CogColorConstants.Red,
                    CogGraphicLabelAlignmentConstants.TopLeft);
                IOC0640.ioc_write_outbit(0, out_NG_bit, 0);
                Thread.Sleep(100);
                IOC0640.ioc_write_outbit(0, out_NG_bit, 1);
                f1.label4.Invoke(del2, "2", f1.label5);
                SaveImage(f1.cogRecordDisplay1, true);
            }

            var pma = (CogPMAlignTool)block.Tools["判断有无料"];

            if (pma.Results.Count == 0)
            {
                f1.label4.Invoke(del2, "1", f1.label7);
                GCF(f1.cogRecordDisplay1, "#", "微软雅黑", 20, 100, 100, "无料", CogColorConstants.Red,
                    CogGraphicLabelAlignmentConstants.TopLeft);
                IOC0640.ioc_write_outbit(0, out_NOPRODUCT_bit, 0);
                Thread.Sleep(100);
                IOC0640.ioc_write_outbit(0, out_NOPRODUCT_bit, 1);
                f1.label4.Invoke(del2, "2", f1.label7);
                SaveImage(f1.cogRecordDisplay1, true);
            }


            Y  = (double)block.Outputs["Y"].Value;
            X1 = (double)block.Outputs["X1"].Value;
            X2 = (double)block.Outputs["X2"].Value;
            X3 = (double)block.Outputs["X3"].Value;
            X4 = (double)block.Outputs["X4"].Value;
            SaveImage(f1.cogRecordDisplay1, true);
            SaveLog();
        }