Ejemplo n.º 1
0
        //取得機臺狀態
        private void getCNCInfo()
        {
            string eqpStatus = "";
            short  ret       = iRemoting.SKY_conn_status(_Pwd, ref _SkyConn_status);

            if (ret == 0)
            {
                switch (_SkyConn_status.Status[0])
                {
                case 0:
                    eqpStatus = "OFF";
                    break;

                case 1:
                    eqpStatus = "RUN";
                    break;

                case 2:
                    eqpStatus = "IDLE";
                    break;

                case 3:
                    eqpStatus = "Alarm";
                    break;
                }
            }
            currentStatus = eqpStatus;
            //取得程式名稱
            ret = iRemoting.SKY_nc_filename(_Pwd, ref _SkyNc_filename);
            if (ret == 0)
            {
                currentProgName = _SkyNc_filename.MainProg[0];
            }
            //取得程式內容
            ret = iRemoting.GET_nc_current_block(_Pwd, ref _nc_current_block);
            if (ret == 0)
            {
                currentProg = "";
                for (int i = 0; i <= _nc_current_block.Block.Length - 1; i++)
                {
                    currentProg += _nc_current_block.Block[i] + "\r\n";
                }
            }
            //取得循環時間
            ret = iRemoting.GET_time(_Pwd, ref _time);
            if (ret == 0)
            {
                cycleTime = _time.Cycle;
            }
            //取得刀號
            ret = iRemoting.GET_othercode(_Pwd, ref _othercode);
            if (ret == 0)
            {
                currentTCode = _othercode.TCode.ToString();
            }
        }
Ejemplo n.º 2
0
        //按下Connect鍵之後所要做的事和判斷的訊息
        private void btnConn_Click(object sender, EventArgs e)
        {
            if (ChannelServices.RegisteredChannels.Length == 0)
            {
                ChannelServices.RegisterChannel(new TcpChannel(), false);
            }
            string IP   = txtIP.Text.Trim();
            string Port = "9501";

            iRemoting          = (IMsg)Activator.GetObject(typeof(IMsg), "tcp://" + IP + ":" + Port + "/RemoteObjectURI" + Port);
            _Pwd.ConnectionKey = "pmc";
            _Pwd.WritePwd      = "pmc";
            short ret = iRemoting.SKY_conn_status(_Pwd, ref _SkyConn_status);

            if (ret == 0)
            {
                MessageBox.Show("Successful!");
                lblConnStatus.Image = Image.FromFile(Application.StartupPath + "\\images\\online.ico");
                timer1.Enabled      = true;
                timer2.Enabled      = true;
            }
        }