Class: AlphaSign
Defined Under Namespace
Constant Summary
Constants included from Format
Format::CharSet, Format::Color, Format::Count1, Format::Count2, Format::Count3, Format::Count4, Format::Count5, Format::DoubleHighOff, Format::DoubleHighOn, Format::Extended, Format::FlashCharOff, Format::FlashCharOn, Format::Mode, Format::Position, Format::Speed, Format::StartMode, Format::TempC, Format::TempF, Format::TrueDecendersOff, Format::TrueDecendersOn
Constants included from Protocol
Protocol::Baud, Protocol::DataBits, Protocol::Footer, Protocol::Parity, Protocol::Preamble, Protocol::StartCMD, Protocol::StartHeader, Protocol::StopBits
Instance Method Summary collapse
-
#initialize(device = "/dev/ttyS0") ⇒ AlphaSign
constructor
for now we only speak rs232.
-
#rawwrite(msg) ⇒ Object
raw serial port for testing this will go away (or atleast become private).
-
#write(msg, opts = { }) ⇒ Object
we don’t have an open yet so this still kludgey and enfoces using only :wtxt command as thats the only one we know we can do @param for control characters for color, font, etc.
Constructor Details
#initialize(device = "/dev/ttyS0") ⇒ AlphaSign
for now we only speak rs232
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/alphasign.rb', line 14 def initialize (device = "/dev/ttyS0") @device= device # Protocol allows multiple signs on the same port, we are not # going to expose that possibility yet but we will recognize this # as an instance variable Where "Z" all units, "00" first unit or # broadcast? @addr = [ 'Z00' ].pack('A3') end |
Instance Method Details
#rawwrite(msg) ⇒ Object
raw serial port for testing this will go away (or atleast become private)
60 61 62 63 64 65 |
# File 'lib/alphasign.rb', line 60 def rawwrite (msg) sp=SerialPort.new(@device, Baud, DataBits, StopBits, Parity) sp.write msg sp.close end |
#write(msg, opts = { }) ⇒ Object
we don’t have an open yet so this still kludgey and enfoces using only :wtxt command as thats the only one we know we can do @param for control characters for color, font, etc. or nil (for comand modes that don’t use it) any value from 0x20 to 0x75 except 0x30 which is reserved
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/alphasign.rb', line 35 def write (msg, opts={ }) opts[:position]=:middle unless opts[:position] # default to middle position opts[:mode]=:hold unless opts[:mode] #default to static display opts[:fileLabel] = 0x41 unless opts[:fileLabel] #this was default in exampelso why not.. raise ArgumentError.new("unkown position #{opts[:position]}") unless Position.has_key?(opts[:position]) raise ArgumentError.new("unkown mode #{opts[:mode]}") unless Mode.has_key?(opts[:mode]) raise ArgumentError.new("invalid File Label specification") unless (opts[:fileLabel] == nil) or ((opts[:fileLabel].kind_of? Integer) and ( opts[:fileLabel] >= 0x20 and opts[:fileLabel] <= 0x75 and opts[:fileLabel] != 0x30)) if opts[:fileLabel] == nil @filelabel="" else @filelabel=[opts[:fileLabel]].pack("C") end @alphaFormat = StartMode + Position[opts[:position]] + Mode[opts[:mode]] @alphaHeader = StartHeader + @addr + StartCMD[:wtxt] + @filelabel + @alphaFormat sp=SerialPort.new(@device, Baud, DataBits, StopBits, Parity) sp.write @alphaHeader sp.write msg sp.write Footer sp.close end |