plc_access 0.1.2 → 0.2.0

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: 508b6323047d55f073eb5d46d05919284b5d09c9c5cdf417df67a60642d1c097
4
- data.tar.gz: '017940d773f256fec40e4fd0ac70a6efe491354401a20c9b23a99a47fe0b66c8'
3
+ metadata.gz: ab5af068754de94a85c011c2649a60b913bf7d5767f19b6c7acccddf95dc13ad
4
+ data.tar.gz: 8f0750599d28cceff1c12816236ce7766f29120e0ed985f56e05a7cee4c4c1e9
5
5
  SHA512:
6
- metadata.gz: f73eca7c987f0ae58e02ff3e0b4526fce468c75d19cf16f45f0d80cff5655b5b7b6536a020fc69be177ac47e900df18737aef637d63a55a128b2b02ee63e7da0
7
- data.tar.gz: 8595aa8ca039870ec747a1646a36923ee8558f98099ebc593dae70c9df435402fd749019a6b539e0017e4ed0d4879b3196aa38f1c384f55fc668cf10a09380e7
6
+ metadata.gz: f4723143d4b6f0ffaf4eb56925b04dbb9eb14fe61bbab1ee216383876bbd187969761af2237120d415fc496cb16e3e8f24312b612ac4e28cae9f3816af62f0ba
7
+ data.tar.gz: 584140d65859c52ec474286a53e1ec551b84c9c401bf3613d57457151d730ecc23c472458bbfa35bf83ca073fb3f93fd6ac117d1e348b64e8f7938497c731ba2
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGES
2
2
 
3
+ ## 0.1.3
4
+
5
+ - Rename Array#as_string to Array#to_string
6
+ - Rename String#to_ushort to String#as_ushort
7
+
3
8
  ## 0.1.2
4
9
 
5
10
  - Be able to access the type value that you want to get.
