private void button_read_long_Click(object sender, EventArgs e) { // 读取long变量 if (textBox12.Text == "1") { DemoUtils.ReadResultRender(keyence_net.ReadInt64(textBox3.Text), textBox3.Text, textBox4); } else { DemoUtils.ReadResultRender(keyence_net.ReadInt64(textBox3.Text, ushort.Parse(textBox12.Text)), textBox3.Text, textBox4); } }
private void test3( ) { // These are the underlying operations that ignore validation of success short d100_short = keyence_net.ReadInt16("D100").Content; ushort d100_ushort = keyence_net.ReadUInt16("D100").Content; int d100_int = keyence_net.ReadInt32("D100").Content; uint d100_uint = keyence_net.ReadUInt32("D100").Content; long d100_long = keyence_net.ReadInt64("D100").Content; ulong d100_ulong = keyence_net.ReadUInt64("D100").Content; float d100_float = keyence_net.ReadFloat("D100").Content; double d100_double = keyence_net.ReadDouble("D100").Content; // need to specify the text length string d100_string = keyence_net.ReadString("D100", 10).Content; }
private void button_read_long_Click(object sender, EventArgs e) { // 读取long变量 DemoUtils.ReadResultRender(keyence_net.ReadInt64(textBox3.Text), textBox3.Text, textBox4); }
//PLC读取 private object ReadSieTcpValue(Config.PlcTypeItem plctype, Config.PlcDataItem plcdata, KeyenceMcNet plc) { try { if (plctype == null || !plctype.IsConnected || plcdata == null || plc == null) { return(null); } switch (plcdata.DataType) { case Common.DataTypes.Bool: //Bool plcdata.ValueNew = plc.ReadBool(plcdata.Address).Content; break; case Common.DataTypes.Byte: //Byte plcdata.ValueNew = plc.Read(plcdata.Address, 1).Content; break; case Common.DataTypes.Short: plcdata.ValueNew = plc.ReadInt16(plcdata.Address).Content; break; case Common.DataTypes.Ushort: plcdata.ValueNew = plc.ReadUInt16(plcdata.Address).Content; break; case Common.DataTypes.Int: plcdata.ValueNew = plc.ReadInt32(plcdata.Address).Content; break; case Common.DataTypes.UInt: plcdata.ValueNew = plc.ReadUInt32(plcdata.Address).Content; break; case Common.DataTypes.Long: long lValueNew = 0; if (long.TryParse(plc.ReadInt64(plcdata.Address).Content.ToString(), out lValueNew)) { long temp = BpLong.SwapInt64(lValueNew); plcdata.ValueNew = temp; } // plcdata.ValueNew = plc.ReadInt64(plcdata.Address).Content; break; case Common.DataTypes.ULong: plcdata.ValueNew = plc.ReadUInt64(plcdata.Address).Content; break; case Common.DataTypes.Float: plcdata.ValueNew = plc.ReadFloat(plcdata.Address).Content; break; case Common.DataTypes.Double: plcdata.ValueNew = plc.ReadDouble(plcdata.Address).Content; break; case Common.DataTypes.String: HslCommunication.OperateResult <byte[]> data = (HslCommunication.OperateResult <byte[]>)plc.Read(plcdata.Address, 50); if (data != null && data.Content != null && data.Content.Length > 2) { List <byte> lstData = new List <byte>(); int nLen = data.Content[1]; for (int i = 2; i < nLen + 2; i++) { lstData.Add(data.Content[i]); } plcdata.ValueNew = System.Text.Encoding.ASCII.GetString(lstData.ToArray()); } break; default: break; } } catch { //MessageBox.Show(ex.Message); } return(plcdata.ValueNew); }