Main Page   Hardware Class Hierarchy   Hardware API     Mapping Class Hierarchy  Mapping API 

dns.h

Go to the documentation of this file.
00001 /*
00002 Object Oriented Mobile Robot Model (OOMRM) C++  Library Copyright (C) 2007  Derek Jones
00003 
00004 This library is free software; you can redistribute it  and/or
00005 modify it under the terms of the GNU Lesser General Public
00006 License  as published by the Free Software Foundation; either
00007 version 2.1 of the  License, or (at your option) any later version.
00008 
00009 This library is  distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY;  without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A  PARTICULAR PURPOSE.  See the GNU
00012 Lesser General Public License for more  details.
00013 
00014 You should have received a copy of the GNU Lesser General  Public
00015 License along with this library; if not, write to the Free  Software
00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   02111-1307  USA
00017 
00018 
00019  $Id: dns.h,v 1.1 2007/06/10 23:15:00 derek Exp $
00020 
00021 Implementation Notes:
00022   Have a transmit method that will resolve device name to Jaus address.
00023 
00024    The only drawback to this method is the instances have to be specified whereas
00025 usually I let them simply increment forming top of stack.  Because of this, the
00026 search time for instance in object_list will increase as will always have to search
00027 the whole instance array (unless already found).
00028 
00029   The system name of "self" can be used instead of real system name. 
00030  If so, it defaults to the current system name.  
00031 
00032 NOTE: No system can use name of "self".
00033 system name.  For example,
00034 transmit("self.led.green",msg); 
00035 
00036   Jstatus.header(6, Set_Binary_Status_Message, NO_ACKNOWLEDGE, NORMAL_DATA_PACKET,
00037          1, 1, Binary_Status_Component, iRED_LED,
00038          1, 1, Binary_Status_Component, iRED_LED);
00039 
00040 now becomes:
00041   Jstatus.header(6, Set_Binary_Status_Message, NO_ACKNOWLEDGE, NORMAL_DATA_PACKET,"self.led.red");
00042 
00043   Three possible implementations:
00044 1.  Jstatus.header("mrm.led.red"); // send intranode message if source ommitted.
00045  or Jstatus.header("host.com","mrm.led.red"); for both addresses.
00046 Advantage: do not need to need any internal constants, although arguably the device name is a type of constant that
00047            serves as a global header file, but perhaps more flexible.
00048            Another advantage from application developer perspective is you don't need to even know
00049            which system ID or JAUS component implements it.  The translation to the component/instance is done in the DSN configuration file.
00050            Also, a vendor can implement new experimental components and simply give application the name of the 
00051            new device.  Its implementation to component instance can change without needing to change application that uses it..
00052 Disadvantage: more processing to translate device name to address.
00053               Another disadvantage for some components is the application developer needs to know the device names
00054               rather than just know "Local_Waypoint_Driver".  If the waypoint driver name is "mrm.driver".
00055 
00056 NOTE: suggest making so if you ommit the last parameter, then it defaults to any instance defined.
00057 NOTE: Although wayoint driver instance name can even be standardized based upon implementation methodology.
00058       For instance, no obstacle driver can be "clear" thus if it is supported, you can know the name
00059       "mrm.driver.clear".
00060 2.   Jstatus.header(Binary_Status_Component,iRED_LED);
00061 Advantage: quicker 
00062 Disadvantage: Need to know all the internal values of how it is implemented component/instances.
00063 
00064 mrm.led.red,2.1.47.1
00065 mrm.led.green,2.1.47.2
00066 mrm.io.port_e0,2.1.47.3
00067 mrm.io.port_e1,2.1.47.4
00068 mrm.io.port_e2,2.1.47.5
00069 mrm.io.port_e3,2.1.47.6
00070 mrm.io.port_e4,2.1.47.7
00071 mrm.io.port_e5,2.1.47.8
00072 mrm.io.port_e6,2.1.47.9
00073 mrm.io.port_e7,2.1.47.10
00074 mrm.io.port_f0,2.1.47.11
00075 mrm.io.port_f1,2.1.47.12
00076 mrm.io.port_f2,2.1.47.13
00077 mrm.io.port_f3,2.1.47.14
00078 mrm.io.port_f4,2.1.47.15
00079 mrm.io.port_f5,2.1.47.16
00080 mrm.io.port_f6,2.1.47.17
00081 mrm.io.port_f7,2.1.47.18
00082 host.led.red,1.1.47.1
00083 host.led.green,1.1.47.2
00084 
00085 */
00086 #ifndef _DeviceNameService_H
00087 #define _DeviceNameService_H
00088 
00089 #include <types.h>
00090 #include <jaus/jaus_message.h>
00091 
00092 class DeviceNameService 
00093 {
00094 public:
00095   DeviceNameService(void);
00096   // configure name of system/subsystem and corresponding address.
00097   static void config(const char* const, const char* const, uint8, uint8);
00098 // given device name, return its address.
00099   static bool lookup(const char* const name, ID_T& address);
00100 // Given address, return device name.
00101   static bool lookup(ID_T address, char* const name);
00103   static uint8 system(void) { return _systemid; }
00105   static uint8 subsystem(void) { return _subsystemid; }
00106 protected:
00107   void load_table(void);
00108   static char _devices[];
00109   static char _sysname[8];
00110   static char _subsysname[8];
00111   static uint8 _systemid;
00112   static uint8 _subsystemid;
00113 };
00114 
00115 #endif

Generated on Mon Oct 8 19:32:18 2007 for OOMRM Mapping API by doxygen1.3