private void button_read_float_Click(object sender, EventArgs e) { // 读取float变量 if (textBox12.Text == "1") { DemoUtils.ReadResultRender(melsecSerial.ReadFloat(textBox3.Text), textBox3.Text, textBox4); } else { DemoUtils.ReadResultRender(melsecSerial.ReadFloat(textBox3.Text, ushort.Parse(textBox12.Text)), textBox3.Text, textBox4); } }
public void ReadExample( ) { #region ReadExample1 MelsecFxSerial melsecFx = new MelsecFxSerial( ); melsecFx.SerialPortInni(sp => { sp.PortName = "COM1"; sp.BaudRate = 9600; sp.DataBits = 7; sp.StopBits = System.IO.Ports.StopBits.One; sp.Parity = System.IO.Ports.Parity.Even; }); melsecFx.Open( ); // 此处以D寄存器作为示例 short short_D1000 = melsecFx.ReadInt16("D100").Content; // 读取D1000的short值 ushort ushort_D1000 = melsecFx.ReadUInt16("D100").Content; // 读取D1000的ushort值 int int_D1000 = melsecFx.ReadInt32("D100").Content; // 读取D1000-D1001组成的int数据 uint uint_D1000 = melsecFx.ReadUInt32("D100").Content; // 读取D1000-D1001组成的uint数据 float float_D1000 = melsecFx.ReadFloat("D100").Content; // 读取D1000-D1001组成的float数据 long long_D1000 = melsecFx.ReadInt64("D100").Content; // 读取D1000-D1003组成的long数据 ulong ulong_D1000 = melsecFx.ReadUInt64("D100").Content; // 读取D1000-D1003组成的long数据 double double_D1000 = melsecFx.ReadDouble("D100").Content; // 读取D1000-D1003组成的double数据 string str_D1000 = melsecFx.ReadString("D100", 10).Content; // 读取D1000-D1009组成的条码数据 // 读取数组 short[] short_D1000_array = melsecFx.ReadInt16("D100", 10).Content; // 读取D1000的short值 ushort[] ushort_D1000_array = melsecFx.ReadUInt16("D100", 10).Content; // 读取D1000的ushort值 int[] int_D1000_array = melsecFx.ReadInt32("D100", 10).Content; // 读取D1000-D1001组成的int数据 uint[] uint_D1000_array = melsecFx.ReadUInt32("D100", 10).Content; // 读取D1000-D1001组成的uint数据 float[] float_D1000_array = melsecFx.ReadFloat("D100", 10).Content; // 读取D1000-D1001组成的float数据 long[] long_D1000_array = melsecFx.ReadInt64("D100", 10).Content; // 读取D1000-D1003组成的long数据 ulong[] ulong_D1000_array = melsecFx.ReadUInt64("D100", 10).Content; // 读取D1000-D1003组成的long数据 double[] double_D1000_array = melsecFx.ReadDouble("D100", 10).Content; // 读取D1000-D1003组成的double数据 #endregion }
private void test3() { // These are the underlying operations that ignore validation of success short d100_short = melsecSerial.ReadInt16("D100").Content; ushort d100_ushort = melsecSerial.ReadUInt16("D100").Content; int d100_int = melsecSerial.ReadInt32("D100").Content; uint d100_uint = melsecSerial.ReadUInt32("D100").Content; long d100_long = melsecSerial.ReadInt64("D100").Content; ulong d100_ulong = melsecSerial.ReadUInt64("D100").Content; float d100_float = melsecSerial.ReadFloat("D100").Content; double d100_double = melsecSerial.ReadDouble("D100").Content; // need to specify the text length string d100_string = melsecSerial.ReadString("D100", 10).Content; }
private void button_read_float_Click(object sender, EventArgs e) { // 读取float变量 readResultRender(melsecSerial.ReadFloat(textBox3.Text), textBox3.Text, textBox4); }