Example #1
0
        private void buttonSet_Click(object sender, EventArgs e)
        {
            int result = 0, resultcnt = 0;

            if (!GetPara())  //从控件中获得参数失败,则不发送修改参数命令
            {
                return;
            }
            result += ZLDM.SetDevParamString(DevID, myDevicePara.DeviceName, ZLDM.PARAM_DEV_NAME);
            resultcnt++;
            result += ZLDM.SetDevParamInt(DevID, myDevicePara.BaudRate, ZLDM.PARAM_BAUNDRATE);
            resultcnt++;
            result += ZLDM.SetDevParamInt(DevID, myDevicePara.DataBits, ZLDM.PARAM_DATA_BITS);
            resultcnt++;
            result += ZLDM.SetDevParamInt(DevID, myDevicePara.Parity, ZLDM.PARAM_PARITY);
            resultcnt++;
            result += ZLDM.SetDevParamInt(DevID, myDevicePara.StopBits, ZLDM.PARAM_STOP_BIT);
            resultcnt++;
            result += ZLDM.SetDevParamInt(DevID, myDevicePara.FlowControl, ZLDM.PARAM_FLOW_CONTROL);
            resultcnt++;
            result += ZLDM.SetDevParamInt(DevID, myDevicePara.IPMode, ZLDM.PARAM_IP_MODE);
            resultcnt++;
            result += ZLDM.SetDevParamString(DevID, myDevicePara.IPaddress, ZLDM.PARAM_DEV_LOCAL_IP);
            resultcnt++;
            result += ZLDM.SetDevParamInt(DevID, myDevicePara.Port, ZLDM.PARAM_DEV_LOCAL_PORT);
            resultcnt++;
            result += ZLDM.SetDevParamInt(DevID, myDevicePara.WorkMode, ZLDM.PARAM_WORK_MODE);
            resultcnt++;
            result += ZLDM.SetDevParamString(DevID, myDevicePara.NetMask, ZLDM.PARAM_NET_MASK);
            resultcnt++;
            result += ZLDM.SetDevParamString(DevID, myDevicePara.Gateway, ZLDM.PARAM_GATEWAY);
            resultcnt++;
            result += ZLDM.SetDevParamString(DevID, myDevicePara.DestIP, ZLDM.PARAM_DEST_IP);
            resultcnt++;
            result += ZLDM.SetDevParamInt(DevID, myDevicePara.DestPort, ZLDM.PARAM_DEST_PORT);
            resultcnt++;

            if (result != resultcnt)
            {
                MessageBox.Show("设置失败", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                ZLDM.SetDevParamExcute(DevID);
                MessageBox.Show("设置成功", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #2
0
 private void FormEditDevice_Load(object sender, EventArgs e)
 {
     this.textBoxDeviceName.Text            = ZLDM.GetDevParamString(DevID, ZLDM.PARAM_DEV_NAME);
     this.comboBoxBaudRate.SelectedIndex    = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_BAUNDRATE);
     this.comboBoxDataBits.SelectedIndex    = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_DATA_BITS);
     this.comboBoxPatity.SelectedIndex      = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_PARITY);
     this.comboBoxStopBits.SelectedIndex    = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_STOP_BIT);
     this.comboBoxFlowControl.SelectedIndex = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_FLOW_CONTROL);
     this.comboBoxIPMode.SelectedIndex      = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_IP_MODE);
     this.textBoxIP.Text   = ZLDM.GetDevParamString(DevID, ZLDM.PARAM_DEV_LOCAL_IP);
     this.textBoxPort.Text = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_DEV_LOCAL_PORT).ToString();
     this.comboBoxWorkMode.SelectedIndex = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_WORK_MODE);
     this.textBoxMask.Text     = ZLDM.GetDevParamString(DevID, ZLDM.PARAM_NET_MASK);
     this.textBoxGateway.Text  = ZLDM.GetDevParamString(DevID, ZLDM.PARAM_GATEWAY);
     this.textBoxDestIP.Text   = ZLDM.GetDevParamString(DevID, ZLDM.PARAM_DEST_IP);
     this.textBoxDestPort.Text = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_DEST_PORT).ToString();
 }
        private void button_StartSearchDev_Click(object sender, EventArgs e)
        {
            int    DeviceNumber, paraInt;
            string DevID;

            DeviceNumber = ZLDM.StartSearchDev();

            this.dataGridView1.Rows.Clear();
            if (DeviceNumber > 0)
            {
                this.dataGridView1.Rows.Add(DeviceNumber);
            }

            for (int i = 0; i < DeviceNumber; i++)
            {
                //设备ID
                //DevID = ZLDM.GetDevID(0);//只能显示第一个设备
                DevID = ZLDM.GetDevID(i);
                this.dataGridView1.Rows[i].Cells[Index设备ID].Value = DevID;
                //类型
                paraInt = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_DEV_EXIST_IN_SUBNET);
                this.dataGridView1.Rows[i].Cells[Index类型].Value = Enum.Parse(typeof(ParamDevExitInSubnet), paraInt.ToString()).ToString();
                //设备名称
                this.dataGridView1.Rows[i].Cells[Index设备名称].Value = ZLDM.GetDevParamString(DevID, ZLDM.PARAM_DEV_NAME);
                //设备IP
                this.dataGridView1.Rows[i].Cells[Index设备IP].Value = ZLDM.GetDevParamString(DevID, ZLDM.PARAM_DEV_LOCAL_IP);
                //目的IP
                this.dataGridView1.Rows[i].Cells[Index目的IP].Value = ZLDM.GetDevParamString(DevID, ZLDM.PARAM_DEST_IP);
                //模式
                paraInt = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_WORK_MODE);
                this.dataGridView1.Rows[i].Cells[Index模式].Value = Enum.Parse(typeof(ParamWorkMode), paraInt.ToString()).ToString();
                //TCP连接状态
                paraInt = ZLDM.GetDevParamInt(DevID, ZLDM.PARAM_LINK_STATUS);
                this.dataGridView1.Rows[i].Cells[IndexTCP连接].Value = Enum.Parse(typeof(ParamLinkStatus), paraInt.ToString()).ToString();
            }


            this.toolStripStatusLabel1.Text = "搜索到" + DeviceNumber.ToString() + "个设备";
        }
        private void FormDeviceManagement_Load(object sender, EventArgs e)
        {
            string mes = "初始化失败!\r\n\r\n";

            mes += "中止:停止打开“" + this.Text + "”窗口\r\n";
            mes += "重试:重新初始化\r\n";
            mes += "忽略:不进行初始化,直接打开窗口\r\n";
            while (0 == ZLDM.Init(4196))
            {
                DialogResult result = MessageBox.Show(mes, "警告", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning);
                if (result == System.Windows.Forms.DialogResult.Abort)
                {
                    this.Close();
                    break;
                }
                else if (result == System.Windows.Forms.DialogResult.Ignore)
                {
                    break;
                }
            }

            this.dataGridView1.Rows.Clear();
            this.toolStripStatusLabel1.Text = "";
        }
 private void FormDeviceManagement_FormClosing(object sender, FormClosingEventArgs e)
 {
     ZLDM.Exit();
 }
Example #6
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     ZLDM.Exit();
 }