Example #1
0
        public Online()
        {
            int index = 0; bool blConnect = false;

            foreach (LisPLC LisPLC in G.LisPLC)
            {
                // AxDBCommManager plcTemp = new AxDBCommManager();

                DBPlcId eModel = (DBPlcId)Enum.Parse(typeof(MOD), LisPLC.Mod.Replace("-", ""));

                Via eVia = LisPLC.Via;
                // KEYENCEs.Create(eModel, eVia, LisPLC.Para);

                G.LisPLC[index].plcKey = KEYENCEs.Create(eModel, eVia, LisPLC.Para);
                // G.LisPLC[index].plcKey = KEYENCE.KEYENCEs.Connnect(LisPLC.plcKey);
                G.LisPLC[index].isConnect = G.isConnect;
                if (G.isConnect == isConnect.Disconnected)
                {
                    int num = index + 1;
                    G.sError   = "ERROR 0X02  : " + "LỖI ĐƯỜNG TRUYỀN KẾT NỐI VỚI LINE !" + Environment.NewLine + "VUI LÒNG KIỂM TRA LẠI KẾT NỐI VỚI THIẾT BỊ :" + LisPLC.name + "(" + LisPLC.Para + ")";
                    G.imgError = new Bitmap("pic\\errorWifi.gif");
                    Error      = new Error();
                    Error.ShowDialog();          //  this.Hide();

                    break;
                    blConnect = true;
                }
                index++;
            }
        }
Example #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            G.sourceSQL = G.VariableSQL;
            if (!cSQL.CHECK("*", "DEVICE", "DEVICE='" + txtName.Text + "' OR PARAMETER ='" + cbPara.Text.Trim() + G.portIP + "'"))
            {
                if (cbPara.Text != "")
                {
                    dynamic         itModel = cbModel.Items[cbModel.SelectedIndex];
                    DBPlcId         eModel  = (DBPlcId)int.Parse(itModel.Value);
                    dynamic         itVia   = cbVia.Items[cbVia.SelectedIndex];
                    Via             eVia    = (Via)int.Parse(itVia.Value);
                    AxDBCommManager plcTemp = new AxDBCommManager();
                    // cbModel.Items

                    plcTemp = KEYENCEs.Create(eModel, eVia, cbPara.Text.Trim() + G.portIP);
                    // G.ListKey.Add(new ListKey("", plcTemp, isConnect.Connected, img, new Point(0, 0)));
                    G.LisPLC.Add(new LisPLC(txtName.Text, cbCo.Text, cbModel.Text, eVia, cbPara.Text.Trim() + G.portIP, plcTemp, G.isConnect, picModel, picVia, G.pPen));
                    List <string> List = new List <string>();
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].name);
                    List.Add("PLC");
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].Co.ToString());
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].Mod.ToString());
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].Via.ToString());
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].Para.ToString());
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].isConnect.ToString());
                    cSQL.Insert("DEVICE", List);

                    // fm1.PicMap.Invalidate();
                    fm1.picMap.Invalidate();

                    //  LoadDevice();
                    G.pPen.X += picReview.Width + 10;
                    if (G.pPen.X + picReview.Width >= fm1.PicMap.Width)
                    {
                        G.pPen.Y += picReview.Height + 50;
                        G.pPen.X  = 0;
                    }
                }
                else
                {
                    MessageBox.Show("Vui lòng quét thông số kết nối trước khi thêm thiết bị mới !");
                }
            }
            else
            {
                MessageBox.Show("Vui lòng đặt tên khác hoặc thông số khác !");
            }
            G.sourceSQL = G.defautSQL;
            //   int A = plcTemp.ReadDevice(DBPlcDevice.DKV3000_DM, "110");
        }
Example #3
0
        private void btnOnline_Click(object sender, EventArgs e)
        {
            int index = 0; bool blConnect = false;

            foreach (LisPLC LisPLC in G.LisPLC)
            {
                // AxDBCommManager plcTemp = new AxDBCommManager();

                DBPlcId eModel = (DBPlcId)Enum.Parse(typeof(MOD), LisPLC.Mod.Replace("-", ""));

                Via eVia = LisPLC.Via;


                G.LisPLC[index].plcKey = KEYENCEs.Create(eModel, eVia, LisPLC.Para);
                // G.LisPLC[index].plcKey = KEYENCE.KEYENCEs.Connnect(LisPLC.plcKey);
                G.LisPLC[index].isConnect = G.isConnect;
                if (G.isConnect == isConnect.Disconnected)
                {
                    blConnect = false;
                }
                else
                {
                    blConnect = true;
                }
                index++;
            }
            if (blConnect == true)
            {
                btnOnline.Image = Properties.Resources.online; btnStart.Enabled = true;
            }
            else
            {
                btnOnline.Image = Properties.Resources.offline; btnStart.Enabled = false;
            }
            picMap.Invalidate();
            Refresh1 = new SFS_FV.SQL.Refresh();
        }