Module: Ardtweeno

Defined in:
lib/ardtweeno.rb,
lib/ardtweeno/db.rb,
lib/ardtweeno/api.rb,
lib/ardtweeno/node.rb,
lib/ardtweeno/packet.rb,
lib/ardtweeno/dispatcher.rb,
lib/ardtweeno/exceptions.rb,
lib/ardtweeno/ringbuffer.rb,
lib/ardtweeno/nodemanager.rb,
lib/ardtweeno/configreader.rb,
lib/ardtweeno/serialparser.rb

Overview

Ardtweeno Mesh Network Application Gateway

Software Gateway to allow collecting/broadcasting to/from a Mesh Network over serial. All data is stored to a database by default to allow later analysis and inclusion in automated reports generated by the system.

Defined Under Namespace

Classes: API, AlreadyWatched, ConfigReader, DB, DBError, Dispatcher, InvalidData, InvalidWatch, ManagerNotDefined, Node, NodeManager, NodeNotAuthorised, NotANode, NotAPacket, NotInNodeList, Packet, PacketListEmpty, RingBuffer, SensorException, SerialDeviceNotFound, SerialParser

Constant Summary collapse

VERSION =

Constants

"0.5.0"
CONFIGPATH =
ENV['HOME'] + "/.ardtweeno"
DBPATH =
Ardtweeno::CONFIGPATH + "/conf.yaml"
NODEPATH =
Ardtweeno::CONFIGPATH + "/nodelist.yaml"
POSTPATH =
Ardtweeno::CONFIGPATH + "/posts.yaml"
@@seqCount =

Class Variables

0
@@options =
{}

Class Method Summary collapse

Class Method Details

.nextSeqObject

Ardtweeno#nextSeq returns the next available sequence number

  • Args :

    • ++ ->

  • Returns :

    • Fixnum

  • Raises : -



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/ardtweeno.rb', line 88

def nextSeq()
  @log = @@options[:log] ||= Logger.new(STDOUT)
  @log.level = @@options[:level] ||= Logger::DEBUG     
  
  @log.debug "Current Sequence Number: " + @@seqCount.to_s    
  theSeq = @@seqCount
  @@seqCount += 1
  @log.debug "Current Sequence Number Incremented: " + @@seqCount.to_s
  
  return theSeq
end

.optionsObject

Ardtweeno#options returns the options hash

  • Args :

    • ++ ->

  • Returns :

    • Hash

  • Raises : -



73
74
75
# File 'lib/ardtweeno.rb', line 73

def options()
  return @@options
end

.setup(theoptions = {}) ⇒ Object

Setup the system for the first time



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/ardtweeno.rb', line 102

def setup(theoptions={})
  @@options = theoptions
  
  @log = @@options[:log] ||= Logger.new(STDOUT)
  @log.level = @@options[:level] ||= Logger::DEBUG
  
  if @@options[:test]
    @log.debug "Ardtweeno is running test mode"
  end    
  
  @log.debug "Checking to see if the configuration folder exists."
  resourceDir = Ardtweeno::CONFIGPATH
  @log.debug resourceDir
  
  if File.directory?(resourceDir) 
    @log.debug "The folder already exists, do nothing."
  else
    @log.debug "Creating ~/.ardtweeno/ and installing the resources there."
    
    begin
      FileUtils.mkdir(resourceDir)
      dbpath = File.expand_path(File.dirname(__FILE__) + '/../resources/conf.yaml')
      nodepath = File.expand_path(File.dirname(__FILE__) + '/../resources/nodelist.yaml')
      postpath = File.expand_path(File.dirname(__FILE__) + '/../resources/posts.yaml')
      FileUtils.cp(dbpath, resourceDir)
      FileUtils.cp(nodepath, resourceDir)
      FileUtils.cp(postpath, resourceDir)
      @log.debug "Successfully copied ~/.ardtweeno/conf.yaml"
      @log.debug "Successfully copied ~/.ardtweeno/nodelist.yaml"
      @log.debug "Successfully copied ~/.ardtweeno/posts.yaml"
    rescue Exception => e
      @log.fatal e.message
      @log.fatal e.backtrace
      exit()
    end
  end
  
end