+
+class VymMap
+ def initialize(map, n )
+ @map = map
+
+ # Getting commands for model via DBUS
+ #if mapCount() > 0
+ # m = model(1)
+ s = @map.listCommands
+ puts "VymMap::initialize Retrieving commands via dbus..." if $debug
+ @model_commands = s[0].split ","
+ @model_commands.each do |c|
+ #puts "Creating map command: #{c}" if $debug
+ self.class.send(:define_method, c) do |*pars|
+ if pars.length == 0
+ # No parameters
+ com = "vym.currentMap().#{c}();"
+ puts " * Calling model: \"#{com}\":" if $debug
+ ret = @map.execute( com )
+ else
+ # Build string with parameters
+ p = "";
+ a = []
+ pars.each do |p|
+ if p.kind_of? String
+ a << "'#{p}'"
+ else
+ a << p
+ end
+ end
+ # com = "vym.clearConsole(); print( vym.currentMap().#{c} (#{a.join(',')}));"
+ com = " vym.currentMap().#{c} (#{a.join(',')});"
+ puts " ** Calling model: \"#{com}\":" if $debug
+ ret = @map.execute( com )
+ puts "Done calling" if $debug
+ end
+
+ #FIXME-2 err = m.errorLevel[0]
+ if $debug
+ puts " Returned: #{ret[0]}" if ret[0] != ""
+ #puts " Error: #{err}" if err > 0
+ end
+ ret[0]
+ end
+ end
+ end # Initialize
+end # VymMap
+