opcua_client 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d5c48f943609a5cff626ade2e52495427fc8c3b3af175c2ac9b7231146209ec
4
- data.tar.gz: f0ec2ea830a866681352b2048950382a06d199ea1f53b47a31857b1f066a3c2f
3
+ metadata.gz: 7fd39e3b07294cf1cf3f7e037c6bb31e202f8d4279e7ff59c06ec1f709641654
4
+ data.tar.gz: a2385d369880786ae3e970625c2a9419ab6c97bf63f861e496b90161aa280cf1
5
5
  SHA512:
6
- metadata.gz: 54bacd20dd2f8f73c10dacd29f1b9ab3776ee1cec0933aa1c56423a9cc077161c5d1c0fb676111b679f80eae434640cbeb5cce2d12d254fd5877927d18142acc
7
- data.tar.gz: 270a0757c4d3469e7e3e6cbf57e874d4ec13911d221bc3befb4a257abf237b0b7307bed5f14960b5381d3ddcf74e4c77d014e778d09efb389c75a957056bb9f3
6
+ metadata.gz: 5652899ac7728aa8b2efc6ed0fcd9b9021f9d864cb68f98aafe7665026215b740afda38557e05f1c714dd77199ff8c38f984ad0605adc21371e9f3d727408b5f
7
+ data.tar.gz: e6a3bef6175e9ebef8b4422e2f97f48a856d873349520470f700cb05200419a22ca95e98e1d0c6aa2cfa73465ddd96e149c5c86cdbe004fa453cc37654d0c9c5
data/README.md CHANGED
@@ -53,11 +53,15 @@ end
53
53
  All methods raise OPCUAClient::Error if unsuccessful.
54
54
 
55
55
  * ```client.read_int16(Fixnum ns, String name) => Fixnum```
56
+ * ```client.read_uint16(Fixnum ns, String name) => Fixnum```
56
57
  * ```client.read_int32(Fixnum ns, String name) => Fixnum```
58
+ * ```client.read_uint32(Fixnum ns, String name) => Fixnum```
57
59
  * ```client.read_float(Fixnum ns, String name) => Float```
58
60
  * ```client.read_boolean(Fixnum ns, String name) => true/false```
59
61
  * ```client.write_int16(Fixnum ns, String name, Fixnum value)```
62
+ * ```client.write_uint16(Fixnum ns, String name, Fixnum value)```
60
63
  * ```client.write_int32(Fixnum ns, String name, Fixnum value)```
64
+ * ```client.write_uint32(Fixnum ns, String name, Fixnum value)```
61
65
  * ```client.write_float(Fixnum ns, String name, Float value)```
62
66
  * ```client.write_boolean(Fixnum ns, String name, bool value)```
63
67
  * ```client.multi_write_int16(Fixnum ns, Array[String] names, Array[Fixnum] values)```
@@ -121,4 +125,5 @@ bundle
121
125
  $ rake compile
122
126
  $ bin/console
123
127
  pry> client = OPCUAClient::Client.new
128
+ pry> client.connect("opc.tcp://127.0.0.1:4840")
124
129
  ```
@@ -421,11 +421,21 @@ static VALUE rb_writeUaValue(VALUE self, VALUE v_nsIndex, VALUE v_name, VALUE v_
421
421
  value.data = UA_malloc(sizeof(UA_Int16));
422
422
  *(UA_Int16*)value.data = newValue;
423
423
  value.type = &UA_TYPES[UA_TYPES_INT16];
424
+ } else if (uaType == UA_TYPES_UINT16) {
425
+ UA_UInt16 newValue = NUM2USHORT(v_newValue);
426
+ value.data = UA_malloc(sizeof(UA_UInt16));
427
+ *(UA_UInt16*)value.data = newValue;
428
+ value.type = &UA_TYPES[UA_TYPES_UINT16];
424
429
  } else if (uaType == UA_TYPES_INT32) {
425
430
  UA_Int32 newValue = NUM2INT(v_newValue);
426
431
  value.data = UA_malloc(sizeof(UA_Int32));
427
432
  *(UA_Int32*)value.data = newValue;
428
433
  value.type = &UA_TYPES[UA_TYPES_INT32];
434
+ } else if (uaType == UA_TYPES_UINT32) {
435
+ UA_UInt32 newValue = NUM2UINT(v_newValue);
436
+ value.data = UA_malloc(sizeof(UA_UInt32));
437
+ *(UA_UInt32*)value.data = newValue;
438
+ value.type = &UA_TYPES[UA_TYPES_UINT32];
429
439
  } else if (uaType == UA_TYPES_FLOAT) {
430
440
  UA_Float newValue = NUM2DBL(v_newValue);
431
441
  value.data = UA_malloc(sizeof(UA_Float));
@@ -456,6 +466,12 @@ static VALUE rb_writeUaValue(VALUE self, VALUE v_nsIndex, VALUE v_name, VALUE v_
456
466
  return Qnil;
457
467
  }
458
468
 
469
+ static VALUE rb_writeUInt16Value(VALUE self, VALUE v_nsIndex, VALUE v_name, VALUE v_newValue) {
470
+ return rb_writeUaValue(self, v_nsIndex, v_name, v_newValue, UA_TYPES_UINT16);
471
+ }
472
+
473
+ // TODO: multi UINT16
474
+
459
475
  static VALUE rb_writeInt16Value(VALUE self, VALUE v_nsIndex, VALUE v_name, VALUE v_newValue) {
460
476
  return rb_writeUaValue(self, v_nsIndex, v_name, v_newValue, UA_TYPES_INT16);
461
477
  }
@@ -472,6 +488,12 @@ static VALUE rb_writeInt32Values(VALUE self, VALUE v_nsIndex, VALUE v_aryNames,
472
488
  return rb_writeUaValues(self, v_nsIndex, v_aryNames, v_aryNewValues, UA_TYPES_INT32);
473
489
  }
474
490
 
491
+ static VALUE rb_writeUInt32Value(VALUE self, VALUE v_nsIndex, VALUE v_name, VALUE v_newValue) {
492
+ return rb_writeUaValue(self, v_nsIndex, v_name, v_newValue, UA_TYPES_UINT32);
493
+ }
494
+
495
+ // TODO: multi UINT32
496
+
475
497
  static VALUE rb_writeBooleanValue(VALUE self, VALUE v_nsIndex, VALUE v_name, VALUE v_newValue) {
476
498
  return rb_writeUaValue(self, v_nsIndex, v_name, v_newValue, UA_TYPES_BOOLEAN);
477
499
  }
@@ -522,9 +544,16 @@ static VALUE rb_readUaValue(VALUE self, VALUE v_nsIndex, VALUE v_name, int type)
522
544
  UA_Int16 val =*(UA_Int16*)value.data;
523
545
  // printf("the value is: %i\n", val);
524
546
  result = INT2FIX(val);
547
+ } else if (type == UA_TYPES_UINT16 && UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_UINT16])) {
548
+ UA_UInt16 val =*(UA_UInt16*)value.data;
549
+ // printf("the value is: %i\n", val);
550
+ result = INT2FIX(val);
525
551
  } else if (type == UA_TYPES_INT32 && UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_INT32])) {
526
552
  UA_Int32 val =*(UA_Int32*)value.data;
527
553
  result = INT2FIX(val);
554
+ } else if (type == UA_TYPES_UINT32 && UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_UINT32])) {
555
+ UA_UInt32 val =*(UA_UInt32*)value.data;
556
+ result = INT2FIX(val);
528
557
  } else if (type == UA_TYPES_BOOLEAN && UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_BOOLEAN])) {
529
558
  UA_Boolean val =*(UA_Boolean*)value.data;
530
559
  result = val ? Qtrue : Qfalse;
@@ -532,7 +561,7 @@ static VALUE rb_readUaValue(VALUE self, VALUE v_nsIndex, VALUE v_name, int type)
532
561
  UA_Float val =*(UA_Float*)value.data;
533
562
  result = DBL2NUM(val);
534
563
  } else {
535
- rb_raise(cError, "Not an int16");
564
+ rb_raise(cError, "UA type mismatch");
536
565
  return Qnil;
537
566
  }
538
567
 
@@ -546,10 +575,18 @@ static VALUE rb_readInt16Value(VALUE self, VALUE v_nsIndex, VALUE v_name) {
546
575
  return rb_readUaValue(self, v_nsIndex, v_name, UA_TYPES_INT16);
547
576
  }
548
577
 
578
+ static VALUE rb_readUInt16Value(VALUE self, VALUE v_nsIndex, VALUE v_name) {
579
+ return rb_readUaValue(self, v_nsIndex, v_name, UA_TYPES_UINT16);
580
+ }
581
+
549
582
  static VALUE rb_readInt32Value(VALUE self, VALUE v_nsIndex, VALUE v_name) {
550
583
  return rb_readUaValue(self, v_nsIndex, v_name, UA_TYPES_INT32);
551
584
  }
552
585
 
586
+ static VALUE rb_readUInt32Value(VALUE self, VALUE v_nsIndex, VALUE v_name) {
587
+ return rb_readUaValue(self, v_nsIndex, v_name, UA_TYPES_UINT32);
588
+ }
589
+
553
590
  static VALUE rb_readBooleanValue(VALUE self, VALUE v_nsIndex, VALUE v_name) {
554
591
  return rb_readUaValue(self, v_nsIndex, v_name, UA_TYPES_BOOLEAN);
555
592
  }
@@ -637,13 +674,17 @@ void Init_opcua_client()
637
674
  rb_define_method(cClient, "state", rb_state, 0);
638
675
 
639
676
  rb_define_method(cClient, "read_int16", rb_readInt16Value, 2);
677
+ rb_define_method(cClient, "read_uint16", rb_readUInt16Value, 2);
640
678
  rb_define_method(cClient, "read_int32", rb_readInt32Value, 2);
679
+ rb_define_method(cClient, "read_uint32", rb_readUInt32Value, 2);
641
680
  rb_define_method(cClient, "read_float", rb_readFloatValue, 2);
642
681
  rb_define_method(cClient, "read_boolean", rb_readBooleanValue, 2);
643
682
  rb_define_method(cClient, "read_bool", rb_readBooleanValue, 2);
644
683
 
645
684
  rb_define_method(cClient, "write_int16", rb_writeInt16Value, 3);
685
+ rb_define_method(cClient, "write_uint16", rb_writeUInt16Value, 3);
646
686
  rb_define_method(cClient, "write_int32", rb_writeInt32Value, 3);
687
+ rb_define_method(cClient, "write_uint32", rb_writeUInt32Value, 3);
647
688
  rb_define_method(cClient, "write_float", rb_writeFloatValue, 3);
648
689
  rb_define_method(cClient, "write_boolean", rb_writeBooleanValue, 3);
649
690
  rb_define_method(cClient, "write_bool", rb_writeBooleanValue, 3);
@@ -1,3 +1,3 @@
1
1
  module OPCUAClient
2
- VERSION = "0.0.2".freeze
2
+ VERSION = "0.0.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opcua_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ritvars Rundzans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-04 00:00:00.000000000 Z
11
+ date: 2020-02-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: