ruby-sml 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,84 @@
1
+ # encoding: UTF-8
2
+
3
+ module SML
4
+ Units = []
5
+
6
+ Units[1] = { "id" => :year, "unit" => "a", "quantity" => "Time", "name" => "Year" }
7
+ Units[2] = { "id" => :month, "unit" => "mo", "quantity" => "Time", "name" => "Month" }
8
+ Units[3] = { "id" => :week, "unit" => "wk", "quantity" => "Time", "name" => "Week" }
9
+ Units[4] = { "id" => :day, "unit" => "d", "quantity" => "Time", "name" => "Day" }
10
+ Units[5] = { "id" => :hour, "unit" => "h", "quantity" => "Time", "name" => "Hour" }
11
+
12
+ Units[6] = { "id" => :minute, "unit" => "min.", "quantity" => "Time", "name" => "Minute" }
13
+ Units[7] = { "id" => :second, "unit" => "s", "quantity" => "Time", "name" => "Second" }
14
+ Units[8] = { "id" => :degree, "unit" => "°", "quantity" => "Angle", "name" => "Degree" }
15
+ Units[9] = { "id" => :celsius, "unit" => "°C", "quantity" => "Temperature", "name" => "Degree Celsius" }
16
+ Units[10] = { "id" => :currency, "unit" => "currency", "quantity" => "(local) Currency", "name" => "" }
17
+
18
+ Units[11] = { "id" => :metre, "unit" => "m", "quantity" => "Length", "name" => "Metre" }
19
+ Units[12] = { "id" => :metre_second, "unit" => "m/s", "quantity" => "Speed", "name" => "Metre per Second" }
20
+ Units[13] = { "id" => :cubicmetre, "unit" => "m³", "quantity" => "Volume", "name" => "Cubic Metre" }
21
+ Units[14] = { "id" => :cubicmetre_c, "unit" => "m³", "quantity" => "Corrected Volume", "name" => "Cubic Metre" }
22
+ Units[15] = { "id" => :cubicmetre_hour, "unit" => "m³/h", "quantity" => "Volume Flux", "name" => "Cubic Metre per Hour" }
23
+
24
+ Units[16] = { "id" => :cubicmetre_hour_c, "unit" => "m³/h", "quantity" => "Corrected Volume Flux", "name" => "Cubic Metre per Hour" }
25
+ Units[17] = { "id" => :cubicmetre_day, "unit" => "m³/d", "quantity" => "Volume Flux", "name" => "Cubic Metre per Day" }
26
+ Units[18] = { "id" => :cubicmetre_day_c, "unit" => "m³/d", "quantity" => "Corrected Volume Flux", "name" => "Cubic Metre per Day" }
27
+ Units[19] = { "id" => :litre, "unit" => "l", "quantity" => "Volume", "name" => "Litre" }
28
+ Units[20] = { "id" => :kilogram, "unit" => "kg", "quantity" => "Mass", "name" => "Kilogram" }
29
+
30
+ Units[21] = { "id" => :newton, "unit" => "N", "quantity" => "Force", "name" => "Newton" }
31
+ Units[22] = { "id" => :newtonmeter, "unit" => "Nm", "quantity" => "Energy", "name" => "Newtonmeter" }
32
+ Units[23] = { "id" => :pascal, "unit" => "Pa", "quantity" => "Pressure", "name" => "Pascal" }
33
+ Units[24] = { "id" => :bar, "unit" => "bar", "quantity" => "Pressure", "name" => "Bar" }
34
+ Units[25] = { "id" => :joule, "unit" => "J", "quantity" => "Energe", "name" => "Joule" }
35
+
36
+ Units[26] = { "id" => :joule_hour, "unit" => "J/h", "quantity" => "Thermal Power", "name" => "Joule per Hour" }
37
+ Units[27] = { "id" => :watt, "unit" => "W", "quantity" => "Active Power", "name" => "Watt" }
38
+ Units[28] = { "id" => :voltampere, "unit" => "VA", "quantity" => "Apparent Power", "name" => "Volt-Ampere" }
39
+ Units[29] = { "id" => :var, "unit" => "var", "quantity" => "Reactive Power", "name" => "var" }
40
+ Units[30] = { "id" => :watthour, "unit" => "Wh", "quantity" => "Active Energy", "name" => "Watt-Hour" }
41
+
42
+ Units[31] = { "id" => :voltamperehour, "unit" => "VAh", "quantity" => "Apparent Energy", "name" => "Volt-Ampere-Hour" }
43
+ Units[32] = { "id" => :varhour, "unit" => "varh", "quantity" => "Reactive Energy", "name" => "Var-Hour" }
44
+ Units[33] = { "id" => :ampere, "unit" => "A", "quantity" => "Current", "name" => "Ampere" }
45
+ Units[34] = { "id" => :coulomb, "unit" => "C", "quantity" => "Electrical Charge", "name" => "Coulomb" }
46
+ Units[35] = { "id" => :volt, "unit" => "V", "quantity" => "Voltage", "name" => "Volt" }
47
+
48
+ Units[36] = { "id" => :volt_metre, "unit" => "V/m", "quantity" => "Eletric Field Strength", "name" => "Volt per Metre" }
49
+ Units[37] = { "id" => :farad, "unit" => "F", "quantity" => "Capacitance", "name" => "Farad" }
50
+ Units[38] = { "id" => :ohm, "unit" => "Ω", "quantity" => "Resistance", "name" => "Ohm" }
51
+ Units[39] = { "id" => :ohm_metre, "unit" => "Ωm²/m", "quantity" => "Resistivity", "name" => "Ohm-Metre" }
52
+ Units[40] = { "id" => :weber, "unit" => "Wb", "quantity" => "Magnetic Flux", "name" => "Weber" }
53
+
54
+ Units[41] = { "id" => :tesla, "unit" => "T", "quantity" => "Magnetic Flux Density", "name" => "Tesla" }
55
+ Units[42] = { "id" => :ampere_metre, "unit" => "A/m", "quantity" => "Magnetic Field Strength", "name" => "Ampere per Metre" }
56
+ Units[43] = { "id" => :henry, "unit" => "H", "quantity" => "Inductance", "name" => "Henry" }
57
+ Units[44] = { "id" => :hertz, "unit" => "Hz", "quantity" => "Frequency", "name" => "Hertz" }
58
+ Units[45] = { "id" => :one_watthour, "unit" => "1/(Wh)", "quantity" => "R_W, Active Energy Meter Constant or Pulse Value", "name" => "" }
59
+
60
+ Units[46] = { "id" => :one_varhour, "unit" => "1/(varh)", "quantity" => "R_B, Reactive Energy Meter Constant or Pulse Value", "name" => "" }
61
+ Units[47] = { "id" => :one_voltamperehour, "unit" => "1/(VAh)", "quantity" => "R_S, Apparent Energy Meter Constant or Pulse Value", "name" => "" }
62
+ Units[48] = { "id" => :voltsquaredhours, "unit" => "V²h", "quantity" => "Volt-squared Hour", "name" => "Volt-Squared-Hours" }
63
+ Units[49] = { "id" => :amperesquaredhours, "unit" => "A²h", "quantity" => "Ampere-squared hour", "name" => "Ampere-Squared-Hours" }
64
+ Units[50] = { "id" => :kilogram_second, "unit" => "kg/s", "quantity" => "Mass Flux", "name" => "Kilogram per Second" }
65
+
66
+ Units[51] = { "id" => :siemens, "unit" => "S", "quantity" => "Conductance", "name" => "Siemens" }
67
+ Units[52] = { "id" => :kelvin, "unit" => "K", "quantity" => "Temperature", "name" => "Kelvin" }
68
+ Units[53] = { "id" => :one_voltsquaredhour, "unit" => "1/(V²h)", "quantity" => "R_U2h, Volt-Squared Hour Meter Constant or Pulse Value", "name" => "" }
69
+ Units[54] = { "id" => :one_amperesquaredhour, "unit" => "1/(A²h)", "quantity" => "R_I2h, Ampere-Squared Hour Meter Constant or Pulse Value", "name" => "" }
70
+ Units[55] = { "id" => :one_cubicmetre, "unit" => "1/m³", "quantity" => "R_V, Meter Constant or Pulse Value (Volume)", "name" => "" }
71
+
72
+ Units[56] = { "id" => :percent, "unit" => "%", "quantity" => "Percentage", "name" => "Percent" }
73
+ Units[57] = { "id" => :amperehour, "unit" => "Ah", "quantity" => "Ampere-Hours", "name" => "Ampere-Hour" }
74
+ Units[60] = { "id" => :watthour_cubicmetre, "unit" => "Wh/m³", "quantity" => "Energy per Volume", "name" => "Watthour per Cubic Metre" }
75
+
76
+ Units[61] = { "id" => :joule_cubicmetre, "unit" => "J/m³", "quantity" => "Calorific Value, Wobbe", "name" => "Joule per Cubic Metre" }
77
+ Units[62] = { "id" => :molpercent, "unit" => "Mol %", "quantity" => "Molar Fraction of Gas Composition", "name" => "Mole Percent" }
78
+ Units[63] = { "id" => :gram_cubicmetre, "unit" => "g/m³", "quantity" => "Mass Density", "name" => "Gram per Cubic Metre" }
79
+ Units[64] = { "id" => :pascalsecond, "unit" => "Pa s", "quantity" => "Dynamic Viscosity", "name" => "Pascal Second" }
80
+
81
+ Units[254] = { "id" => :other, "unit" => "other", "quantity" => "Other Unit", "name" => "" }
82
+ Units[255] = { "id" => :count, "unit" => "count", "quantity" => "Count, unitless", "name" => "" }
83
+
84
+ end
@@ -0,0 +1,66 @@
1
+ require 'pp'
2
+
3
+ $: << "./lib/ruby-sml"
4
+
5
+ require 'transport-binary'
6
+ require 'encoding-binary'
7
+ require 'sml-file'
8
+
9
+ @inputFile = "test-data/request.sml"
10
+ @outputFile = "test-data/request_processed.sml"
11
+
12
+ io = File.open(@inputFile, 'rb')
13
+
14
+ encodedFile = SML::BinaryTransport.readfile(io)
15
+ if encodedFile.nil?
16
+ puts "binary transport checksum invalid, exiting"
17
+ io.close
18
+ exit 1
19
+ end
20
+ puts "Encoded File:"
21
+ count = 0
22
+ encodedFile.each_byte do |byte|
23
+ print "0x%02x " % byte
24
+ count += 1
25
+ if count > 7
26
+ count = 0
27
+ puts
28
+ end
29
+ end
30
+ puts
31
+ puts "-------------"
32
+
33
+ io.close
34
+
35
+ decodedFile = SML::BinaryEncoding.decode_file(encodedFile)
36
+ puts "Decoded File:"
37
+ pp decodedFile
38
+ puts "-------------"
39
+
40
+ sml_file = SML::File.construct(decodedFile)
41
+ puts "Parsed File:"
42
+ pp sml_file
43
+ puts "-------------"
44
+
45
+ sml_file_array_rep = sml_file.to_a
46
+ puts "Unparsed File:"
47
+ pp sml_file_array_rep
48
+ puts "-------------"
49
+
50
+ reencodedFile = SML::BinaryEncoding.encode_file(sml_file_array_rep)
51
+ puts "Reencoded File:"
52
+ count = 0
53
+ reencodedFile.each_byte do |byte|
54
+ print "0x%02x " % byte
55
+ count += 1
56
+ if count > 7
57
+ count = 0
58
+ puts
59
+ end
60
+ end
61
+ puts
62
+ puts "-------------"
63
+
64
+ io_out = File.open(@outputFile, 'wb')
65
+ SML::BinaryTransport.writefile(io_out, reencodedFile)
66
+ io_out.close
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-sml
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: "0.2"
6
+ platform: ruby
7
+ authors:
8
+ - Prof. MAAD
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2010-05-27 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: " ruby-sml implements the Smart Messaging Language specification 1.3 (http://www.vde.de/de/fnn/arbeitsgebiete/messwesen/documents/Spezifikation_SML_1-03.pdf) in pure ruby. So far, only transport protocol v1 is supported.\n"
17
+ email: himself@prof-maad.org
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/ruby-sml/transport-binary.rb
26
+ - lib/ruby-sml/sml-message.rb
27
+ - lib/ruby-sml/helpers.rb
28
+ - lib/ruby-sml/sml-tree.rb
29
+ - lib/ruby-sml/sml-profileobjectheaderentry.rb
30
+ - lib/ruby-sml/sml-file.rb
31
+ - lib/ruby-sml/sml-getprofilepack.rb
32
+ - lib/ruby-sml/sml-attention.rb
33
+ - lib/ruby-sml/sml-getlist.rb
34
+ - lib/ruby-sml/sml-treepath.rb
35
+ - lib/ruby-sml/sml-publicclose.rb
36
+ - lib/ruby-sml/sml-profileobjectperiodentry.rb
37
+ - lib/ruby-sml/sml-procparametervalue.rb
38
+ - lib/ruby-sml/sml-getprofilelist.rb
39
+ - lib/ruby-sml/sml-valueentry.rb
40
+ - lib/ruby-sml/nilclass-mixin.rb
41
+ - lib/ruby-sml/sml-listentry.rb
42
+ - lib/ruby-sml/units.rb
43
+ - lib/ruby-sml/obis.rb
44
+ - lib/ruby-sml/sml-setprocparameter.rb
45
+ - lib/ruby-sml/sml-getprocparameter.rb
46
+ - lib/ruby-sml/sml-publicopen.rb
47
+ - lib/ruby-sml/crc16.rb
48
+ - lib/ruby-sml/sml-time.rb
49
+ - lib/ruby-sml/sml-periodentry.rb
50
+ - lib/ruby-sml/sml-tupelentry.rb
51
+ - lib/ruby-sml/encoding-binary.rb
52
+ - lib/ruby-sml/sml-messagebody.rb
53
+ - lib/ruby-sml.rb
54
+ - sample.rb
55
+ - README.md
56
+ - LICENSE
57
+ homepage: https://prof-maad.org
58
+ licenses:
59
+ - BSD
60
+ post_install_message:
61
+ rdoc_options: []
62
+
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project:
80
+ rubygems_version: 1.8.5
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Pure ruby implementation of the Smart Messaging Language protocol
84
+ test_files: []
85
+