コード例 #1
0
        private void Receive(object input)
        {
            string receiveMsg = string.Empty;


            int           numberOfBytesRead = 0;
            NetworkStream ns = tcpClient.GetStream();

            try
            {
                while (tcpClient.Connected)
                {
                    if (ns.CanRead)
                    {
                        do
                        {
                            byte[] receiveBytes = new byte[tcpClient.ReceiveBufferSize];
                            numberOfBytesRead = ns.Read(receiveBytes, 0, tcpClient.ReceiveBufferSize);

                            byte[] bytesRead = new byte[numberOfBytesRead];
                            Array.Copy(receiveBytes, bytesRead, numberOfBytesRead);
                            //receiveMsg = Encoding.Default.GetString(receiveBytes, 0, numberOfBytesRead);
                            socketDataArrivalHandler(bytesRead);
                        }while (ns.DataAvailable);
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error(e.StackTrace, e);
                FormMainUpdate.ShowMessage(e.StackTrace);
            }
        }
コード例 #2
0
ファイル: FormSelectRecipe.cs プロジェクト: bookorz/Sachiel
        private void btnChange_Click_1(object sender, EventArgs e)
        {
            string oldRecipeId = SystemConfig.Get().CurrentRecipe;
            string newRecipeId = cbRecipe.SelectedItem.ToString();

            using (var form = new FormConfirm("是否變更生產 Recipe:" + oldRecipeId + "=>" + newRecipeId))
            {
                var result = form.ShowDialog();
                if (result == DialogResult.OK)
                {
                    SystemConfig config = SystemConfig.Get();
                    config.CurrentRecipe = cbRecipe.SelectedItem.ToString();
                    config.Save();
                    FormMainUpdate.UpdateRecipe(config.CurrentRecipe);
                    SanwaUtil.addActionLog("Recipe", "Change", Global.currentUser, "變更生產 Recipe:" + oldRecipeId + "=>" + newRecipeId);
                    MessageBox.Show("Change recipe completed.", "Success");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Cancel.", "Notice");
                }
            }
        }
コード例 #3
0
ファイル: FormSysConfig.cs プロジェクト: bookorz/Sachiel
        private void btnSave_Click(object sender, EventArgs e)
        {
            //權限檢查
            using (var form = new FormConfirm("是否儲存變更?"))
            {
                var result = form.ShowDialog();
                if (result != DialogResult.OK)
                {
                    MessageBox.Show("Cancel.", "Notice");
                    return;
                }
            }

            SystemConfig config = SystemConfig.Get();

            //目前只開放查詢以下資料
            config.EquipmentID      = tbEqpId.Text;
            config.OCR1ImgToJpgPath = tbOcr1ImgBak.Text;
            config.FoupTxfLogPath   = tbTxfLogPath.Text;
            config.CurrentRecipe    = cbRecipe.SelectedItem.ToString();

            config.Save();
            MessageBox.Show("Update Completed.", "Success");
            FormMainUpdate.UpdateRecipe(config.CurrentRecipe);
        }
コード例 #4
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     FormMainUpdate.SetFormEnable("FormMain", true);
     //tbMsg.Text = "";
     //this.Hide();
     this.Close();
 }
コード例 #5
0
        private void On_IO_Click(object sender, EventArgs e)
        {
            string key  = ((Button)sender).Name;
            string type = key.Substring(key.LastIndexOf("_") + 1);

            key = key.Substring(0, key.LastIndexOf("_"));
            string address = key.Split('_')[0];
            string io      = key.Split('_')[1];
            string ioCmd   = cbUseIOName.Checked ? "MCR:SET_NMEIO/" : "MCR:SET_RELIO/";
            string cmd     = "$" + address + ioCmd + io + "/";

            switch (type.ToUpper())
            {
            case "ON":
                FormMainUpdate.Update_IO(key, "ON");
                cmd = cmd + "1;";
                break;

            case "OFF":
                FormMainUpdate.Update_IO(key, "OFF");
                cmd = cmd + "0;";
                break;
            }
            sendCommand(cmd);
        }
コード例 #6
0
 private void btnQryIO3_Click(object sender, EventArgs e)
 {
     if (FormMain.isScriptRunning)
     {
         MessageBox.Show("Script執行中無法使用本功能");
     }
     else
     {
         if (tabIOControl3.SelectedTab.Text.Equals("IN") || tabIOControl3.SelectedTab.Text.Equals("OUT"))
         {
             string cmd = "$1MCR:I7565DNM_REFRESH;";
             sendCommand(cmd);
             if (cbUseIOName.Checked)
             {
                 QryIOByName(tabIOControl3, Category3_I_List, Category3_O_List);
             }
             //QryIOByName("3", tabIOControl3, Category3_I_List, Category3_O_List);
             else
             {
                 QryIO(tabIOControl3, Category3_I_List, Category3_O_List);
             }
         }
         else
         {
             Dictionary <string, string> ioMap = new Dictionary <string, string>();
             foreach (Control foo in Category3_O_List.Controls)
             {
                 if (!foo.GetType().Name.Equals("Label"))
                 {
                     continue;
                 }
                 else if (!foo.Text.Equals("■"))
                 {
                     string address = foo.Name.Split('_')[0];
                     //Console.WriteLine(foo.Name);
                     string rio = foo.Text.Substring(0, foo.Text.IndexOf("("));
                     if (ioMap.ContainsKey(address))
                     {
                         ioMap[address] = ioMap[address] + ";" + rio;
                     }
                     else
                     {
                         ioMap[address] = rio;
                     }
                     string key = foo.Name.Substring(0, foo.Name.LastIndexOf("_"));
                     FormMainUpdate.Update_IO(key, "OFF");
                 }
             }
             foreach (KeyValuePair <string, string> ios in ioMap)
             {
                 setRELIOS(ios.Key, ios.Value, "0");//clear output
             }
         }
     }
 }
コード例 #7
0
        ///

        /// 創建套接字+異步連接函數
        ///
        ///
        private bool socket_create_connect()
        {
            try
            {
                IPAddress  ipAddress = IPAddress.Parse(remoteHost);
                IPEndPoint remoteEP  = new IPEndPoint(ipAddress, remotePort);
                theSocket             = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                theSocket.SendTimeout = 1000;

                SetHeartBeat();//設置心跳參數

                #region 異步連接代碼

                TimeoutObject.Reset(); //覆位timeout事件
                try
                {
                    ConnReport.On_Connection_Connecting("Connecting");
                    theSocket.BeginConnect(remoteEP, connectedCallback, theSocket);
                }
                catch (Exception err)
                {
                    SockErrorStr = err.ToString();
                    ConnReport.On_Connection_Error(err.Message);
                    return(false);
                }
                if (TimeoutObject.WaitOne(10000, false))//直到timeout,或者TimeoutObject.set()
                {
                    if (IsconnectSuccess)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    SockErrorStr = "Time Out";
                    ConnReport.On_Connection_Error("Time Out");
                    return(false);
                }
                #endregion
            }
            catch (Exception e)
            {
                FormMainUpdate.LogUpdate(e.StackTrace + ":" + e.Message);
                FormMainUpdate.AlarmUpdate(true);
                return(false);
            }
        }
コード例 #8
0
 private void RefreshIO(object obj)
 {
     while (isAutoRefresh)
     {
         try
         {
             //Thread.Sleep(20000);//LOCAL測試用
             Thread.Sleep(interval);
             string cmd = "$1MCR:I7565DNM_REFRESH;";
             sendCommand(cmd);
             ArrayList cmds1 = FormMainUpdate.getIORefreshCmds("tabIOControl1", "Category1_I_List", "Category1_O_List");
             if (cmds1 != null)
             {
                 foreach (string item in cmds1)
                 {
                     sendCommand(item);
                 }
             }
             ArrayList cmds2 = FormMainUpdate.getIORefreshCmds("tabIOControl2", "Category2_I_List", "Category2_O_List");
             if (cmds2 != null)
             {
                 foreach (string item in cmds2)
                 {
                     sendCommand(item);
                 }
             }
             ArrayList cmds3 = FormMainUpdate.getIORefreshCmds("tabIOControl3", "Category3_I_List", "Category3_O_List");
             if (cmds3 != null)
             {
                 foreach (string item in cmds3)
                 {
                     sendCommand(item);
                 }
             }
             //FormMainUpdate.cmdList.Clear();
             //btnQryIO1_Click(null, null);
             //btnQryIO2_Click(null, null);
             //btnQryIO3_Click(null, null);
         }
         catch (Exception e)
         {
             //logger.Error(e.StackTrace);
             Console.Write(e.StackTrace);
         }
     }
 }
コード例 #9
0
ファイル: FormMain.cs プロジェクト: bookorz/EFEM_Emulator
 public void On_CommandMessage(string msg)
 {
     FormMainUpdate.LogUpdate(msg);
 }
コード例 #10
0
 private void FormAuto_FormClosed(object sender, FormClosedEventArgs e)
 {
     FormMainUpdate.SetFormEnable("FormMain", true);
 }
コード例 #11
0
ファイル: FormMain.cs プロジェクト: bookorz/EQP_Sim
        public void On_Connection_Message(Socket handler, string Msg)
        {
            string NodeAdr = "";
            string Type    = "";
            string Command = "";
            string Value   = "";

            string[] content = { };
            if (Msg.IndexOf("$") != -1)
            {
                //Sanwa
                NodeAdr = Msg[1].ToString();
                content = Msg.Replace("\r", "").Replace("\n", "").Substring(2).Split(':');
                FormMainUpdate.LogUpdate(handler.RemoteEndPoint.ToString() + " Rev:" + Msg);
            }
            else
            {
                //TDK
                byte[] t = new byte[Encoding.ASCII.GetByteCount(Msg.ToString())];
                int    c = Encoding.ASCII.GetBytes(Msg.ToString(), 0, Encoding.ASCII.GetByteCount(Msg.ToString()), t, 0);
                NodeAdr = Encoding.Default.GetString(t, 3, 2);
                string contentStr = Encoding.Default.GetString(t, 5, t.Length - 5 - 3).Replace(";", "").Trim();
                content = contentStr.Split(':', '/');
                FormMainUpdate.LogUpdate(handler.RemoteEndPoint.ToString() + " Rev:" + contentStr);
            }
            for (int i = 0; i < content.Length; i++)
            {
                switch (i)
                {
                case 0:

                    Type = content[i];
                    break;

                case 1:

                    Command = content[i];

                    break;

                case 2:
                    Value = content[i];

                    break;
                }
            }

            string ReturnMessage = "";

            if (Msg.IndexOf("$") != -1)
            {
                string ReturnValue = "";
                //Sanwa
                if (Type.Equals("GET"))
                {
                    switch (Command)
                    {
                    case "RIO__":
                        switch (Value)
                        {
                        case "004":
                            ReturnValue = ":" + Value + ",0";
                            break;

                        case "005":
                            ReturnValue = ":" + Value + ",0";
                            break;

                        case "008":
                            ReturnValue = ":" + Value + ",0";
                            break;

                        case "009":
                            ReturnValue = ":" + Value + ",0";
                            break;

                        default:
                            ReturnValue = ":" + Value + ",0";
                            break;
                        }
                        break;
                    }
                }

                ReturnMessage = "$" + NodeAdr + "ACK:" + Command + ReturnValue + "\r";
                Comm.Send(handler, ReturnMessage);
                FormMainUpdate.LogUpdate(handler.RemoteEndPoint.ToString() + " Snd:" + ReturnMessage);

                if (Type.Equals("CMD"))
                {
                    ReturnMessage = "$" + NodeAdr + "FIN:" + Command + ":00000000" + "\r";
                    Comm.Send(handler, ReturnMessage);
                    FormMainUpdate.LogUpdate(handler.RemoteEndPoint.ToString() + " Snd:" + ReturnMessage);
                }
            }
            else
            {
                if (!Type.Equals("FIN"))
                {
                    string ReturnValue = "";
                    if (Type.Equals("GET"))
                    {
                        switch (Command)
                        {
                        case "STATE":
                            ReturnValue = "/00000000100110111000";
                            break;

                        case "MAPRD":
                            ReturnValue = "/1000000000000000000000000";
                            break;
                        }
                    }
                    ReturnMessage = TDK_A("ACK:" + Command + ReturnValue);
                    Comm.Send(handler, ReturnMessage);
                    FormMainUpdate.LogUpdate(handler.RemoteEndPoint.ToString() + " Snd:" + "ACK:" + Command + ReturnValue);

                    //System.Threading.Thread.Sleep(100);

                    ReturnMessage = TDK_A("INF:" + Command + ReturnValue);
                    Comm.Send(handler, ReturnMessage);
                    FormMainUpdate.LogUpdate(handler.RemoteEndPoint.ToString() + " Snd:" + "INF:" + Command + ReturnValue);
                }
                //TDK
                //ReturnMessage =  NodeAdr + "ACK:" + Command;
                //Comm.Send(handler, ReturnMessage);
                //ReturnMessage = "$" + NodeAdr + "FIN:" + Command + "00000000";
                //Comm.Send(handler, ReturnMessage);
            }
        }
コード例 #12
0
ファイル: FormMain.cs プロジェクト: bookorz/EQP_Sim
 public void On_Connection_Error(string Msg)
 {
     FormMainUpdate.LogUpdate("Error");
 }
コード例 #13
0
ファイル: FormMain.cs プロジェクト: bookorz/EQP_Sim
 public void On_Connection_Disconnected()
 {
     FormMainUpdate.LogUpdate("Disconnected");
 }
コード例 #14
0
ファイル: FormMain.cs プロジェクト: bookorz/EQP_Sim
 public void On_Connection_Connecting()
 {
     FormMainUpdate.LogUpdate("Connecting");
 }
コード例 #15
0
ファイル: FormMain.cs プロジェクト: bookorz/EQP_Sim
 public void On_Connection_Connected(Socket handler)
 {
     FormMainUpdate.LogUpdate(handler.RemoteEndPoint.ToString() + " Connected");
 }
コード例 #16
0
ファイル: FormMain.cs プロジェクト: bookorz/EFEM_Emulator
 public void On_Controller_State_Changed(string Device_ID, string Status)
 {
     FormMainUpdate.LogUpdate(Device_ID + ":" + Status);
 }
コード例 #17
0
ファイル: FormMain.cs プロジェクト: bookorz/EFEM_Emulator
 public void On_Connection_Status_Report(string DIOName, string Status)
 {
     FormMainUpdate.LogUpdate(DIOName + ":" + Status);
 }
コード例 #18
0
ファイル: FormMain.cs プロジェクト: bookorz/EFEM_Emulator
 public void On_Connection_Error(string DIOName, string ErrorMsg)
 {
     FormMainUpdate.LogUpdate(DIOName + ":" + ErrorMsg);
 }
コード例 #19
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //檢查資料
            if (tbRecipeID.Text.Trim().Equals("") || tbRecipeName.Text.Trim().Equals(""))
            {
                MessageBox.Show("Recipe Name or recipe id should not be empty.", "Data check error");
                return;
            }
            //權限檢查
            using (var form = new FormConfirm("確認是否儲存 Recipe:" + tbRecipeID.Text))
            {
                var result = form.ShowDialog();
                if (result != DialogResult.OK)
                {
                    MessageBox.Show("Cancel.", "Notice");
                    return;
                }
            }
            //GUI 處理
            //gbRecipe.Enabled = false;
            btnCreateRecipe.Enabled = true;
            btnModifyRecipe.Enabled = true;
            btnCancel.Enabled       = false;
            btnSave.Enabled         = false;
            tbRecipeName.ReadOnly   = true;
            tbRecipeID.ReadOnly     = true;
            trvRecipe.Enabled       = true;
            //Recipe 存檔
            Recipe recipe = new Recipe();

            recipe.aligner1_angle = tbA1_angle.Text.Equals("") ? "0" : Int32.Parse(tbA1_angle.Text).ToString();
            recipe.aligner1_speed = tbA1_speed.Text.Equals("") ? "20" : Int32.Parse(tbA1_speed.Text).ToString();
            recipe.aligner2_angle = tbA2_angle.Text.Equals("") ? "0" : Int32.Parse(tbA2_angle.Text).ToString();
            recipe.aligner2_speed = tbA2_speed.Text.Equals("") ? "20" : Int32.Parse(tbA2_speed.Text).ToString();

            recipe.is_use_aligner1 = cbUseA1.Checked;
            recipe.is_use_aligner2 = cbUseA2.Checked;


            recipe.auto_fin_unclamp = "Y";//固定Y

            recipe.auto_get_constrict = cbAutoGetRule.Text;
            recipe.auto_put_constrict = cbAutoPutRule.Text;
            //recipe.equip_id = tbEqpID.Text;
            recipe.ffu_rpm_close = tbFFUCloseRpm.Text;
            recipe.ffu_rpm_open  = tbFFUOpenRpm.Text;

            recipe.manual_fin_unclamp = "Y";//固定Y

            recipe.manual_get_constrict = cbManualGetRule.Text;
            recipe.manual_put_constrict = cbManualPutRule.Text;

            recipe.port1_carrier_type = cbP1CstType.Text;
            recipe.port1_priority     = Int32.Parse(cbP1Seq.Text);
            recipe.port1_type         = cbP1LoadType.Text;

            recipe.port2_carrier_type = cbP2CstType.Text;
            recipe.port2_priority     = Int32.Parse(cbP2Seq.Text);
            recipe.port2_type         = cbP2LoadType.Text;

            recipe.port3_carrier_type = cbP3CstType.Text;
            recipe.port3_priority     = Int32.Parse(cbP3Seq.Text);
            recipe.port3_type         = cbP3LoadType.Text;

            recipe.port4_carrier_type = cbP4CstType.Text;
            recipe.port4_priority     = Int32.Parse(cbP4Seq.Text);
            recipe.port4_type         = cbP4LoadType.Text;

            recipe.recipe_id    = tbRecipeID.Text.Trim();
            recipe.recipe_name  = tbRecipeName.Text;
            recipe.robot1_speed = tbR1Speed.Text.Equals("") ? "20" : Int32.Parse(tbR1Speed.Text).ToString();
            recipe.robot2_speed = "20";//default tbR2Speed.Text.Equals("") ? "20" : Int32.Parse(tbR2Speed.Text).ToString();

            recipe.notch_angle = tbNotch_angle.Text.Equals("") ? "0" : Int32.Parse(tbNotch_angle.Text).ToString();

            recipe.is_use_l_arm      = cbUseLArm.Checked;
            recipe.is_use_r_arm      = cbUseRArm.Checked;
            recipe.is_use_double_arm = cbUserBothArm.Checked;
            recipe.get_slot_order    = cbGetSlotOrder.Text;
            recipe.put_slot_order    = cbPutSlotOrder.Text;

            Recipe.Set(recipe.recipe_id, recipe);

            string CurrentRecipe = SystemConfig.Get().CurrentRecipe;

            if (cbActive.Checked)//設定生效
            {
                SystemConfig config = SystemConfig.Get();
                config.CurrentRecipe = tbRecipeID.Text;
                config.Save();
                FormMainUpdate.UpdateRecipe(tbRecipeID.Text);
            }
            else if (CurrentRecipe.Equals(tbRecipeID.Text))//取消生效
            {
                SystemConfig config = SystemConfig.Get();
                config.CurrentRecipe = "default";
                config.Save();
                //update node config
                FormMainUpdate.UpdateRecipe("default");
            }
            //紀錄修改Log
            if (tbRecipeID.Enabled)
            {
                Util.SanwaUtil.addActionLog("Recipe", "Create", Global.currentUser, "建立 Recipe:" + recipe.recipe_id);
            }
            if (tbRecipeID.Enabled)
            {
                Util.SanwaUtil.addActionLog("Recipe", "Modify", Global.currentUser, "修改 Recipe:" + recipe.recipe_id);
            }

            refreshList();
            MessageBox.Show("Execute successfully.", "Success");
        }
コード例 #20
0
ファイル: FormMain.cs プロジェクト: bookorz/EFEM_Emulator
 public void On_Connection_Connected()
 {
     FormMainUpdate.ConnectUpdate("Connected");
     FormMainUpdate.LogUpdate("Connected");
 }
コード例 #21
0
 private void updateLog(object data)
 {
     FormMainUpdate.Log(data.ToString());
     //FormMainUpdate.LogUpdate(data.ToString());
 }