private void btnWriteAssetCode_Click(object sender, EventArgs e) { IdentityValue iv = new IdentityValue(); byte[] tmp = Encoding.ASCII.GetBytes(txtAssetCode.Text); if (iv.Write_Device_AssetCode(_address, serialPort1, tmp)) { stalabMBStatus.Text = "写入资产编码成功"; } }
private void get_ratedResidual() { IdentityValue iv = new IdentityValue(); byte[] tmp = new byte[8]; for (int i = 0; i < 8; i++) { tmp[i] = (byte)iv.Rated_Residual_Parameter_Group(_address, serialPort1)[i]; _dtRatedResidual.Rows[i][1] = tmp[i]; } }
private void get_ProductModel() { IdentityValue iv = new IdentityValue(); byte[] tmp = new byte[10]; for (int i = 0; i < 10; i++) { tmp[i] = (byte)iv.Device_ProductModel(_address, serialPort1)[i]; } _dtSmp.Rows[5][1] = Encoding.ASCII.GetString(tmp); }
private void get_HW_Version() { IdentityValue iv = new IdentityValue(); byte[] tmp = new byte[32]; for (int i = 0; i < 32; i++) { tmp[i] = (byte)iv.Device_HW_Version(_address, serialPort1)[i]; } _dtSmp.Rows[5][1] = Encoding.ASCII.GetString(tmp); }
private void get_FactoryCode() { IdentityValue iv = new IdentityValue(); byte[] tmp = new byte[24]; for (int i = 0; i < 24; i++) { tmp[i] = (byte)iv.Device_FactoryCode(_address, serialPort1)[i]; } _dtSmp.Rows[3][1] = Encoding.ASCII.GetString(tmp); }
private void get_Inm() { IdentityValue iv = new IdentityValue(); byte[] tmp = new byte[6]; for (int i = 0; i < 6; i++) { tmp[i] = (byte)iv.Inm(_address, serialPort1)[i]; } _dtSmp.Rows[2][1] = Encoding.ASCII.GetString(tmp); }
private void btnReadAssetCode_Click(object sender, EventArgs e) { IdentityValue iv = new IdentityValue(); byte[] tmp = new byte[32]; for (int i = 0; i < 32; i++) { tmp[i] = (byte)iv.Read_Device_AssetCode(_address, serialPort1)[i]; } txtAssetCode.Text = Encoding.ASCII.GetString(tmp); }
private void btnReadDeviceNum_Click(object sender, EventArgs e) { IdentityValue iv = new IdentityValue(); byte[] tmp = new byte[6]; for (int i = 0; i < 6; i++) { tmp[i] = (byte)iv.Read_Device_Number(_address, serialPort1)[i]; txtDeviceNum.Text += tmp[i].ToString(); } }
private void btnWriteDeviceNum_Click(object sender, EventArgs e) { IdentityValue iv = new IdentityValue(); byte[] tmp = new byte[6]; for (int i = 0; i < txtDeviceNum.TextLength; i++) { tmp[i] = byte.Parse(txtDeviceNum.Text.Substring(i, 1)); } if (iv.Write_Device_Number(_address, serialPort1, tmp)) { stalabMBStatus.Text = "写入设备号成功"; } }
private void btnWriteProductDate_Click(object sender, EventArgs e) { IdentityValue iv = new IdentityValue(); byte[] tmp = Encoding.ASCII.GetBytes(txtProductDate.Text); //byte[] array = new byte[10]; //for (int i = 0; i < tmp.Length; i++) //{ // array[tmp.Length - 1 - i] = tmp[i]; //} if (iv.Write_Device_ProductDate(_address, serialPort1, tmp)) { stalabMBStatus.Text = "写入生产日期成功"; } }
private void btnSetBaudrate_Click(object sender, EventArgs e) { lock (_lock) { try { IdentityValue iv = new IdentityValue(); if (iv.Write_Device_BaudRate(_address, serialPort1, int.Parse(cbxBaudRate.Text))) { stalabMBStatus.Text = "修改通讯速率成功"; } } catch (Exception ex) { offline_process(ex.Message); } } }
private void btnReadAddr_Click(object sender, EventArgs e) { lock (_lock) { try { IdentityValue iv = new IdentityValue(); for (int i = 0; i < 6; i++) { txtDetect1.Text += iv.Read_Device_Address(serialPort1)[6 - i - 1].ToString(); } } catch (Exception ex) { offline_process(ex.Message); } } }
private void btnReadBaudrate_Click(object sender, EventArgs e) { lock (_lock) { try { IdentityValue iv = new IdentityValue(); int tmp = iv.Device_BaudRate(_address, serialPort1); if (tmp == 1) { cbxBaudRate.Text = "600"; } else if (tmp == 2) { cbxBaudRate.Text = "1200"; } else if (tmp == 3) { cbxBaudRate.Text = "2400"; } else if (tmp == 4) { cbxBaudRate.Text = "4800"; } else if (tmp == 5) { cbxBaudRate.Text = "9600"; } else if (tmp == 6) { cbxBaudRate.Text = "19200"; } } catch (Exception ex) { offline_process(ex.Message); } } }
private void btnSetAddr_Click(object sender, EventArgs e) { lock (_lock) { try { IdentityValue iv = new IdentityValue(); int a, b; byte tmp = byte.Parse(txtDetect1.Text); a = (tmp / 10) << 4; b = (tmp % 10) & 0x0F; _address[0] = (byte)(a + b); if (iv.Write_Device_Address(_address, serialPort1)) { stalabMBStatus.Text = "修改通讯地址成功"; } } catch (Exception ex) { offline_process(ex.Message); } } }