예제 #1
0
 private void button_read_bool_Click(object sender, EventArgs e)
 {
     // 读取bool变量
     if (textBox1.Text == "1")
     {
         DemoUtils.ReadResultRender(xGBCnet.ReadBool(textBox3.Text), textBox3.Text, textBox4);
     }
     else
     {
         DemoUtils.ReadResultRender(xGBCnet.ReadBool(textBox3.Text, ushort.Parse(textBox1.Text)), textBox3.Text, textBox4);
     }
 }
예제 #2
0
 public TValue Read <TValue>(string address)
 {
     if (typeof(TValue) == typeof(bool))
     {
         OperateResult <bool[]> read = xGBCnet.ReadBool(address, 1);
         if (!read.IsSuccess)
         {
             throw new InvalidOperationException($"{read.Message}");
         }
         else
         {
             return((TValue)(object)read.Content[0]);
         }
     }
     throw new InvalidOperationException(string.Format("type '{0}' not supported.", typeof(TValue)));
 }