Ejemplo n.º 1
0
    private void Form1_Load(object sender, EventArgs e)
    {
        #region -- dataview --
        dataGridView1.ColumnHeadersVisible = true;
        DataGridViewTextBoxColumn newCol = new DataGridViewTextBoxColumn(); // add a column to the grid
        newCol.HeaderText = "Time Stamp";
        newCol.Name       = "clmTs";
        newCol.Visible    = true;
        newCol.Width      = 90;
        dataGridView1.Columns.Add(newCol);
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Exe Step";
        newCol.Name       = "clmStp";
        newCol.Visible    = true;
        newCol.Width      = 150;
        dataGridView1.Columns.Add(newCol);
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Result";
        newCol.Name       = "clmRes";
        newCol.Visible    = true;
        newCol.Width      = 80;
        dataGridView1.Columns.Add(newCol);
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Exe Time (ms)";
        newCol.Name       = "clmExt";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Error Code";
        newCol.Name       = "clmErr";
        newCol.Visible    = true;
        newCol.Width      = 200;
        dataGridView1.Columns.Add(newCol);

        for (int i = 0; i < dataGridView1.Columns.Count - 1; i++)
        {
            dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic;
        }
        dataGridView1.Rows.Clear();
        try
        {
            m_DataGridViewCtrlAddDataRow = new DataGridViewCtrlAddDataRow(DataGridViewCtrlAddNewRow);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        #endregion

        HttpReqService = new HttpReqService();
        dataHld        = new DataHandleService();
        LoadPara       = dataHld.GetPara(Application.StartupPath);
        textBox1.Text  = AddressIP = LoadPara.IP;
        GCtxtBox.Text  = path = LoadPara.Path;
    }
Ejemplo n.º 2
0
    private void Form1_Load(object sender, EventArgs e)
    {
        //HttpReqService = new HttpReqService();
        //
        //dataGridView1.ColumnCount = 1;
        dataGridView1.ColumnHeadersVisible = true;
        DataGridViewTextBoxColumn newCol = new DataGridViewTextBoxColumn(); // add a column to the grid

        newCol.HeaderText = "Time Stamp";
        newCol.Name       = "clmTs";
        newCol.Visible    = true;
        newCol.Width      = 90;
        dataGridView1.Columns.Add(newCol);
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Exe Step";
        newCol.Name       = "clmStp";
        newCol.Visible    = true;
        newCol.Width      = 150;
        dataGridView1.Columns.Add(newCol);
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Result";
        newCol.Name       = "clmRes";
        newCol.Visible    = true;
        newCol.Width      = 80;
        dataGridView1.Columns.Add(newCol);
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Exe Time (ms)";
        newCol.Name       = "clmExt";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Error Code";
        newCol.Name       = "clmErr";
        newCol.Visible    = true;
        newCol.Width      = 200;
        dataGridView1.Columns.Add(newCol);

        for (int i = 0; i < dataGridView1.Columns.Count - 1; i++)
        {
            dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic;
        }
        dataGridView1.Rows.Clear();
        try
        {
            m_DataGridViewCtrlAddDataRow = new DataGridViewCtrlAddDataRow(DataGridViewCtrlAddNewRow);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        backgroundWorker1.WorkerSupportsCancellation = true;
        GetParaFromFile();
    }
Ejemplo n.º 3
0
 public Form1()
 {
     InitializeComponent();
     for (int i = 0; i < dataGridView1.Columns.Count - 1; i++)
     {
         dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
     }
     dataGridView1.Rows.Clear();
     try
     {
         m_DataGridViewCtrlAddDataRow = new DataGridViewCtrlAddDataRow(DataGridViewCtrlAddNewRow);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 4
0
 public Form1()
 {
     InitializeComponent();
     try
     {
         m_DataGridViewCtrlAddDataRow = new DataGridViewCtrlAddDataRow(DataGridViewCtrlAddNewRow);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     Browser.SelectedIndex = 0;
     if (System.IO.File.Exists(sIniFilePath))
     {
         EventLog.AddLog(sIniFilePath + " file exist, load initial setting");
         InitialRequiredInfo(sIniFilePath);
     }
 }
Ejemplo n.º 5
0
        public Form1()
        {
            InitializeComponent();
            Browser.SelectedIndex = 0;
            Text = string.Format("Advantech WebAccess Auto Test ( {0} )", sTestItemName);
            try
            {
                m_DataGridViewCtrlAddDataRow = new DataGridViewCtrlAddDataRow(DataGridViewCtrlAddNewRow);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            //if (System.IO.File.Exists(sIniFilePath))
            //{
            //    EventLog.AddLog(sIniFilePath + " file exist, load initial setting");
            //    InitialRequiredInfo(sIniFilePath);
            //}
        }
Ejemplo n.º 6
0
    private void Form1_Load(object sender, EventArgs e)
    {
        //Get IO value
        m_HttpRequest = new AdvantechHttpWebUtility();
        m_HttpRequest.ResquestOccurredError += this.OnGetHttpRequestError;
        m_HttpRequest.ResquestResponded     += this.OnGetData;
        //
        Device = new DeviceModel()//20150626 建立一個DeviceModel給所有Service
        {
            IPAddress     = textBox1.Text,
            Account       = "root",
            Password      = "******",
            Port          = 80,
            SlotNum       = 0,
            ModbusAddr    = 1,
            ModbusTimeOut = 3000,
        };
        //
        dataGridView1.ColumnHeadersVisible = true;
        DataGridViewTextBoxColumn newCol = new DataGridViewTextBoxColumn(); // add a column to the grid

        newCol.HeaderText = "Time";
        newCol.Name       = "clmTs";
        newCol.Visible    = true;
        newCol.Width      = 50;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Method";
        newCol.Name       = "clmStp";
        newCol.Visible    = true;
        newCol.Width      = 50;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Instruction";
        newCol.Name       = "clmIns";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Description";
        newCol.Name       = "clmDes";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Result";
        newCol.Name       = "clmRes";
        newCol.Visible    = true;
        newCol.Width      = 80;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Error";
        newCol.Name       = "clmErr";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);

        for (int i = 0; i < dataGridView1.Columns.Count - 1; i++)
        {
            dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic;
        }
        dataGridView1.Rows.Clear();
        try
        {
            m_DataGridViewCtrlAddDataRow = new DataGridViewCtrlAddDataRow(DataGridViewCtrlAddNewRow);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }

        dataHld       = new DataHandleService();
        textBox1.Text = dataHld.GetPara(Application.StartupPath);
        //debug
        //GetNetConfigRequest();
    }
Ejemplo n.º 7
0
    private void ADAM_AutoIO_LtoH_Latch_Load(object sender, EventArgs e)
    {
        #region -- Item --
        chkbox     = new CheckBox[num_item];
        setTxtbox  = new TextBox[num_item];
        getTxtbox  = new TextBox[num_item];
        apaxTxtbox = new TextBox[num_item];
        modbTxtbox = new TextBox[num_item];
        resLabel   = new Label[num_item];
        chkbox.Initialize(); setTxtbox.Initialize();
        getTxtbox.Initialize(); apaxTxtbox.Initialize();
        modbTxtbox.Initialize(); resLabel.Initialize();
        var text_style = new FontFamily("Times New Roman");
        for (int i = 0; i < num_item; i++)
        {
            chkbox[i]                 = new CheckBox();
            chkbox[i].Name            = "StpChkIdx" + (i + 1).ToString();
            chkbox[i].Location        = new Point(10, 83 + 35 * (i + 1));
            chkbox[i].Text            = "";
            chkbox[i].Parent          = this;
            chkbox[i].CheckedChanged += new EventHandler(SubChkBoxChanged);

            setTxtbox[i]           = new TextBox();
            setTxtbox[i].Size      = new Size(60, 25);
            setTxtbox[i].Location  = new Point(174, 83 + 35 * (i + 1));
            setTxtbox[i].Font      = new Font(text_style, 12, FontStyle.Regular);
            setTxtbox[i].TextAlign = HorizontalAlignment.Center;
            setTxtbox[i].Parent    = this;

            getTxtbox[i]           = new TextBox();
            getTxtbox[i].Size      = new Size(60, 25);
            getTxtbox[i].Location  = new Point(240, 83 + 35 * (i + 1));
            getTxtbox[i].Font      = new Font(text_style, 12, FontStyle.Regular);
            getTxtbox[i].TextAlign = HorizontalAlignment.Center;
            getTxtbox[i].Parent    = this;

            apaxTxtbox[i]           = new TextBox();
            apaxTxtbox[i].Size      = new Size(60, 25);
            apaxTxtbox[i].Location  = new Point(306, 83 + 35 * (i + 1));
            apaxTxtbox[i].Font      = new Font(text_style, 12, FontStyle.Regular);
            apaxTxtbox[i].TextAlign = HorizontalAlignment.Center;
            apaxTxtbox[i].Parent    = this;

            modbTxtbox[i]           = new TextBox();
            modbTxtbox[i].Size      = new Size(60, 25);
            modbTxtbox[i].Location  = new Point(372, 83 + 35 * (i + 1));
            modbTxtbox[i].Font      = new Font(text_style, 12, FontStyle.Regular);
            modbTxtbox[i].TextAlign = HorizontalAlignment.Center;
            modbTxtbox[i].Parent    = this;

            resLabel[i]          = new Label();
            resLabel[i].Size     = new Size(60, 25);
            resLabel[i].Location = new Point(438, 83 + 35 * (i + 1));
            resLabel[i].Font     = new Font(text_style, 12, FontStyle.Regular);
            resLabel[i].Text     = "";
            resLabel[i].Parent   = this;
        }
        for (int i = 0; i < num_item; i++)
        {
            chkbox[i].Checked = true;
        }

        //
        dataGridView1.ColumnHeadersVisible = true;
        DataGridViewTextBoxColumn newCol = new DataGridViewTextBoxColumn(); // add a column to the grid
        newCol.HeaderText = "Time";
        newCol.Name       = "clmTs";
        newCol.Visible    = true;
        newCol.Width      = 20;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Ch";
        newCol.Name       = "clmStp";
        newCol.Visible    = true;
        newCol.Width      = 30;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Step";
        newCol.Name       = "clmIns";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Result";
        newCol.Name       = "clmDes";
        newCol.Visible    = true;
        newCol.Width      = 50;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Rowdata";
        newCol.Name       = "clmRes";
        newCol.Visible    = true;
        newCol.Width      = 200;
        dataGridView1.Columns.Add(newCol);

        for (int i = 0; i < dataGridView1.Columns.Count - 1; i++)
        {
            dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic;
        }
        dataGridView1.Rows.Clear();
        try
        {
            m_DataGridViewCtrlAddDataRow = new DataGridViewCtrlAddDataRow(DataGridViewCtrlAddNewRow);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        #endregion

        ADAM6KReqService = new ADAM6KReqService();
        APAX5070Service  = new ModbusTCPService();
        ADAMmds          = new ModbusTCPService();
        //debug
        //ADAMConnection();
    }
Ejemplo n.º 8
0
    private void Form1_Load(object sender, EventArgs e)
    {
        //Get IO value
        m_HttpRequest = new AdvantechHttpWebUtility();
        m_HttpRequest.ResquestOccurredError += this.OnGetHttpRequestError;
        m_HttpRequest.ResquestResponded     += this.OnGetData;
        //
        Device = new DeviceModel()//20150626 建立一個DeviceModel給所有Service
        {
            IPAddress     = textBox1.Text,
            Account       = "root",
            Password      = "******",
            Port          = 80,
            SlotNum       = 0,
            ModbusAddr    = 1,
            ModbusTimeOut = 3000,
        };
        //
        dataGridView1.ColumnHeadersVisible = true;
        DataGridViewTextBoxColumn newCol = new DataGridViewTextBoxColumn(); // add a column to the grid

        newCol.HeaderText = "Time";
        newCol.Name       = "clmTs";
        newCol.Visible    = true;
        newCol.Width      = 50;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Method";
        newCol.Name       = "clmStp";
        newCol.Visible    = true;
        newCol.Width      = 50;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Instruction";
        newCol.Name       = "clmIns";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Description";
        newCol.Name       = "clmDes";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Result";
        newCol.Name       = "clmRes";
        newCol.Visible    = true;
        newCol.Width      = 80;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Error";
        newCol.Name       = "clmErr";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);

        for (int i = 0; i < dataGridView1.Columns.Count - 1; i++)
        {
            dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic;
        }
        dataGridView1.Rows.Clear();
        try
        {
            m_DataGridViewCtrlAddDataRow = new DataGridViewCtrlAddDataRow(DataGridViewCtrlAddNewRow);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }

        dataHld       = new DataHandleService();
        textBox1.Text = dataHld.GetPara(Application.StartupPath);
        //
        // 取得本機名稱
        string strHostName = Dns.GetHostName();
        // 取得本機的IpHostEntry類別實體,MSDN建議新的用法
        IPHostEntry iphostentry = Dns.GetHostEntry(strHostName);

        // 取得所有 IP 位址
        System.Collections.ArrayList ipList = new System.Collections.ArrayList();
        foreach (IPAddress ipaddress in iphostentry.AddressList)
        {
            // 只取得IP V4的Address
            if (ipaddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
            {
                ipList.Add(ipaddress.ToString());
                //Console.WriteLine("Local IP: " + ipaddress.ToString());
            }
        }
        //input
        //foreach (var item in ipList)
        //{
        //    ChangeDataArry[indx] = new SysChgData() { En = 1, Adr = (string)item };
        //    indx++;
        //}
        //for (int i = indx; i < 8; i++)
        //{
        //    ChangeDataArry[i] = new SysChgData() { En = 1, Adr = "192.168.1." + (i + 1).ToString() };
        //}
        IpTable.Initialize();
        foreach (var item in ipList)
        {
            IpTable[indx] = (string)item;
            indx++;
        }
        for (int i = indx; i < 8; i++)
        {
            IpTable[i] = "192.168.1." + (i + 1).ToString();
        }
    }
Ejemplo n.º 9
0
    private void Form1_Load(object sender, EventArgs e)
    {
        //Get IO value
        m_HttpRequest = new AdvantechHttpWebUtility();
        m_HttpRequest.ResquestOccurredError += this.OnGetHttpRequestError;
        m_HttpRequest.ResquestResponded     += this.OnGetData;

        //
        dataGridView1.ColumnHeadersVisible = true;
        DataGridViewTextBoxColumn newCol = new DataGridViewTextBoxColumn(); // add a column to the grid

        newCol.HeaderText = "Time";
        newCol.Name       = "clmTs";
        newCol.Visible    = true;
        newCol.Width      = 50;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Method";
        newCol.Name       = "clmStp";
        newCol.Visible    = true;
        newCol.Width      = 50;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Instruction";
        newCol.Name       = "clmIns";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Description";
        newCol.Name       = "clmDes";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Result";
        newCol.Name       = "clmRes";
        newCol.Visible    = true;
        newCol.Width      = 80;
        dataGridView1.Columns.Add(newCol);
        //
        newCol            = new DataGridViewTextBoxColumn();
        newCol.HeaderText = "Error";
        newCol.Name       = "clmErr";
        newCol.Visible    = true;
        newCol.Width      = 100;
        dataGridView1.Columns.Add(newCol);

        for (int i = 0; i < dataGridView1.Columns.Count - 1; i++)
        {
            dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic;
        }
        dataGridView1.Rows.Clear();
        try
        {
            m_DataGridViewCtrlAddDataRow = new DataGridViewCtrlAddDataRow(DataGridViewCtrlAddNewRow);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }

        dataHld       = new DataHandleService();
        textBox1.Text = dataHld.GetPara(Application.StartupPath);
        //debug
        //button1.Text = HttpReq_Connet() ? "Connected" : "Disconnected";
    }