Update of /cvsroot/playerstage/code/player/libplayercore
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30199/libplayercore
Modified Files:
.cvsignore Makefile.am driver.h interface_util.c player.h
Added Files:
playerinterfacegen.py
Log Message:
overhaul of the player interface definitions
interfaces are now defined with a very light weight IDL allowing them to be
edited in a single file
some subtype names were also modified as a side effect, making them more
consistent globally
Index: .cvsignore
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/.cvsignore,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** .cvsignore 22 Jul 2005 02:01:42 -0000 1.4
--- .cvsignore 20 Aug 2007 06:37:26 -0000 1.5
***************
*** 5,6 ****
--- 5,8 ----
playercore.pc
playererror.pc
+ interface_table.c
+ player_interfaces.h
Index: player.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/player.h,v
retrieving revision 1.137
retrieving revision 1.138
diff -C2 -d -r1.137 -r1.138
*** player.h 11 Aug 2007 00:21:28 -0000 1.137
--- player.h 20 Aug 2007 06:37:26 -0000 1.138
***************
*** 131,177 ****
* @{ */
! #define PLAYER_NULL_CODE 256 // /dev/null analogue
! #define PLAYER_PLAYER_CODE 1 // the server itself
! #define PLAYER_POWER_CODE 2 // power subsystem
! #define PLAYER_GRIPPER_CODE 3 // gripper
! #define PLAYER_POSITION2D_CODE 4 // device that moves about in the plane
! #define PLAYER_SONAR_CODE 5 // fixed range-finder
! #define PLAYER_LASER_CODE 6 // scanning range-finder
! #define PLAYER_BLOBFINDER_CODE 7 // visual blobfinder
[...4626 lines suppressed...]
! typedef struct player_wsn_datafreq_config
! {
! /** The ID of the WSN node. -1 for all.
*/
! int32_t node_id;
! /** The Group ID of the WSN node. -1 for all.
*/
! int32_t group_id;
! /** Requested frequency in Hz.
*/
! double frequency;
! } player_wsn_datafreq_config_t;
! /** @} */
#endif /* PLAYER_H */
--- 547,553 ----
@todo
- Normalize subtype names (PLAYER_PTZ_REQ_GEOM vs
PLAYER_POSITION2D_REQ_GET_GEOM)
*/
! #include <libplayercore/player_interfaces.h>
#endif /* PLAYER_H */
Index: interface_util.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/interface_util.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** interface_util.c 4 Aug 2007 03:12:07 -0000 1.8
--- interface_util.c 20 Aug 2007 06:37:26 -0000 1.9
***************
*** 45,120 ****
#include <libplayercore/interface_util.h> // for player_interface_t type
! /* this array lists the interfaces that Player knows how to load
! * It is important that this list is kept in strict numerical order
! * with respect to the interface numeric codes.
! *
! * NOTE: the last element must be NULL
! */
! static player_interface_t interfaces[] = {
! {PLAYER_NULL_CODE, PLAYER_NULL_STRING},
! {PLAYER_PLAYER_CODE, PLAYER_PLAYER_STRING},
! {PLAYER_POWER_CODE, PLAYER_POWER_STRING},
! {PLAYER_GRIPPER_CODE, PLAYER_GRIPPER_STRING},
! {PLAYER_POSITION2D_CODE, PLAYER_POSITION2D_STRING},
! {PLAYER_SONAR_CODE, PLAYER_SONAR_STRING},
! {PLAYER_LASER_CODE, PLAYER_LASER_STRING},
! {PLAYER_BLOBFINDER_CODE, PLAYER_BLOBFINDER_STRING},
! {PLAYER_PTZ_CODE, PLAYER_PTZ_STRING},
! {PLAYER_AUDIO_CODE, PLAYER_AUDIO_STRING},
! {PLAYER_FIDUCIAL_CODE, PLAYER_FIDUCIAL_STRING},
! {0xFFFF, "nointerf11"},
! {PLAYER_SPEECH_CODE, PLAYER_SPEECH_STRING},
! {PLAYER_GPS_CODE, PLAYER_GPS_STRING},
! {PLAYER_BUMPER_CODE, PLAYER_BUMPER_STRING},
! {0xFFFF, "nointerf15"},
! {0xFFFF, "nointerf16"},
! {0xFFFF, "nointerf17"},
! {0xFFFF, "nointerf18"},
! {0xFFFF, "nointerf19"},
! {PLAYER_DIO_CODE, PLAYER_DIO_STRING},
! {PLAYER_AIO_CODE, PLAYER_AIO_STRING},
! {PLAYER_IR_CODE, PLAYER_IR_STRING},
! {PLAYER_WIFI_CODE, PLAYER_WIFI_STRING},
! {0xFFFF, "nointerf24"},
! {PLAYER_LOCALIZE_CODE, PLAYER_LOCALIZE_STRING},
! {PLAYER_MCOM_CODE, PLAYER_MCOM_STRING},
! {0xFFFF, "nointerf27"},
! {0xFFFF, "nointerf28"},
! {0xFFFF, "nointerf29"},
! {PLAYER_POSITION3D_CODE, PLAYER_POSITION3D_STRING},
! {PLAYER_SIMULATION_CODE, PLAYER_SIMULATION_STRING},
! {0xFFFF, "nointerf32"},
! {PLAYER_BLINKENLIGHT_CODE, PLAYER_BLINKENLIGHT_STRING},
! {PLAYER_NOMAD_CODE, PLAYER_NOMAD_STRING},
! {0xFFFF, "nointerf35"},
! {0xFFFF, "nointerf36"},
! {0xFFFF, "nointerf37"},
! {0xFFFF, "nointerf38"},
! {0xFFFF, "nointerf39"},
! {PLAYER_CAMERA_CODE, PLAYER_CAMERA_STRING},
! {0xFFFF, "nointerf41"},
! {PLAYER_MAP_CODE, PLAYER_MAP_STRING},
! {0xFFFF, "nointerf43"},
! {PLAYER_PLANNER_CODE, PLAYER_PLANNER_STRING},
! {PLAYER_LOG_CODE, PLAYER_LOG_STRING},
! {0xFFFF, "nointerf46"},
! {0xFFFF, "nointerf47"},
! {0xFFFF, "nointerf48"},
! {PLAYER_JOYSTICK_CODE, PLAYER_JOYSTICK_STRING},
! {PLAYER_SPEECH_RECOGNITION_CODE, PLAYER_SPEECH_RECOGNITION_STRING},
! {PLAYER_OPAQUE_CODE, PLAYER_OPAQUE_STRING},
! {PLAYER_POSITION1D_CODE, PLAYER_POSITION1D_STRING},
! {PLAYER_ACTARRAY_CODE, PLAYER_ACTARRAY_STRING},
! {PLAYER_LIMB_CODE, PLAYER_LIMB_STRING},
! {PLAYER_GRAPHICS2D_CODE, PLAYER_GRAPHICS2D_STRING},
! {PLAYER_RFID_CODE, PLAYER_RFID_STRING},
! {PLAYER_WSN_CODE, PLAYER_WSN_STRING},
! {PLAYER_GRAPHICS3D_CODE, PLAYER_GRAPHICS3D_STRING},
! {PLAYER_HEALTH_CODE, PLAYER_HEALTH_STRING},
! {PLAYER_IMU_CODE, PLAYER_IMU_STRING},
! {PLAYER_POINTCLOUD3D_CODE, PLAYER_POINTCLOUD3D_STRING},
! {PLAYER_RANGER_CODE, PLAYER_RANGER_STRING},
! {0,NULL}
! };
static player_interface_t* itable;
--- 45,49 ----
#include <libplayercore/interface_util.h> // for player_interface_t type
! #include "interface_table.c"
static player_interface_t* itable;
Index: driver.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/driver.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** driver.h 10 Jul 2007 09:01:51 -0000 1.20
--- driver.h 20 Aug 2007 06:37:26 -0000 1.21
***************
*** 228,232 ****
@param overwrite_cmds Do new commands overwrite old ones?
@param queue_maxlen How long can the incoming queue grow?
! @param interf Player interface code; e.g., PLAYER_POSITION_CODE */
Driver(ConfigFile *cf,
int section,
--- 228,232 ----
@param overwrite_cmds Do new commands overwrite old ones?
@param queue_maxlen How long can the incoming queue grow?
! @param interf Player interface code; e.g., PLAYER_POSITION2D_CODE */
Driver(ConfigFile *cf,
int section,
Index: Makefile.am
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/Makefile.am,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** Makefile.am 29 Apr 2007 07:18:43 -0000 1.18
--- Makefile.am 20 Aug 2007 06:37:26 -0000 1.19
***************
*** 7,11 ****
EXTRA_DIST = playercore.pc.in playererror.pc.in
! BUILT_SOURCES = playerconfig.h
CLEANFILES = playerconfig.h playercore.pc playererror.pc
--- 7,11 ----
EXTRA_DIST = playercore.pc.in playererror.pc.in
! BUILT_SOURCES = playerconfig.h player_interfaces.h interface_table.c
CLEANFILES = playerconfig.h playercore.pc playererror.pc
***************
*** 25,35 ****
property.cpp property.h
libplayercore_la_LDFLAGS = $(PLAYER_VERSION_INFO) -rpath $(libdir)
$(top_builddir)/libplayercore/libplayererror.la
$(top_builddir)/libplayercore/libplayerutils.la
! libplayercore_la_DEPENDENCIES =
$(top_builddir)/libplayercore/libplayererror.la
$(top_builddir)/libplayercore/libplayerutils.la
libplayererror_la_SOURCES = error.h error.c
libplayererror_la_LDFLAGS = $(PLAYER_VERSION_INFO) -rpath $(libdir)
! libplayerutils_la_SOURCES = interface_util.c interface_util.h
libplayerutils_la_LDFLAGS = $(PLAYER_VERSION_INFO) -rpath $(libdir)
coreincludedir = $(includedir)/player-2.0/libplayercore
--- 25,37 ----
property.cpp property.h
libplayercore_la_LDFLAGS = $(PLAYER_VERSION_INFO) -rpath $(libdir)
$(top_builddir)/libplayercore/libplayererror.la
$(top_builddir)/libplayercore/libplayerutils.la
! libplayercore_la_DEPENDENCIES =
$(top_builddir)/libplayercore/libplayererror.la
$(top_builddir)/libplayercore/libplayerutils.la player_interfaces.h
libplayererror_la_SOURCES = error.h error.c
libplayererror_la_LDFLAGS = $(PLAYER_VERSION_INFO) -rpath $(libdir)
! libplayerutils_la_SOURCES = interface_util.c interface_util.h
libplayerutils_la_LDFLAGS = $(PLAYER_VERSION_INFO) -rpath $(libdir)
+ libplayerutils_la_DEPENDENCIES = interface_table.c
+
coreincludedir = $(includedir)/player-2.0/libplayercore
***************
*** 51,54 ****
error.h \
addr_util.h \
! property.h
--- 53,62 ----
error.h \
addr_util.h \
! property.h \
! player_interfaces.h
!
! player_interfaces.h: ./interfaces/* playerinterfacegen.py
! if ! ./playerinterfacegen.py > player_interfaces.h; then rm
player_interfaces.h; fi
+ interface_table.c: ./interfaces/* playerinterfacegen.py
+ if ! ./playerinterfacegen.py --utils > interface_table.c; then rm
interface_table.c; fi
\ No newline at end of file
--- NEW FILE: playerinterfacegen.py ---
#!/usr/bin/env python
import re
import string
import sys
import os
import glob
HEADER_MODE = "--header"
FUNCTIONTABLE_MODE = "--functiontable"
UTILS_MODE = "--utils"
USAGE = "USAGE: playerinterfacegen.py [%s | %s | %s] [<interface
file>|<interface dir>]" % (HEADER_MODE, FUNCTIONTABLE_MODE, UTILS_MODE)
class msg:
pass
def get_interface(filename):
interface_filename = os.path.splitext(os.path.split(filename)[-1])[0]
interface_code = int(interface_filename.split("_")[0])
interface_name = string.join(interface_filename.split("_")[1:],'_').lower()
return (interface_code, interface_name)
def processfile(mode, filename):
interface_code, interface_name = get_interface(filename)
interface_def = "PLAYER_%s_CODE" % interface_name.upper()
print >> sys.stderr, "Processing interface: ", interface_code, interface_name
# now we process the input file
interface_file = open(filename, 'r')
input_data = interface_file.read()
interface_file.close()
interface_types = ""
interface_messages = []
# Read in the interface comment, and remove it
interface_comment = ""
pattern = re.compile('^\s*description\s*{(.*?)}[^\n]*\n',re.M|re.S)
m = pattern.search(input_data)
if m:
interface_comment = m.group(1)
pattern = re.compile('^\s*description\s*{(.*?)}[^\n]*\n',re.M|re.S)
input_data = pattern.sub('', input_data)
# read in the interface messages, and remove them
pattern =
re.compile('(?P<comment>/\*\*[^{}]*?\*/)?\s*message\s*{\s*(?P<type>\w*)\s*,\s*(?P<subtype>\w*)\s*,\s*(?P<subtypecode>\w*)\s*,\s*(?P<datatype>\w*)\s*}\s*;\s*',re.M|re.S)
for m in pattern.finditer(input_data):
mess = msg()
mess.msg_type = "PLAYER_MSGTYPE_%s" % m.group("type").upper()
mess.msg_subtype_string = "PLAYER_%s_%s_%s" % (interface_name.upper(),
m.group("type").upper(), m.group("subtype").upper())
mess.msg_subtype_code = int(m.group("subtypecode"))
mess.datatype = m.group("datatype")
if m.group("comment"):
mess.comment = m.group("comment")
else:
mess.comment = ""
interface_messages.append(mess)
input_data = pattern.sub('', input_data)
# strip out single line c++ comments at the start of lines, these can then be
used to document the interface file
pattern = re.compile('^\s*//.*',re.M)
input_data = pattern.sub('', input_data)
# the remaining data is the interface data types
interface_types = input_data
# Now we dump the data, what gets displayed depends on the mode
if mode == HEADER_MODE:
message_string = ""
for m in interface_messages:
message_string += """
%(comment)s
#define %(string)s %(code)d
""" % {"comment": m.comment, "string": m.msg_subtype_string, "code":
m.msg_subtype_code}
print """
/** @ingroup message_codes
* @{ */
#define %(interface_def)s %(interface_code)d
/** @}
* @ingroup message_strings
* @{ */
#define PLAYER_%(interface_name_upper)s_STRING "%(interface_name)s"
/** @} */
// /////////////////////////////////////////////////////////////////////////////
/** @ingroup interfaces
@defgroup interface_%(interface_name)s %(interface_name)s
%(interface_comment)s
*/
/**
@ingroup interface_%(interface_name)s
* @{ */
%(interface_messages)s
%(interface_types)s
/** @} */
""" % {
"interface_name" : interface_name,
"interface_name_upper" : interface_name.upper(),
"interface_def" : interface_def,
"interface_code" : interface_code,
"interface_messages" : message_string,
"interface_types" : interface_types,
"interface_comment" : interface_comment}
elif mode == FUNCTIONTABLE_MODE:
print "\n /* %s messages */" % interface_name
for m in interface_messages:
print " {", interface_def, ",", m.msg_type, ",", m.msg_subtype_string,
","
print " (player_pack_fn_t)%(dt_base)s_pack,
(player_dpcpy_fn_t)%(dt)s_dpcpy, (player_cleanup_fn_t)%(dt)s_cleanup}," % {
"dt_base": m.datatype[:-2], "dt": m.datatype}
def process_for_utils(targetfile):
interfaces = []
if os.path.isdir(targetfile):
for file in glob.glob(os.path.join(targetfile ,"*.def")):
if not os.path.isdir(file):
interfaces.append(get_interface(file))
print """
/* this array lists the interfaces that Player knows how to load
* It is important that this list is kept in strict numerical order
* with respect to the interface numeric codes.
*
* NOTE: the last element must be NULL
*/
static player_interface_t interfaces[] = {
"""
interfaces.sort()
last_code = 0
for interface in interfaces:
while interface[0] > last_code + 1:
print """ {0xFFFF, "nointerf%d"},""" % last_code
last_code += 1
print """ {PLAYER_%(i)s_CODE, PLAYER_%(i)s_STRING},""" % {"i" :
interface[1].upper() }
last_code += 1
print """
{0,NULL}
};"""
if __name__ == '__main__':
mode = HEADER_MODE
targetfile = "interfaces"
for option in sys.argv[1:]:
if option == "-h" or option == "--help":
print USAGE
sys.exit(-1)
elif option == HEADER_MODE or option == FUNCTIONTABLE_MODE or option ==
UTILS_MODE:
mode = option
else:
targetfile = option
print "/* START OF AUTOGENERATED CODE */"
print "/* This file or section was automatically generated by
playerinterfacegen.py"
print "To modify the interfaces in this file please edit their interface
definition in libplayercore/interfaces/ */"
if mode == UTILS_MODE:
process_for_utils(targetfile)
else:
if os.path.isdir(targetfile):
for file in glob.glob(os.path.join(targetfile ,"*.def")):
if not os.path.isdir(file):
processfile(mode, file)
else:
processfile(mode, targetfile)
print "/* END OF AUTOGENERATED CODE */"
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit