tallakt-picopc 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -16,7 +16,11 @@ To run the tests, you must install the rspec gem and the free Matrikon OPC Simul
16
16
 
17
17
  == Examples
18
18
 
19
- this simple example covers most functionality
19
+ === Simple example
20
+
21
+ This simple example covers most functionality:
22
+
23
+ require 'picopc'
20
24
 
21
25
  PicOpc.connect 'Matrikon.OPC.Simulation' do |opc|
22
26
  # Read a variable
@@ -38,12 +42,17 @@ this simple example covers most functionality
38
42
  Note that all exceptions thrown are of the class +PicOpcException+.
39
43
 
40
44
 
45
+ === Without a block
46
+
41
47
  If you don't want to use a block you can do this:
42
48
 
43
49
  opc = PicOpc::Client.new 'Matrikon.OPC.Simulation'
44
50
  puts opc.read('Random.Int1')
45
51
  opc.cleanup
46
52
 
53
+
54
+ === Cache option
55
+
47
56
  Sometimes you may want to tweak the :cache option
48
57
 
49
58
  PicOpc.connect 'Matrikon.OPC.Simulation', :cache => true { |opc| ... }
@@ -51,8 +60,29 @@ Sometimes you may want to tweak the :cache option
51
60
  Using cached reads is a lot faster, but depends on your OPC server to update the values from it's source (usually the PLC). Default behaviour is to read from the device.
52
61
 
53
62
 
63
+ === Adding a common tag prefix
64
+
65
+ The :prefix options allows you to add a common prefix to all tags added to the PicOpc client object
66
+
67
+ PicOpc.connect 'Matrikon.OPC.Simulation', :prefix => 'Bucket Brigade.' do |opc|
68
+ # prefix is added to tagname
69
+ opc.write('String', 'PicOpc Rules!')
70
+ opc['String'] = 'PicOpc Rules!'
71
+
72
+ opc.tag 'String', :bbs
73
+ opc.bbs = 'PicOpc Rules!'
74
+ end
75
+
76
+
54
77
 
55
78
  == Install
56
79
 
80
+ If you have not yet converted to gemcutter, first perform:
81
+
82
+ [sudo] gem install gemcutter
83
+ [sudo] gem tumble
84
+
85
+ Then:
86
+
57
87
  [sudo] gem install tallakt-picopc
58
88
 
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ begin
17
17
  # generates an error, no big deal
18
18
  # gem.platform = Gem::Platform::WIN32
19
19
  gem.rdoc_options << '--title' << 'PicOpc -- Tiny Ruby OPC' <<
20
- '--main' << 'README' <<
20
+ '--main' << 'README.rdoc' <<
21
21
  '--line-numbers'
22
22
 
23
23
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/picopc/picopc.rb CHANGED
@@ -45,6 +45,7 @@ module PicOpc
45
45
  else
46
46
  @source = OPCDataSource::OPCDevice
47
47
  end
48
+ @prefix = options[:prefix].to_s || ''
48
49
  rescue Exception => e
49
50
  PicOpcException[e] # wrap all exceptions in this type
50
51
  end
@@ -61,7 +62,7 @@ module PicOpc
61
62
 
62
63
  def add_item(name)
63
64
  if not @items.key? name
64
- @items[name] = @opc_items.AddItem(name, @handle)
65
+ @items[name] = @opc_items.AddItem(@prefix + name, @handle)
65
66
  @handle += 1
66
67
  end
67
68
  @items[name]
data/spec/picopc_spec.rb CHANGED
@@ -8,6 +8,7 @@ describe PicOpc do
8
8
  po.read('Random.Int1').should_not be_nil
9
9
  po['Random.Int1'].should_not be_nil
10
10
  end
11
+
11
12
  it 'Should be able to write a tag from Matrikon.OPC.Simulator' do
12
13
  tag = 'Bucket Brigade.String'
13
14
  po = PicOpc::Client.new MATRIKON
@@ -56,4 +57,16 @@ describe PicOpc do
56
57
  m.int.should == 6
57
58
  end
58
59
  end
60
+
61
+ it 'Sould add a prefix to tag names if :prefix option is set' do
62
+ PicOpc.connect MATRIKON, :prefix => 'Bucket Brigade.' do |m|
63
+ (97..98).each do |x|
64
+ m['Int1'] = x
65
+ m['Int1'].should == x
66
+ end
67
+ m.tag :int, 'Int1'
68
+ m.int = 99
69
+ m.int.should == 99
70
+ end
71
+ end
59
72
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tallakt-picopc}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tallak Tveide"]
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  "tallakt-picopc.gemspec"
32
32
  ]
33
33
  s.homepage = %q{http://github.com/tallakt/picopc}
34
- s.rdoc_options = ["--charset=UTF-8", "--title", "PicOpc -- Tiny Ruby OPC", "--main", "README", "--line-numbers"]
34
+ s.rdoc_options = ["--charset=UTF-8", "--title", "PicOpc -- Tiny Ruby OPC", "--main", "README.rdoc", "--line-numbers"]
35
35
  s.require_paths = ["lib"]
36
36
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.0")
37
37
  s.requirements = ["To run tests, you must install Matrikon OPC Simulator", "PicOpc will only run on Windows systems due to DCOM dependency"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tallakt-picopc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tallak Tveide
@@ -54,7 +54,7 @@ rdoc_options:
54
54
  - --title
55
55
  - PicOpc -- Tiny Ruby OPC
56
56
  - --main
57
- - README
57
+ - README.rdoc
58
58
  - --line-numbers
59
59
  require_paths:
60
60
  - lib