Class: AlphaSign

Inherits:
Object
  • Object
show all
Includes:
Format, Protocol
Defined in:
lib/alphasign.rb

Defined Under Namespace

Modules: Format, Protocol

Constant Summary

Constants included from Format

Format::CallDots, Format::CallString, Format::CharSet, Format::Color, Format::Count1, Format::Count2, Format::Count3, Format::Count4, Format::Count5, Format::DoubleHighOff, Format::DoubleHighOn, Format::Extended, Format::FixWidth, 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::FileType, Protocol::Footer, Protocol::Parity, Protocol::Preamble, Protocol::StartCMD, Protocol::StartHeader, Protocol::StopBits

Instance Method Summary collapse

Constructor Details

#initialize(device = "/dev/ttyS0") ⇒ AlphaSign

for now we only speak rs232

Parameters:

  • device (String) (defaults to: "/dev/ttyS0")

    the serial device the sign is connected to



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/alphasign.rb', line 14

def  initialize (device = "/dev/ttyS0")
  @device=SerialPort.new(device, Baud,  DataBits,  StopBits,  Parity) 
  @memsync=false
  # default file setup, we should read this from the device, for now
  # just enforce our own & hope no other process is messing with it
  # (that's why we're 0.x.x)
  @files={
    # 256 byte text file always displayed
    :default => AlphaFile.new(:txt, "A", "0100", "FF00"),
    # 80 byte string file
    :str1   => AlphaFile.new(:str, "B", "0050", "0000"),
    # another string file
    :str2   => AlphaFile.new(:str, "C", "0050", "0000"),
    # 16 (0x10) row by 120 (0x78) column dots file in 3 colors
    # not sure why but htat's what "2000" means in this context
    :dot1   => AlphaFile.new(:dot, "D", "1078", "2000"),
    # another dots file
    :dot2   => AlphaFile.new(:dot, "E", "1078", "2000"),
  }

  # 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 unit types, "00" is broadcast
  @addr = 'Z00'

  # write out initial memory config to sign
  writemem
end

Instance Method Details

#callstr(filename = :str1) ⇒ Object

this returns code to insert a named string file in txt file

Raises:

  • (ArgumentError)


82
83
84
85
# File 'lib/alphasign.rb', line 82

def callstr (filename=:str1)
  raise ArgumentError.new("filename must be a preconfigured as a string file in momory")unless @files[filename].type == :str
  CallString +  @files[filename].label
end

#write(msg, opts = { }) ⇒ Object

This is for writing “txt” files

Parameters:

  • msg (STRING)

    the message (text file in Alpha parlance)

  • opts (HASH) (defaults to: { })

    the write options

Options Hash (opts):

  • :position (Symbol)

    display position @see AlphaSign::Format::Position

Raises:

  • (ArgumentError)

See Also:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/alphasign.rb', line 50

def  write (msg, opts={ })

 # default to middle position
 opts[:position]=:middle unless opts[:position] 

 #default to static display
 opts[:mode]=:hold unless opts[:mode] 

 # sign file to write to, carefule these need to be setup before
 # they can be written to...
 opts[:filename]=:default unless opts [:filename]
 raise ArgumentError.new(":filename must be a preconfigured as a txt file in momory")unless @files[opts[:filename]].type == :txt
 
 @format = StartMode + Position[opts[:position]] + Mode[opts[:mode]]

 rawwrite  StartCMD[:wtxt]+ @files[opts[:filename]].label + @format + msg 
end

#writestr(msg, filename = :str1) ⇒ Object

write to a string file (this must then be called from a text file for display, but string files are buffered so good for frequent updates without flashing screen like txt files do defaults to “:str1” part of default memory config

Parameters:

  • msg (STRING)

    the message string

  • filename (Symbol) (defaults to: :str1)

    a key from @files hash for a configure :txt file

Raises:

  • (ArgumentError)

See Also:



76
77
78
79
# File 'lib/alphasign.rb', line 76

def writestr (msg,filename=:str1)
  raise ArgumentError.new("filename must be a preconfigured as a string file in momory")unless @files[filename].type == :str
  rawwrite StartCMD[:wstr] + @files[filename].label + msg
end