ruby-sml 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+ require 'ruby-sml/nilclass-mixin'
2
+ require 'ruby-sml/sml-tree'
3
+
4
+ module SML
5
+ module Attention
6
+
7
+ Errors = {}
8
+ Errors["\x81\x81\xc7\xc7\xfe\x00"] = "unknown error"
9
+ Errors["\x81\x81\xc7\xc7\xfe\x01"] = "unknown SML identifier"
10
+ Errors["\x81\x81\xc7\xc7\xfe\x02"] = "insufficient authentification, user/password invalid"
11
+ Errors["\x81\x81\xc7\xc7\xfe\x03"] = "target address (serverId) not available"
12
+ Errors["\x81\x81\xc7\xc7\xfe\x04"] = "request (reqFileId) not available"
13
+ Errors["\x81\x81\xc7\xc7\xfe\x05"] = "one or more target attributes could not be written"
14
+ Errors["\x81\x81\xc7\xc7\xfe\x06"] = "one or more target attributes could not be read"
15
+ Errors["\x81\x81\xc7\xc7\xfe\x07"] = "communication with metering point interrupted"
16
+ Errors["\x81\x81\xc7\xc7\xfe\x08"] = "raw data could not be interpreted"
17
+ Errors["\x81\x81\xc7\xc7\xfe\x09"] = "value out of range"
18
+ Errors["\x81\x81\xc7\xc7\xfe\x0a"] = "request not executed"
19
+ Errors["\x81\x81\xc7\xc7\xfe\x0b"] = "checksum incorrect"
20
+ Errors["\x81\x81\xc7\xc7\xfe\x0c"] = "broadcast not supported"
21
+ Errors["\x81\x81\xc7\xc7\xfe\x0d"] = "unexpected SML message"
22
+ Errors["\x81\x81\xc7\xc7\xfe\x0e"] = "unknown object in load curve"
23
+ Errors["\x81\x81\xc7\xc7\xfe\x0f"] = "unsupported data type in SetProcPar"
24
+ Errors["\x81\x81\xc7\xc7\xfe\x10"] = "optional element not supported"
25
+ Errors["\x81\x81\xc7\xc7\xfe\x11"] = "profile doesn't have any entries"
26
+ Errors["\x81\x81\xc7\xc7\xfe\x12"] = "end before begin"
27
+ Errors["\x81\x81\xc7\xc7\xfe\x13"] = "no entries in time frame"
28
+ Errors["\x81\x81\xc7\xc7\xfe\x14"] = "SML-Close missing"
29
+
30
+ Errors["\x81\x81\xc7\xc7\xfd\x00"] = "ok"
31
+ Errors["\x81\x81\xc7\xc7\xfd\x01"] = "execution delayed, response will be delivered via response-without-request"
32
+
33
+
34
+ class Response
35
+ attr_accessor :server_id, :number, :message, :details
36
+
37
+ def initialize(server_id, number, message, details)
38
+ @server_id = server_id
39
+ @number = number
40
+ @message = message
41
+ @details = details
42
+ end
43
+
44
+ def self.construct(array_rep)
45
+ return nil if array_rep.nil?
46
+ server_id = array_rep.shift
47
+ number = array_rep.shift
48
+ message = array_rep.shift
49
+ details = SML::Tree.construct(array_rep.shift)
50
+
51
+ return SML::Attention::Response.new(server_id, number, message, details)
52
+ end
53
+ def to_a
54
+ return [] << server_id << number << message < details.to_a
55
+ end
56
+
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,37 @@
1
+ require 'ruby-sml/nilclass-mixin'
2
+ require 'ruby-sml/sml-message'
3
+
4
+ module SML
5
+
6
+ class File
7
+ attr_accessor :messages
8
+
9
+ def initialize(messages)
10
+ @messages = messages
11
+ end
12
+
13
+ def self.construct(array_rep)
14
+ return nil if array_rep.nil?
15
+ messages = []
16
+ array_rep.each do |message_array|
17
+ message = SML::Message.construct(message_array)
18
+ return nil if message.nil?
19
+ messages << message
20
+ end
21
+
22
+ file = SML::File.new(messages)
23
+
24
+ return file
25
+ end
26
+ def to_a
27
+ result = []
28
+ messages.each do |message|
29
+ result << message.to_a
30
+ end
31
+
32
+ return result
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,88 @@
1
+ require 'ruby-sml/nilclass-mixin'
2
+ require 'ruby-sml/sml-tree'
3
+ require 'ruby-sml/sml-listentry'
4
+ require 'ruby-sml/sml-time'
5
+
6
+ module SML
7
+ module GetList
8
+
9
+ class Request
10
+ attr_accessor :client_id, :server_id, :username, :password, :list_name
11
+
12
+ def initialize(client_id, server_id, username, password, list_name)
13
+ @client_id = client_id
14
+ @server_id = server_id
15
+ @username = username
16
+ @password = password
17
+ @list_name = list_name
18
+ end
19
+
20
+ def self.construct(array_rep)
21
+ return nil if array_rep.nil?
22
+ client_id = array_rep.shift
23
+ server_id = array_rep.shift
24
+ username = array_rep.shift
25
+ password = array_rep.shift
26
+ list_name = array_rep.shift
27
+
28
+ return SML::GetList::Request.new(client_id, server_id, username, password, list_name)
29
+ end
30
+
31
+ def self.pconstrut(o={})
32
+ return SML::GetList::Request.new(o[:client_id], o[:server_id], o[:username], o[:password], o[:list_name])
33
+ end
34
+
35
+ def to_a
36
+ return [] << client_id << server_id << username << password << list_name
37
+ end
38
+
39
+ end
40
+
41
+ class Response
42
+ attr_accessor :client_id, :server_id, :list_name, :act_sensor_time, :value_list, :list_signature, :act_gateway_time
43
+
44
+ def initialize(client_id, server_id, list_name, act_sensor_time, value_list, list_signature, act_gateway_time)
45
+ @client_id = client_id
46
+ @server_id = server_id
47
+ @list_name = list_name
48
+ @act_sensor_time = act_sensor_time
49
+ @value_list = value_list
50
+ @list_signature = list_signature
51
+ @act_gateway_time = act_gateway_time
52
+ end
53
+
54
+ def self.construct(array_rep)
55
+ return nil if array_rep.nil?
56
+ client_id = array_rep.shift
57
+ server_id = array_rep.shift
58
+ list_name = array_rep.shift
59
+ act_sensor_time = SML::Time.construct(array_rep.shift)
60
+ value_list = []
61
+ array_rep.shift.each do |entry_array_rep|
62
+ entry = SML::ListEntry.construct(entry_array_rep)
63
+ return nil if entry.nil?
64
+ value_list << entry
65
+ end
66
+ list_signature = array_rep.shift
67
+ act_gateway_time = SML::Time.construct(array_rep.shift)
68
+
69
+ return SML::GetList::Response.new(client_id, server_id, list_name, act_sensor_time, value_list, list_signature, act_gateway_time)
70
+ end
71
+
72
+ def self.pconstruct(o={})
73
+ return SML::GetList::Response.new(o[:client_id], o[:server_id], o[:list_name], o[:act_sensor_time], o[:value_list], o[:list_signature], o[:act_gateway_time])
74
+ end
75
+
76
+ def to_a
77
+ value_list_array = []
78
+ value_list.each do |value|
79
+ value_list_array << value.to_a
80
+ end
81
+
82
+ return [] << client_id << server_id << list_name << act_sensor_time.to_a << value_list_array << list_signature << act_gateway_time.to_a
83
+ end
84
+
85
+ end
86
+
87
+ end
88
+ end
@@ -0,0 +1,61 @@
1
+ require 'ruby-sml/nilclass-mixin'
2
+ require 'ruby-sml/sml-treepath'
3
+ require 'ruby-sml/sml-tree'
4
+
5
+ module SML
6
+ module GetProcParameter
7
+
8
+ class Request
9
+ attr_accessor :server_id, :username, :password, :parameter_treepath, :attribute
10
+
11
+ def initialize(server_id, username, password, parameter_treepath, attribute)
12
+ @server_id = server_id
13
+ @username = username
14
+ @password = password
15
+ @parameter_treepath = parameter_treepath
16
+ @attribute = attribute
17
+ end
18
+
19
+ def self.construct(array_rep)
20
+ return nil if array_rep.nil?
21
+ server_id = array_rep.shift
22
+ username = array_rep.shift
23
+ password = array_rep.shift
24
+ parameter_treepath = SML::Treepath.construct(array_rep.shift)
25
+ attribute = array_rep.shift
26
+
27
+ return nil if parameter_treepath.nil?
28
+ return SML::GetProcParameter::Request.new(server_id, username, password, parameter_treepath, attribute)
29
+ end
30
+ def to_a
31
+ return [] << server_id << username << password << parameter_treepath.to_a << attribute
32
+ end
33
+
34
+ end
35
+
36
+ class Response
37
+ attr_accessor :server_id, :parameter_treepath, :parameter_tree
38
+
39
+ def initialize(server_id, parameter_treepath, parameter_tree)
40
+ @server_id = server_id
41
+ @parameter_treepath = parameter_treepath
42
+ @parameter_tree = parameter_tree
43
+ end
44
+
45
+ def self.construct(array_rep)
46
+ return nil if array_rep.nil?
47
+ server_id = array_rep.shift
48
+ parameter_treepath = SML::Treepath.construct(array_rep.shift)
49
+ parameter_tree = SML::Tree.construct(array_rep.shift)
50
+
51
+ return nil if (server_id.nil? or parameter_treepath.nil? or parameter_tree.nil?)
52
+ return SML::GetProcParameter::Response.new(server_id, parameter_treepath, parameter_tree)
53
+ end
54
+ def to_a
55
+ return [] << server_id << parameter_treepath.to_a << parameter_tree.to_a
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,103 @@
1
+ require 'ruby-sml/nilclass-mixin'
2
+ require 'ruby-sml/sml-time'
3
+ require 'ruby-sml/sml-treepath'
4
+ require 'ruby-sml/sml-periodentry'
5
+
6
+ module SML
7
+ module GetProfileList
8
+
9
+ class Request
10
+ attr_accessor :server_id, :username, :password, :with_raw_data, :begin_time, :end_time, :parameter_treepath, :object_list, :das_details
11
+
12
+ def initialize(server_id, username, password, with_raw_data, begin_time, end_time, parameter_treepath, object_list, das_details)
13
+ @server_id = server_id
14
+ @username = username
15
+ @password = password
16
+ @with_raw_data = with_raw_data
17
+ @begin_time = begin_time
18
+ @end_time = end_time
19
+ @parameter_treepath = parameter_treepath
20
+ @object_list = object_list
21
+ @das_details = das_details
22
+ end
23
+
24
+ def self.construct(array_rep)
25
+ return nil if array_rep.nil?
26
+ server_id = array_rep.shift
27
+ username = array_rep.shift
28
+ password = array_rep.shift
29
+ with_raw_data = array_rep.shift
30
+ array_rep.shift unless with_raw_data.nil?
31
+ begin_time = SML::Time.construct(array_rep.shift)
32
+ end_time = SML::Time.construct(array_rep.shift)
33
+ parameter_treepath = SML::Treepath.construct(array_rep.shift)
34
+ object_list = array_rep.shift
35
+ das_details = SML::Tree.construct(array_rep.shift)
36
+
37
+ return nil if parameter_treepath.nil?
38
+ return SML::GetProfileList::Request.new(server_id, username, password, with_raw_data, begin_time, end_time, parameter_treepath, object_list, das_details)
39
+ end
40
+ def to_a
41
+ result = [] << server_id << username << password << with_raw_data
42
+ result << :bool unless with_raw_data.nil?
43
+
44
+ return result << begin_time.to_a << end_time.to_a << parameter_treepath.to_a << object_list << das_details.to_a
45
+ end
46
+
47
+ end
48
+
49
+ class Response
50
+ attr_accessor :server_id, :act_time, :registration_period, :parameter_treepath, :val_time, :status, :period_list, :raw_data, :period_signature
51
+
52
+ def initialize(server_id, act_time, registration_period, parameter_treepath, val_time, status, period_list, raw_data, period_signature)
53
+ @server_id = server_id
54
+ @act_time = act_time
55
+ @registration_period = registration_period
56
+ @parameter_treepath = parameter_treepath
57
+ @val_time = val_time
58
+ @status = status
59
+ @period_list = period_list
60
+ @raw_data = raw_data
61
+ @period_signature = period_signature
62
+ end
63
+
64
+ def self.construct(array_rep)
65
+ return nil if array_rep.nil?
66
+ server_id = array_rep.shift
67
+ act_time = SML::Time.construct(array_rep.shift)
68
+ registration_period = array_rep.shift
69
+ array_rep.shift unless registration_period.nil?
70
+ parameter_treepath = SML::Treepath.construct(array_rep.shift)
71
+ val_time = SML::Time.construct(array_rep.shift)
72
+ status = array_rep.shift
73
+ array_rep.shift unless status.nil?
74
+ period_list = []
75
+ array_rep.shift.each do |entry_array_rep|
76
+ entry = SML::PeriodEntry.construct(entry_array_rep)
77
+ return nil if entry.nil?
78
+ period_list << entry
79
+ end
80
+ raw_data = array_rep.shift
81
+ period_signature = array_rep.shift
82
+
83
+ return nil if (act_time.nil? or parameter_treepath.nil? or val_time.nil?)
84
+ return SML::GetProfileList::Response.new(server_id, act_time, registration_period, parameter_treepath, val_time, status, period_list, raw_data, period_signature)
85
+ end
86
+ def to_a
87
+ period_list_array = []
88
+ period_list.each do |entry|
89
+ period_list_array << entry.to_a
90
+ end
91
+
92
+ result = [] << server_id << act_time.to_a << registration_period
93
+ result << :uint32 unless registration_period.nil?
94
+ result << parameter_treepath.to_a << val_time.to_a << status
95
+ result << :uint64 unless status.nil?
96
+
97
+ return result << period_list_array << raw_data << period_signature
98
+ end
99
+
100
+ end
101
+
102
+ end
103
+ end
@@ -0,0 +1,107 @@
1
+ require 'ruby-sml/nilclass-mixin'
2
+ require 'ruby-sml/sml-time'
3
+ require 'ruby-sml/sml-treepath'
4
+ require 'ruby-sml/sml-tree'
5
+ require 'ruby-sml/sml-profileobjectheaderentry'
6
+ require 'ruby-sml/sml-profileobjectperiodentry'
7
+
8
+ module SML
9
+ module GetProfilePack
10
+
11
+ class Request
12
+ attr_accessor :server_id, :username, :password, :with_raw_data, :begin_time, :end_time, :parameter_treepath, :object_list, :das_details
13
+
14
+ def initialize(server_id, username, password, with_raw_data, begin_time, end_time, parameter_treepath, object_list, das_details)
15
+ @server_id = server_id
16
+ @username = username
17
+ @password = password
18
+ @with_raw_data = with_raw_data
19
+ @begin_time = begin_time
20
+ @end_time = end_time
21
+ @parameter_treepath = parameter_treepath
22
+ @object_list = object_list
23
+ @das_details = das_details
24
+ end
25
+
26
+ def self.construct(array_rep)
27
+ return nil if array_rep.nil?
28
+ server_id = array_rep.shift
29
+ username = array_rep.shift
30
+ password = array_rep.shift
31
+ with_raw_data = array_rep.shift
32
+ array_rep.shift unless with_raw_data.nil?
33
+ begin_time = SML::Time.construct(array_rep.shift)
34
+ end_time = SML::Time.construct(array_rep.shift)
35
+ parameter_treepath = SML::Treepath.construct(array_rep.shift)
36
+ object_list = array_rep.shift
37
+ das_details = SML::Tree.construct(array_rep.shift)
38
+
39
+ return nil if parameter_treepath.nil?
40
+ return SML::GetProfilePack::Request.new(server_id, username, password, with_raw_data, begin_time, end_time, parameter_treepath, object_list, das_details)
41
+ end
42
+ def to_a
43
+ result = [] << server_id << username << password << with_raw_data
44
+ result << :bool unless with_raw_data.nil?
45
+ return result << begin_time.to_a << end_time.to_a << parameter_treepath.to_a << object_list << das_details.to_a
46
+ end
47
+
48
+ end
49
+
50
+ class Response
51
+ attr_accessor :server_id, :act_time, :register_period, :parameter_treepath, :header_list, :period_list, :raw_data, :profile_signature
52
+
53
+ def initialize(server_id, act_time, register_period, parameter_treepath, header_list, period_list, raw_data, profile_signature)
54
+ @server_id = server_id
55
+ @act_time = act_time
56
+ @register_period = register_period
57
+ @parameter_treepath = parameter_treepath
58
+ @header_list = header_list
59
+ @period_list = period_list
60
+ @raw_data = raw_data
61
+ @profile_signature = profile_signature
62
+ end
63
+
64
+ def self.construct(array_rep)
65
+ return nil if array_rep.nil?
66
+ server_id = array_rep.shift
67
+ act_time = SML::Time.construct(array_rep.shift)
68
+ registration_period = array_rep.shift
69
+ array_rep.shift unless registration_period.nil?
70
+ parameter_treepath = SML::Treepath.construct(array_rep.shift)
71
+ header_list = []
72
+ array_rep.shift.each do |entry_array_rep|
73
+ entry = SML::ProfileObjectHeaderEntry.construct(entry_array_rep)
74
+ return nil if entry.nil?
75
+ header_list << entry
76
+ end
77
+ period_list = []
78
+ array_rep.shift.each do |entry_array_rep|
79
+ entry = SML::ProfileObjectPeriodEntry.construct(entry_array_rep)
80
+ return nil if entry.nil?
81
+ period_list << entry
82
+ end
83
+ raw_data = array_rep.shift
84
+ profile_signature = array_rep.shift
85
+
86
+ return nil if (act_time.nil? or parameter_treepath.nil?)
87
+ return SML::GetProfilePack::Response.new(server_id, act_time, registration_period, parameter_treepath, header_list, period_list, raw_data, profile_signature)
88
+ end
89
+ def to_a
90
+ header_list_array = []
91
+ header_list.each do |entry|
92
+ header_list_array << entry.to_a
93
+ end
94
+ period_list_array = []
95
+ period_list.each do |entry|
96
+ period_list_array << entry.to_a
97
+ end
98
+
99
+ result = [] << server_id << act_time.to_a << registration_period
100
+ result << :uint32 unless registration_period.nil?
101
+ return result << parameter_treepath.to_a << header_list_array << period_list_array << raw_data << profile_signature
102
+ end
103
+
104
+ end
105
+
106
+ end
107
+ end