data/Gemfile.lock CHANGED
@@ -1,43 +1,49 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plc_access (0.1.1)
4
+ plc_access (0.1.3)
5
5
  serialport (~> 1.3, >= 1.3.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
- json (2.6.2)
12
- parallel (1.22.1)
13
- parser (3.1.2.1)
11
+ json (2.10.1)
12
+ language_server-protocol (3.17.0.4)
13
+ lint_roller (1.1.0)
14
+ parallel (1.26.3)
15
+ parser (3.3.7.1)
14
16
  ast (~> 2.4.1)
15
- power_assert (2.0.1)
17
+ racc
18
+ power_assert (2.0.5)
19
+ racc (1.8.1)
16
20
  rainbow (3.1.1)
17
21
  rake (12.3.3)
18
- regexp_parser (2.5.0)
19
- rexml (3.2.5)
20
- rr (3.1.0)
21
- rubocop (1.36.0)
22
+ regexp_parser (2.10.0)
23
+ rr (3.1.1)
24
+ rubocop (1.72.2)
22
25
  json (~> 2.3)
26
+ language_server-protocol (~> 3.17.0.2)
27
+ lint_roller (~> 1.1.0)
23
28
  parallel (~> 1.10)
24
- parser (>= 3.1.2.1)
29
+ parser (>= 3.3.0.2)
25
30
  rainbow (>= 2.2.2, < 4.0)
26
- regexp_parser (>= 1.8, < 3.0)
27
- rexml (>= 3.2.5, < 4.0)
28
- rubocop-ast (>= 1.20.1, < 2.0)
31
+ regexp_parser (>= 2.9.3, < 3.0)
32
+ rubocop-ast (>= 1.38.0, < 2.0)
29
33
  ruby-progressbar (~> 1.7)
30
- unicode-display_width (>= 1.4.0, < 3.0)
31
- rubocop-ast (1.21.0)
32
- parser (>= 3.1.1.0)
33
- ruby-progressbar (1.11.0)
34
+ unicode-display_width (>= 2.4.0, < 4.0)
35
+ rubocop-ast (1.38.0)
36
+ parser (>= 3.3.1.0)
37
+ ruby-progressbar (1.13.0)
34
38
  serialport (1.3.2)
35
- test-unit (3.5.3)
39
+ test-unit (3.6.7)
36
40
  power_assert
37
41
  test-unit-rr (1.0.5)
38
42
  rr (>= 1.1.1)
39
43
  test-unit (>= 2.5.2)
40
- unicode-display_width (2.3.0)
44
+ unicode-display_width (3.1.4)
45
+ unicode-emoji (~> 4.0, >= 4.0.4)
46
+ unicode-emoji (4.0.4)
41
47
 
42
48
  PLATFORMS
43
49
  ruby
data/README.md CHANGED
@@ -80,6 +80,74 @@ plc["DM0", 10].to_string()
80
80
 
81
81
  ```
82
82
 
83
+ ## Supported PLCs
84
+
85
+ ### Keyence
86
+
87
+ It supports Keyence PLCs with an Ethernet connection.
88
+
89
+ ```
90
+ plc = PlcAccess::Protocol::Keyence::KvProtocol.new host: '192.168.0.10', port: 8501
91
+ ```
92
+
93
+ ### Mitsubishi
94
+
95
+ It supports Mitsubishi PLCs with an Ethernet connection.
96
+
97
+ ```
98
+ plc = PlcAccess::Protocol::Mitsubishi::McProtocol.new host: '192.168.0.10', port: 5010
99
+ ```
100
+
101
+ It supports Mitsubishi Fx PLCs with a Serial connection.
102
+
103
+ ```
104
+ plc = PlcAccess::Protocol::Mitsubishi::FxProtocol.new port: /dev/tty.usbxxxxx'
105
+ ```
106
+
107
+ PLC configuration:
108
+ - baudrate: 19200
109
+ - bit: 7
110
+ - parity: Odd
111
+ - stop bit: 1
112
+
113
+ ![](images/fx_comm_setting.png)
114
+
115
+ ### Omron
116
+
117
+ It supports Omron PLCs with an Ethernet connection.
118
+
119
+ ```
120
+ plc = PlcAccess::Protocol::Omron::FinsTcpProtocol.new host: '192.168.0.10', port: 9600
121
+ ```
122
+
123
+ It supports Omron PLCs with a C Mode serial connection.
124
+
125
+ ```
126
+ plc = PlcAccess::Protocol::Omron::CModeProtocol.new port: /dev/tty.usbxxxxx'
127
+ ```
128
+
129
+ ### Plc Share
130
+
131
+ Plc Share is a protocol conversion application. It runs on Windows and connects to various PLCs using a serial or Ethernet connection. You can then connect with the Plc Share Protocol, which extends Keyence’s protocol. You can specify a target PLC’s device.
132
+
133
+ [Plc Share](http://iphone.itosoft.com/plcshare)
134
+
135
+ ![](images/plc_share.png)
136
+
137
+ ```
138
+ plc = PlcAccess::Protocol::PlcShare::PlcShareProtocol.new host: '192.168.0.10', port: 10000, device_type: :fx
139
+ ```
140
+
141
+ You can choose a target PLC by using the device type option.
142
+
143
+ |device_type|Target PLCs|
144
+ |:-:|:--|
145
+ |:kv|Keyence PLCs|
146
+ |:fx|Mitsubishi Fx PLCs|
147
+ |:q|Mitsubishi Q/L/R PLCs|
148
+ |:omron|Omron PLCs|
149
+
150
+
83
151
  ## Contributing
84
152
 
85
153
  Bug reports and pull requests are welcome on GitHub at https://github.com/ito-soft-design/plc_access. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ito-soft-design/plc_access/blob/master/CODE_OF_CONDUCT.md).
Binary file
Binary file
@@ -43,7 +43,7 @@ module ActAsType
43
43
  pack("f*").unpack("S*")
44
44
  end
45
45
 
46
- def as_string length=nil, encoding=Encoding::UTF_8
46
+ def to_string length=nil, encoding=Encoding::UTF_8
47
47
  s = pack("v*")
48
48
  if length
49
49
  s = s[0, length].delete("\000")
@@ -55,7 +55,7 @@ module ActAsType
55
55
 
56
56
  refine String do
57
57
 
58
- def to_ushort length=nil, encoding=Encoding::UTF_8
58
+ def as_ushort length=nil, encoding=Encoding::UTF_8
59
59
  a = self.encode(encoding).unpack("v*")
60
60
  return a unless length
61
61
 
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The MIT License (MIT)
4
+ #
5
+ # Copyright (c) 2025 ITO SOFT DESIGN Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining
8
+ # a copy of this software and associated documentation files (the
9
+ # "Software"), to deal in the Software without restriction, including
10
+ # without limitation the rights to use, copy, modify, merge, publish,
11
+ # distribute, sublicense, and/or sell copies of the Software, and to
12
+ # permit persons to whom the Software is furnished to do so, subject to
13
+ # the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be
16
+ # included in all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+
26
+ dir = __dir__
27
+ $LOAD_PATH.unshift dir unless $LOAD_PATH.include? dir
28
+
29
+ require 'socket'
30
+ require 'logger'
31
+ require 'timeout'
32
+ require 'plc_share_protocol'
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The MIT License (MIT)
4
+ #
5
+ # Copyright (c) 2025 ITO SOFT DESIGN Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining
8
+ # a copy of this software and associated documentation files (the
9
+ # "Software"), to deal in the Software without restriction, including
10
+ # without limitation the rights to use, copy, modify, merge, publish,
11
+ # distribute, sublicense, and/or sell copies of the Software, and to
12
+ # permit persons to whom the Software is furnished to do so, subject to
13
+ # the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be
16
+ # included in all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+
26
+ module PlcAccess
27
+ module Protocol
28
+ module PlcShare
29
+ class PlcShareProtocol < PlcAccess::Protocol::Keyence::KvProtocol
30
+ attr_accessor :device_type
31
+
32
+ def initialize(options = {})
33
+ super
34
+ @socket = nil
35
+ @host = options[:host] || '192.168.0.10'
36
+ @port = options[:port] || 10000
37
+ self.device_type = options[:device_type] if options[:device_type]
38
+ end
39
+
40
+ # Device type
41
+ # :kv Keyence device
42
+ # :fx Mitsubishi Fx device
43
+ # :q Mitsubishi Q/L device
44
+ # :omron Omron device
45
+ def device_type= type
46
+ @device_type = type
47
+ end
48
+
49
+ private
50
+
51
+ def device_class
52
+ case @device_type
53
+ when :kv
54
+ PlcAccess::Protocol::Keyence::KvDevice
55
+ when :fx
56
+ PlcAccess::Protocol::Mitsubishi::FxDevice
57
+ when :q
58
+ PlcAccess::Protocol::Mitsubishi::QDevice
59
+ when :omron
60
+ PlcAccess::Protocol::Omron::OmronDevice
61
+ else
62
+ PlcAccess::Protocol::Keyence::KvDevice
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+
@@ -217,3 +217,4 @@ require 'plc_device'
217
217
  require 'keyence/keyence'
218
218
  require 'mitsubishi/mitsubishi'
219
219
  require 'omron/omron'
220
+ require 'plc_share/plc_share'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlcAccess
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plc_access
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katsuyoshi Ito
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-11 00:00:00.000000000 Z
11
+ date: 2025-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: serialport
@@ -49,6 +49,8 @@ files:
49
49
  - Rakefile
50
50
  - bin/console
51
51
  - bin/setup
52
+ - images/fx_comm_setting.png
53
+ - images/plc_share.png
52
54
  - lib/plc_access.rb
53
55
  - lib/plc_access/act_as_type.rb
54
56
  - lib/plc_access/protocol/keyence/keyence.rb
@@ -64,6 +66,8 @@ files:
64
66
  - lib/plc_access/protocol/omron/omron.rb
65
67
  - lib/plc_access/protocol/omron/omron_device.rb
66
68
  - lib/plc_access/protocol/plc_device.rb
69
+ - lib/plc_access/protocol/plc_share/plc_share.rb
70
+ - lib/plc_access/protocol/plc_share/plc_share_protocol.rb
67
71
  - lib/plc_access/protocol/protocol.rb
68
72
  - lib/plc_access/version.rb
69
73
  - plc_access.gemspec
@@ -89,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
93
  - !ruby/object:Gem::Version
90
94
  version: '0'
91
95
  requirements: []
92
- rubygems_version: 3.4.22
96
+ rubygems_version: 3.4.19
93
97
  signing_key:
94
98
  specification_version: 4
95
99
  summary: The PlcAccess communicates with PLCs.