class MovingsignApi::WriteTextCommand

Writes text to a sign

Attributes

align_mode[RW]

Align mode to use. See {AlignMode}

@param value [Symbol] One of :left :right :center (default :left)

dayofweek_mask[RW]

Day of week mask. See specification for an explaination of this parameter

@param value [String] default: +'7F'+

display_mode[RW]

Display mode to use. See {DisplayMode}

@param value [Sybol] (default: :hold)

display_pause[RW]

Display pause between screens of information. See {DisplayPause}

@param value [Integer] default: 2

display_speed[RW]

Display speed of effects. See {DisplaySpeed}

@param value [Symbol] default: :normal

end_time[RW]

Display end time @note work in progress

@param value [String] default: +'2359'+

file_handle[RW]

Index of the file to write to. 0 - 35 (363 total). See {FileHandle}

@param value [Integer] 0 - 35 (default: 0)

start_time[RW]

Display start time @note work in progress

@param value [String] default: +'0000'+

text[RW]

Text to display

@param value [String] the message to display

Public Instance Methods

align_mode=(align) click to toggle source
# File lib/movingsign_api/commands/write_text_command.rb, line 74
def align_mode=(align)
  @align_mode = AlignMode.parse(align)
end
command_code() click to toggle source

(see Command#command_code) 'A' for the “Write Text” command

# File lib/movingsign_api/commands/write_text_command.rb, line 80
def command_code
  'A'
end
display_mode=(mode) click to toggle source
# File lib/movingsign_api/commands/write_text_command.rb, line 62
def display_mode=(mode)
  @display_mode = DisplayMode.parse(mode)
end
display_pause=(seconds) click to toggle source
# File lib/movingsign_api/commands/write_text_command.rb, line 70
def display_pause=(seconds)
  @display_pause = DisplayPause.new seconds
end
display_speed=(speed) click to toggle source
# File lib/movingsign_api/commands/write_text_command.rb, line 66
def display_speed=(speed)
  @display_speed = DisplaySpeed.parse(speed)
end
file_handle=(handle) click to toggle source
# File lib/movingsign_api/commands/write_text_command.rb, line 58
def file_handle=(handle)
  @file_handle = FileHandle.new(handle)
end

Private Instance Methods

command_payload_bytes() click to toggle source
# File lib/movingsign_api/commands/write_text_command.rb, line 86
def command_payload_bytes
  # set defaults if needed
  self.file_handle      ||= 0
  self.display_mode     ||= :hold
  self.display_speed    ||= :normal
  self.display_pause    ||= 2
  self.dayofweek_mask   ||= '7F'
  self.align_mode       ||= :left
  self.start_time       ||= '0000'
  self.end_time         ||= '2359'
  raise InvalidInputError, "text not set" unless self.text

  bytes = []

  bytes.concat self.file_handle.to_bytes     # Filename
  bytes.concat self.display_mode.to_bytes           # Display Mode
  bytes.concat self.display_speed.to_bytes           # Display Speed
  bytes.concat self.display_pause.to_bytes           # Display Pause
  bytes.concat string_to_ascii_bytes(self.dayofweek_mask)           # Show Date
  bytes.concat string_to_ascii_bytes(self.start_time)           # Start Time
  bytes.concat string_to_ascii_bytes(self.end_time)           # End Time
  bytes.concat string_to_ascii_bytes('000')           # Reserved
  bytes.concat self.align_mode.to_bytes           # Align Mode
  #bytes.concat string_to_ascii_bytes("\xFD\x42" + self.text.gsub("\n", "\x7F"))           # Text
  bytes.concat string_to_ascii_bytes(self.text)           # Text

  bytes
end