Compare commits
No commits in common. "wip2" and "master" have entirely different histories.
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +0,0 @@
|
|||||||
**/build
|
|
||||||
**/devel
|
|
||||||
**/log
|
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,6 +0,0 @@
|
|||||||
[submodule "Legacy/ws_linux/src/usb_cam"]
|
|
||||||
path = Legacy/ws_linux/src/usb_cam
|
|
||||||
url = https://github.com/ros-drivers/usb_cam
|
|
||||||
[submodule "Legacy/ws_linux/src/amr-ros-config"]
|
|
||||||
path = Legacy/ws_linux/src/amr-ros-config
|
|
||||||
url = https://github.com/MobileRobots/amr-ros-config.git
|
|
@ -1,16 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>ArNetworking Documentation</title>
|
|
||||||
<meta http-equiv="Refresh" content="1; URL=docs/index.html">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h2 align=center><a href = docs/index.html>ArNetworking Index</a></h2>
|
|
||||||
<pre>
|
|
||||||
|
|
||||||
|
|
||||||
</pre>
|
|
||||||
<h5 align=center>(If the ArNetworking index isn't loaded automatically,<br>please click
|
|
||||||
the above hyperlink,<br> or locate the index.html page in
|
|
||||||
docs/.)</h6>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,68 +0,0 @@
|
|||||||
|
|
||||||
ArNetworking 2.8.0
|
|
||||||
|
|
||||||
Summary of command line options
|
|
||||||
|
|
||||||
Some classes in ARIA and ArNetworking check a program's run time options to
|
|
||||||
specify parameters and options. These options are used to configure run time
|
|
||||||
accessory device parameters (ports, speeds, etc.) used by ARIA; host names,
|
|
||||||
port numbers, etc. used by ArNetworking; and various other run time options.
|
|
||||||
Options may be given as program arguments on the command line, or globally
|
|
||||||
saved as defaults in the file /etc/Aria.args if on Linux, or in the ARIAARGS
|
|
||||||
environment variable. Arguments given on the command line may override some
|
|
||||||
internal defaults or values read from the robot parameter files.
|
|
||||||
|
|
||||||
Note, an option will be available only in programs that instantiate an
|
|
||||||
object of the class that uses it. Some programs may also check for
|
|
||||||
program-specific command line options.
|
|
||||||
|
|
||||||
Use the special "-help" command line option to cause a program to
|
|
||||||
print out its available options.
|
|
||||||
|
|
||||||
A list of options used by each class follows.
|
|
||||||
|
|
||||||
|
|
||||||
ArClientSimpleConnector
|
|
||||||
-----------------------
|
|
||||||
Options for ArClientSimpleConnector (see docs for more details):
|
|
||||||
-host <hostName>
|
|
||||||
-port <portNumber>
|
|
||||||
-p <portNumber>
|
|
||||||
-user <user>
|
|
||||||
-u <user>
|
|
||||||
-password <password>
|
|
||||||
-pwd <password>
|
|
||||||
-nopassword
|
|
||||||
-np
|
|
||||||
-logDataList
|
|
||||||
-ldl
|
|
||||||
|
|
||||||
ArServerSimpleOpener
|
|
||||||
--------------------
|
|
||||||
Options for ArServerSimpleOpener:
|
|
||||||
-serverPort <serverPortNumber>
|
|
||||||
-sp <serverPortNumber>
|
|
||||||
-serverIP <serverIPToOpenOn>
|
|
||||||
-sip <serverIPToOpenOn>
|
|
||||||
-serverTcpOnly
|
|
||||||
-userInfo <userInfoFileName>
|
|
||||||
-ui <userInfoFileName>
|
|
||||||
-logUserInfo
|
|
||||||
-lui
|
|
||||||
-logCommandGroups
|
|
||||||
-lcg
|
|
||||||
-serverInfoFile <file>
|
|
||||||
|
|
||||||
|
|
||||||
ArClientSwitchManager
|
|
||||||
---------------------
|
|
||||||
ArClientSwitchManager options:
|
|
||||||
-centralServer <host>
|
|
||||||
-cs <host>
|
|
||||||
-centralServerPort <port>
|
|
||||||
-csp <port>
|
|
||||||
-identifier <identifier>
|
|
||||||
-id <identifier>
|
|
||||||
-centralServerInfoFile <fileName>
|
|
||||||
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
|||||||
|
|
||||||
ArNetworking @ARIA_VERSION@
|
|
||||||
|
|
||||||
Summary of command line options
|
|
||||||
|
|
||||||
Some classes in ARIA and ArNetworking check a program's run time options to
|
|
||||||
specify parameters and options. These options are used to configure run time
|
|
||||||
accessory device parameters (ports, speeds, etc.) used by ARIA; host names,
|
|
||||||
port numbers, etc. used by ArNetworking; and various other run time options.
|
|
||||||
Options may be given as program arguments on the command line, or globally
|
|
||||||
saved as defaults in the file /etc/Aria.args if on Linux, or in the ARIAARGS
|
|
||||||
environment variable. Arguments given on the command line may override some
|
|
||||||
internal defaults or values read from the robot parameter files.
|
|
||||||
|
|
||||||
Note, an option will be available only in programs that instantiate an
|
|
||||||
object of the class that uses it. Some programs may also check for
|
|
||||||
program-specific command line options.
|
|
||||||
|
|
||||||
Use the special "-help" command line option to cause a program to
|
|
||||||
print out its available options.
|
|
||||||
|
|
||||||
A list of options used by each class follows.
|
|
||||||
|
|
||||||
|
|
||||||
ArClientSimpleConnector
|
|
||||||
-----------------------
|
|
||||||
Options for ArClientSimpleConnector (see docs for more details):
|
|
||||||
-host <hostName>
|
|
||||||
-port <portNumber>
|
|
||||||
-p <portNumber>
|
|
||||||
-user <user>
|
|
||||||
-u <user>
|
|
||||||
-password <password>
|
|
||||||
-pwd <password>
|
|
||||||
-nopassword
|
|
||||||
-np
|
|
||||||
-logDataList
|
|
||||||
-ldl
|
|
||||||
|
|
||||||
ArServerSimpleOpener
|
|
||||||
--------------------
|
|
||||||
Options for ArServerSimpleOpener:
|
|
||||||
-serverPort <serverPortNumber>
|
|
||||||
-sp <serverPortNumber>
|
|
||||||
-serverIP <serverIPToOpenOn>
|
|
||||||
-sip <serverIPToOpenOn>
|
|
||||||
-serverTcpOnly
|
|
||||||
-userInfo <userInfoFileName>
|
|
||||||
-ui <userInfoFileName>
|
|
||||||
-logUserInfo
|
|
||||||
-lui
|
|
||||||
-logCommandGroups
|
|
||||||
-lcg
|
|
||||||
-serverInfoFile <file>
|
|
||||||
|
|
||||||
|
|
||||||
ArClientSwitchManager
|
|
||||||
---------------------
|
|
||||||
ArClientSwitchManager options:
|
|
||||||
-centralServer <host>
|
|
||||||
-cs <host>
|
|
||||||
-centralServerPort <port>
|
|
||||||
-csp <port>
|
|
||||||
-identifier <identifier>
|
|
||||||
-id <identifier>
|
|
||||||
-centralServerInfoFile <fileName>
|
|
||||||
|
|
||||||
|
|
@ -1,260 +0,0 @@
|
|||||||
CFILEEXT:=cpp
|
|
||||||
# Make sure we're using a compiler (we probably don't need to define
|
|
||||||
# it but we have been so here it is unless it was already set)
|
|
||||||
ifndef CXX
|
|
||||||
CXX=g++
|
|
||||||
endif
|
|
||||||
BARECXXFLAGS:=-fPIC -g -Wall -D_REENTRANT #-pg -fprofile-arcs
|
|
||||||
CXXFLAGS+=$(BARECXXFLAGS) -fno-exceptions
|
|
||||||
CXXINC:=-I../include -Iinclude
|
|
||||||
CXXLINK:=-L../lib -lAria -lArNetworking -lpthread -ldl -lrt \
|
|
||||||
-Xlinker -Bstatic -lstdc++ -Xlinker -Bdynamic
|
|
||||||
CXXSTATICLINK:=-L../lib -Xlinker -Bstatic -lArNetworking -lAria -Xlinker -Bdynamic -lpthread -ldl -lrt -Xlinker -Bstatic -lstdc++ -Xlinker -Bdynamic
|
|
||||||
|
|
||||||
ifdef JAVA_BIN
|
|
||||||
JAVAC:=$(JAVA_BIN)/javac
|
|
||||||
JAR:=$(JAVA_BIN)/jar
|
|
||||||
else
|
|
||||||
JAVAC:=javac
|
|
||||||
JAR:=jar
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFILES:= \
|
|
||||||
ArCentralManager.cpp \
|
|
||||||
ArCentralForwarder.cpp \
|
|
||||||
ArClientBase.cpp \
|
|
||||||
ArClientData.cpp \
|
|
||||||
ArClientHandlerConfig.cpp \
|
|
||||||
ArClientFileUtils.cpp \
|
|
||||||
ArClientSimpleConnector.cpp \
|
|
||||||
ArClientSwitchManager.cpp \
|
|
||||||
ArClientArgUtils.cpp \
|
|
||||||
ArHybridForwarderVideo.cpp \
|
|
||||||
ArMapChanger.cpp \
|
|
||||||
ArNetPacket.cpp \
|
|
||||||
ArNetPacketReceiverUdp.cpp \
|
|
||||||
ArNetPacketReceiverTcp.cpp \
|
|
||||||
ArNetPacketSenderTcp.cpp \
|
|
||||||
ArServerBase.cpp \
|
|
||||||
ArServerClient.cpp \
|
|
||||||
ArServerData.cpp \
|
|
||||||
ArServerFileUtils.cpp \
|
|
||||||
ArServerHandlerCamera.cpp \
|
|
||||||
ArServerHandlerCameraCollection.cpp \
|
|
||||||
ArServerHandlerCommands.cpp \
|
|
||||||
ArServerHandlerCommMonitor.cpp \
|
|
||||||
ArServerHandlerConfig.cpp \
|
|
||||||
ArServerHandlerMap.cpp \
|
|
||||||
ArServerHandlerMapping.cpp \
|
|
||||||
ArServerHandlerPopup.cpp \
|
|
||||||
ArServerMode.cpp \
|
|
||||||
ArServerModeDrive.cpp \
|
|
||||||
ArServerModeIdle.cpp \
|
|
||||||
ArServerModeRatioDrive.cpp \
|
|
||||||
ArServerModeStop.cpp \
|
|
||||||
ArServerModeWander.cpp \
|
|
||||||
ArServerInfoDrawings.cpp \
|
|
||||||
ArServerInfoRobot.cpp \
|
|
||||||
ArServerInfoSensor.cpp \
|
|
||||||
ArServerInfoStrings.cpp \
|
|
||||||
ArServerSimpleCommands.cpp \
|
|
||||||
ArServerSimpleOpener.cpp \
|
|
||||||
ArServerUserInfo.cpp \
|
|
||||||
ArTempDirectoryHelper.cpp \
|
|
||||||
md5.cpp
|
|
||||||
|
|
||||||
|
|
||||||
OTFILES:=$(patsubst %.$(CFILEEXT),%.o,$(CFILES))
|
|
||||||
OFILES:=$(patsubst %,../obj/%,$(OTFILES))
|
|
||||||
|
|
||||||
TARGETS:=../lib/libArNetworking.so examples
|
|
||||||
|
|
||||||
EXAMPLES_CPP:=$(shell find examples -name "*.$(CFILEEXT)" | grep -v Mod.cpp)
|
|
||||||
EXAMPLES:=$(patsubst %.$(CFILEEXT),%,$(EXAMPLES_CPP))
|
|
||||||
|
|
||||||
TESTS_CPP:=$(shell find tests -name "*.$(CFILEEXT)" | grep -v Mod.cpp)
|
|
||||||
TESTS:=$(patsubst %.$(CFILEEXT),%,$(TESTS_CPP))
|
|
||||||
|
|
||||||
SRC_FILES:=$(patsubst %,src/%,$(CFILES))
|
|
||||||
HEADER_FILES:=$(shell find include -type f -name \*.h)
|
|
||||||
|
|
||||||
all: dirs $(TARGETS)
|
|
||||||
|
|
||||||
dirs:
|
|
||||||
@mkdir -p -v ../obj
|
|
||||||
@mkdir -p -v ../lib
|
|
||||||
|
|
||||||
../lib/libArNetworking.so: $(OFILES) ../lib/libAria.so Makefile.dep
|
|
||||||
@mkdir -p -v ../obj
|
|
||||||
@mkdir -p -v ../lib
|
|
||||||
$(CXX) -shared -Xlinker -Bstatic -lstdc++ -Xlinker -Bdynamic -o $(@) $(OFILES)
|
|
||||||
|
|
||||||
../lib/libArNetworking.a: $(OFILES) ../lib/libAria.a Makefile.dep
|
|
||||||
@mkdir -p -v ../obj
|
|
||||||
@mkdir -p -v ../lib
|
|
||||||
ar -cr $(@) $(OFILES)
|
|
||||||
ranlib $(@)
|
|
||||||
|
|
||||||
|
|
||||||
examples: dirs $(EXAMPLES) Makefile.dep
|
|
||||||
|
|
||||||
|
|
||||||
tests: dirs $(TESTS) Makefile.dep
|
|
||||||
|
|
||||||
clean: cleanExamples
|
|
||||||
rm -f ../lib/libArNetworking.so ../lib/libArNetworking.a \
|
|
||||||
`find . -name core` $(OFILES) `find . -name '*~'`
|
|
||||||
|
|
||||||
cleanPython:
|
|
||||||
-rm ../python/_ArNetworkingPy.so
|
|
||||||
-rm ../python/ArNetworkingPy.py
|
|
||||||
-rm ../python/ArNetworkingPy.pyc
|
|
||||||
-rm ../python/ArNetworkingPy_wrap.cpp
|
|
||||||
-rm ../obj/ArNetworkingPy_wrap.o
|
|
||||||
|
|
||||||
cleanExamples:
|
|
||||||
rm -f $(EXAMPLES)
|
|
||||||
|
|
||||||
cleanDoc:
|
|
||||||
-rm -f docs/*.html docs/*.png docs/*.png
|
|
||||||
-rm -rf docs/tmp
|
|
||||||
|
|
||||||
fullClean: clean cleanExamples cleanJava cleanPython cleanDoc
|
|
||||||
|
|
||||||
docs: doc
|
|
||||||
doc: docs/index.html
|
|
||||||
docs/index.html: $(SRC_FILES) $(HEADER_FILES) $(EXAMPLES_CPP) doxygen.conf docs/options/all_options.dox ../docs/index.html
|
|
||||||
$(MAKE) cleanDoc
|
|
||||||
-mkdir docs
|
|
||||||
doxygen doxygen.conf
|
|
||||||
|
|
||||||
../docs/index.html: FORCE
|
|
||||||
$(MAKE) -C .. docs/index.html
|
|
||||||
|
|
||||||
#doxygen.conf: FORCE
|
|
||||||
# $(MAKE) -C .. ArNetworking/$@
|
|
||||||
#
|
|
||||||
#CommandLineOptions.txt: FORCE
|
|
||||||
# $(MAKE) -C .. ArNetworking/$@
|
|
||||||
|
|
||||||
Makefile.dep:
|
|
||||||
$(MAKE) dep
|
|
||||||
|
|
||||||
dep: clean
|
|
||||||
if [ -f `echo src/*.cpp | cut -d' ' -f1` ]; then \
|
|
||||||
$(CXX) $(CXXFLAGS) $(CXXINC) -MM src/*.cpp | \
|
|
||||||
awk '$$1 ~ /:/{printf "../obj/%s\n", $$0} $$1 !~ /:/' > Makefile.dep; fi
|
|
||||||
if [ -f `echo examples/*.cpp | cut -d' ' -f1` ]; then \
|
|
||||||
$(CXX) $(CXXFLAGS) $(CXXINC) -MM examples/*.cpp | \
|
|
||||||
awk '$$1 ~ /:/{printf "examples/%s\n", $$0} $$1 !~ /:/' | \
|
|
||||||
sed 's/\.o//' >> Makefile.dep; fi
|
|
||||||
|
|
||||||
../lib/libAria.so: FORCE
|
|
||||||
$(MAKE) -C .. dirs lib/libAria.so
|
|
||||||
|
|
||||||
../lib/libAria.a: FORCE
|
|
||||||
$(MAKE) -C .. dirs lib/libAria.a
|
|
||||||
|
|
||||||
../obj/%.o : src/%.cpp Makefile.dep
|
|
||||||
$(CXX) $(CXXFLAGS) $(CXXINC) -c $< -o $@
|
|
||||||
|
|
||||||
../obj/%.o : src/%.c Makefile.dep
|
|
||||||
$(CXX) $(CXXFLAGS) $(CXXINC) -c $< -o $@
|
|
||||||
|
|
||||||
# Don't build .o files if their library is up to date with respect to source files:
|
|
||||||
.INTERMEDIATE: $(OFILES)
|
|
||||||
|
|
||||||
# But don't delete .o files if we do make them in order to make a library:
|
|
||||||
.PRECIOUS: $(OFILES)
|
|
||||||
|
|
||||||
examples/%: examples/%.$(CFILEEXT) ../lib/libAria.so ../lib/libArNetworking.so Makefile.dep
|
|
||||||
$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXLINK)
|
|
||||||
|
|
||||||
tests/%: tests/%.$(CFILEEXT) ../lib/libAria.so ../lib/libArNetworking.so Makefile.dep
|
|
||||||
$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXLINK)
|
|
||||||
|
|
||||||
|
|
||||||
examples/%Static: examples/%.$(CFILEEXT) ../lib/libAria.a ../lib/libArNetworking.a Makefile.dep
|
|
||||||
$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXSTATICLINK)
|
|
||||||
strip $@
|
|
||||||
|
|
||||||
tests/%Static: tests/%.$(CFILEEXT) ../lib/libAria.a ../lib/libArNetworking.a Makefile.dep
|
|
||||||
$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXSTATICLINK)
|
|
||||||
strip $@
|
|
||||||
|
|
||||||
CommandLineOptions.txt.in docs/options/all_options.dox: genCommandLineOptionDocs
|
|
||||||
-mkdir docs/options
|
|
||||||
./genCommandLineOptionDocs
|
|
||||||
|
|
||||||
genCommandLineOptionDocs: ../utils/genCommandLineOptionDocs.cpp ../lib/libAria.so ../lib/libArNetworking.so src/ArServerSimpleOpener.cpp src/ArClientSimpleConnector.cpp src/ArClientSwitchManager.cpp
|
|
||||||
$(CXX) $(CXXFLAGS) -DFOR_ARNETWORKING $(CXXINC) $< -o $@ $(CXXLINK)
|
|
||||||
|
|
||||||
## Python SWIG wrapper ##
|
|
||||||
|
|
||||||
ifdef PYTHON_INCLUDE
|
|
||||||
PYTHON_INCLUDE_FLAGS=-I$(PYTHON_INCLUDE)
|
|
||||||
else
|
|
||||||
ifdef DIST_INSTALL
|
|
||||||
$(warning WARNING using default value of /usr/include/python2.5 for PYTHON_INCLUDE directory. Set PYTHON_INCLUDE environment variable if you would like to use a different version of the Python C development library to build the Python ARIA wrapper.)
|
|
||||||
endif
|
|
||||||
PYTHON_INCLUDE:=/usr/include/python2.5
|
|
||||||
PYTHON_INCLUDE_FLAGS=-I/usr/include/python2.5
|
|
||||||
endif
|
|
||||||
|
|
||||||
python: ariaPython ../python/_ArNetworkingPy.so
|
|
||||||
|
|
||||||
ariaPython:
|
|
||||||
$(MAKE) -C .. python
|
|
||||||
|
|
||||||
../python/ArNetworkingPy_wrap.cpp ../python/ArNetworkingPy.py: include/wrapper.i $(HEADER_FILES)
|
|
||||||
cd ../python; swig -c++ -python -module ArNetworkingPy -Dlinux -DAREXPORT -o ArNetworkingPy_wrap.cpp -I../include -I../ArNetworking/include ../ArNetworking/include/wrapper.i
|
|
||||||
|
|
||||||
../python/_ArNetworkingPy.so: ../obj/ArNetworkingPy_wrap.o ../lib/libArNetworking.so Makefile.dep
|
|
||||||
$(CXX) $(BARECXXFLAGS) -shared -o $(@) ../obj/ArNetworkingPy_wrap.o -lpthread -ldl -lrt \
|
|
||||||
-L../lib -lAria -lArNetworking
|
|
||||||
|
|
||||||
../obj/ArNetworkingPy_wrap.o: ../python/ArNetworkingPy_wrap.cpp
|
|
||||||
@ if test -z "$(PYTHON_INCLUDE)"; then echo "*** Error: PYTHON_INCLUDE is not set, cannot build ArNetworking python wrapper! ***"; exit 1; fi
|
|
||||||
$(CXX) -c $(BARECXXFLAGS) -g $(CXXINC) -I$(PYTHON_INCLUDE) $< -o $@
|
|
||||||
|
|
||||||
|
|
||||||
## Java SWIG wrapper ##
|
|
||||||
|
|
||||||
|
|
||||||
java: ../lib/libArNetworkingJava.so ../java/ArNetworking.jar
|
|
||||||
|
|
||||||
../java/Aria.jar:
|
|
||||||
$(MAKE) -C .. java
|
|
||||||
|
|
||||||
../java/ArNetworking.jar: ../java/com/mobilerobots/ArNetworking/ArServerBase.class
|
|
||||||
cd ../java ; $(JAR) cf ArNetworking.jar com/mobilerobots/ArNetworking/*.class
|
|
||||||
|
|
||||||
../java/ArNetworkingJava_wrap.cpp ../java/com/mobilerobots/ArNetworking/ArServerBase.java: include/wrapper.i $(HEADER_FILES)
|
|
||||||
-mkdir -p ../java/com/mobilerobots/ArNetworking
|
|
||||||
rm ../java/com/mobilerobots/ArNetworking/*.java ../java/ArNetworkingJava_wrap.cpp ../java/ArNetworkingJava_wrap.h ; swig -c++ -java -package com.mobilerobots.ArNetworking -outdir ../java/com/mobilerobots/ArNetworking -module ArNetworkingJava -Dlinux -DAREXPORT -o ../java/ArNetworkingJava_wrap.cpp -I../include -Iinclude include/wrapper.i
|
|
||||||
|
|
||||||
../java/com/mobilerobots/ArNetworking/ArServerBase.class: ../java/com/mobilerobots/ArNetworking/ArServerBase.java ../java/Aria.jar
|
|
||||||
rm ../java/com/mobilerobots/ArNetworking/*.class; $(JAVAC) -classpath ../java/Aria.jar:../java ../java/com/mobilerobots/ArNetworking/*.java
|
|
||||||
|
|
||||||
cleanJava:
|
|
||||||
-rm ../java/ArNetworking.jar
|
|
||||||
-rm -r ../java/com/mobilerobots/ArNetworking
|
|
||||||
-rm ../java/ArNetworkingJava_wrap.* ../obj/ArNetworkingJava_wrap.o ../lib/libArNetworkingJava.so
|
|
||||||
|
|
||||||
../lib/libArNetworkingJava.so: ../obj/ArNetworkingJava_wrap.o Makefile.dep ../lib/libArNetworking.so
|
|
||||||
$(CXX) $(BARECXXFLAGS) -shared -o $(@) ../obj/ArNetworkingJava_wrap.o -lpthread -ldl -lrt -L../lib -lAria -lArNetworking
|
|
||||||
|
|
||||||
../obj/ArNetworkingJava_wrap.o: ../java/ArNetworkingJava_wrap.cpp
|
|
||||||
@ if test -z "$(JAVA_INCLUDE)"; then echo "*** Error: JAVA_INCLUDE is not set, building ArNetworkingPy_wrap.cpp will probably fail! ***"; fi
|
|
||||||
$(CXX) -c $(BARECXXFLAGS) $(CXXINC) -I$(JAVA_INCLUDE) -I$(JAVA_INCLUDE)/linux $< -o $@
|
|
||||||
|
|
||||||
FORCE:
|
|
||||||
|
|
||||||
# Just see if there is a Makefile.dep, if so include one... there
|
|
||||||
# should be one because of the rules up in the command line parsing
|
|
||||||
# part above
|
|
||||||
ifeq (Makefile.dep,$(wildcard Makefile.dep))
|
|
||||||
include Makefile.dep
|
|
||||||
# End of the Makefile.dep check
|
|
||||||
endif
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 59 KiB |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,87 +0,0 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clientDemoStatic", "clientDemoStatic-vc2003.vcproj", "{0A8A179D-832B-44B2-829A-AB6E61BFF46E}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A} = {527BBF7C-631F-486B-8E4F-EA594299A71A}
|
|
||||||
{1D08AFC4-1036-425C-B381-6FE522207D47} = {1D08AFC4-1036-425C-B381-6FE522207D47}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArNetworkingDLL", "..\src\ArNetworkingDLL-vc2003.vcproj", "{95FF1CC1-5006-4DEE-99D9-0B6C418C9689}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F} = {606257AE-E882-4C66-84C0-72331642D09F}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArNetworkingStatic", "..\src\ArNetworkingStatic-vc2003.vcproj", "{1D08AFC4-1036-425C-B381-6FE522207D47}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A} = {527BBF7C-631F-486B-8E4F-EA594299A71A}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clientDemo", "clientDemo-vc2003.vcproj", "{806E0C42-BE8A-4857-A97B-068FD56C27A1}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F} = {606257AE-E882-4C66-84C0-72331642D09F}
|
|
||||||
{95FF1CC1-5006-4DEE-99D9-0B6C418C9689} = {95FF1CC1-5006-4DEE-99D9-0B6C418C9689}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "serverDemo", "serverDemo-vc2003.vcproj", "{7AEA7E4D-0984-4A16-8A3F-AF36B1A27836}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F} = {606257AE-E882-4C66-84C0-72331642D09F}
|
|
||||||
{95FF1CC1-5006-4DEE-99D9-0B6C418C9689} = {95FF1CC1-5006-4DEE-99D9-0B6C418C9689}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "serverDemoStatic", "serverDemoStatic-vc2003.vcproj", "{31A8793E-E70A-4C52-B470-971BAF9DE5E0}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A} = {527BBF7C-631F-486B-8E4F-EA594299A71A}
|
|
||||||
{1D08AFC4-1036-425C-B381-6FE522207D47} = {1D08AFC4-1036-425C-B381-6FE522207D47}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AriaDLL", "..\..\src\AriaDLL-vc2003.vcproj", "{606257AE-E882-4C66-84C0-72331642D09F}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AriaStatic", "..\..\src\AriaStatic-vc2003.vcproj", "{527BBF7C-631F-486B-8E4F-EA594299A71A}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
|
||||||
Debug = Debug
|
|
||||||
Release = Release
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfiguration) = postSolution
|
|
||||||
{0A8A179D-832B-44B2-829A-AB6E61BFF46E}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{0A8A179D-832B-44B2-829A-AB6E61BFF46E}.Debug.Build.0 = Debug|Win32
|
|
||||||
{0A8A179D-832B-44B2-829A-AB6E61BFF46E}.Release.ActiveCfg = Release|Win32
|
|
||||||
{0A8A179D-832B-44B2-829A-AB6E61BFF46E}.Release.Build.0 = Release|Win32
|
|
||||||
{95FF1CC1-5006-4DEE-99D9-0B6C418C9689}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{95FF1CC1-5006-4DEE-99D9-0B6C418C9689}.Debug.Build.0 = Debug|Win32
|
|
||||||
{95FF1CC1-5006-4DEE-99D9-0B6C418C9689}.Release.ActiveCfg = Release|Win32
|
|
||||||
{95FF1CC1-5006-4DEE-99D9-0B6C418C9689}.Release.Build.0 = Release|Win32
|
|
||||||
{1D08AFC4-1036-425C-B381-6FE522207D47}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{1D08AFC4-1036-425C-B381-6FE522207D47}.Debug.Build.0 = Debug|Win32
|
|
||||||
{1D08AFC4-1036-425C-B381-6FE522207D47}.Release.ActiveCfg = Release|Win32
|
|
||||||
{1D08AFC4-1036-425C-B381-6FE522207D47}.Release.Build.0 = Release|Win32
|
|
||||||
{806E0C42-BE8A-4857-A97B-068FD56C27A1}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{806E0C42-BE8A-4857-A97B-068FD56C27A1}.Debug.Build.0 = Debug|Win32
|
|
||||||
{806E0C42-BE8A-4857-A97B-068FD56C27A1}.Release.ActiveCfg = Release|Win32
|
|
||||||
{806E0C42-BE8A-4857-A97B-068FD56C27A1}.Release.Build.0 = Release|Win32
|
|
||||||
{7AEA7E4D-0984-4A16-8A3F-AF36B1A27836}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{7AEA7E4D-0984-4A16-8A3F-AF36B1A27836}.Debug.Build.0 = Debug|Win32
|
|
||||||
{7AEA7E4D-0984-4A16-8A3F-AF36B1A27836}.Release.ActiveCfg = Release|Win32
|
|
||||||
{7AEA7E4D-0984-4A16-8A3F-AF36B1A27836}.Release.Build.0 = Release|Win32
|
|
||||||
{31A8793E-E70A-4C52-B470-971BAF9DE5E0}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{31A8793E-E70A-4C52-B470-971BAF9DE5E0}.Debug.Build.0 = Debug|Win32
|
|
||||||
{31A8793E-E70A-4C52-B470-971BAF9DE5E0}.Release.ActiveCfg = Release|Win32
|
|
||||||
{31A8793E-E70A-4C52-B470-971BAF9DE5E0}.Release.Build.0 = Release|Win32
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F}.Debug.Build.0 = Debug|Win32
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F}.Release.ActiveCfg = Release|Win32
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F}.Release.Build.0 = Release|Win32
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A}.Debug.Build.0 = Debug|Win32
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A}.Release.ActiveCfg = Release|Win32
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A}.Release.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
@ -1,79 +0,0 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
|
||||||
# Visual C++ Express 2008
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clientDemoStatic", "clientDemoStatic-vc2008.vcproj", "{0A8A179D-832B-44B2-829A-AB6E61BFF46E}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A} = {527BBF7C-631F-486B-8E4F-EA594299A71A}
|
|
||||||
{5AD87287-2610-453A-A986-A4CDCCC24C89} = {5AD87287-2610-453A-A986-A4CDCCC24C89}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArNetworkingDLL", "..\src\ArNetworkingDLL-vc2008.vcproj", "{783BA2AB-07CE-43AD-8FC2-FFD9F19DF575}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F} = {606257AE-E882-4C66-84C0-72331642D09F}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArNetworkingStatic", "..\src\ArNetworkingStatic-vc2008.vcproj", "{5AD87287-2610-453A-A986-A4CDCCC24C89}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A} = {527BBF7C-631F-486B-8E4F-EA594299A71A}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clientDemo", "clientDemo-vc2008.vcproj", "{806E0C42-BE8A-4857-A97B-068FD56C27A1}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F} = {606257AE-E882-4C66-84C0-72331642D09F}
|
|
||||||
{783BA2AB-07CE-43AD-8FC2-FFD9F19DF575} = {783BA2AB-07CE-43AD-8FC2-FFD9F19DF575}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "serverDemoStatic", "serverDemoStatic-vc2008.vcproj", "{EEF9FE4C-34C4-4C76-94C4-D11930C88DE1}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A} = {527BBF7C-631F-486B-8E4F-EA594299A71A}
|
|
||||||
{5AD87287-2610-453A-A986-A4CDCCC24C89} = {5AD87287-2610-453A-A986-A4CDCCC24C89}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AriaDLL", "..\..\src\AriaDLL-vc2008.vcproj", "{606257AE-E882-4C66-84C0-72331642D09F}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AriaStatic", "..\..\src\AriaStatic-vc2008.vcproj", "{527BBF7C-631F-486B-8E4F-EA594299A71A}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "serverDemo", "serverDemo-vc2008.vcproj", "{B9C37E51-E357-4019-B4B5-71C42E1FCD11}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Win32 = Debug|Win32
|
|
||||||
Release|Win32 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{0A8A179D-832B-44B2-829A-AB6E61BFF46E}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{0A8A179D-832B-44B2-829A-AB6E61BFF46E}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{0A8A179D-832B-44B2-829A-AB6E61BFF46E}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{0A8A179D-832B-44B2-829A-AB6E61BFF46E}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{783BA2AB-07CE-43AD-8FC2-FFD9F19DF575}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{783BA2AB-07CE-43AD-8FC2-FFD9F19DF575}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{783BA2AB-07CE-43AD-8FC2-FFD9F19DF575}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{783BA2AB-07CE-43AD-8FC2-FFD9F19DF575}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{5AD87287-2610-453A-A986-A4CDCCC24C89}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{5AD87287-2610-453A-A986-A4CDCCC24C89}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{5AD87287-2610-453A-A986-A4CDCCC24C89}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{5AD87287-2610-453A-A986-A4CDCCC24C89}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{806E0C42-BE8A-4857-A97B-068FD56C27A1}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{806E0C42-BE8A-4857-A97B-068FD56C27A1}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{806E0C42-BE8A-4857-A97B-068FD56C27A1}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{806E0C42-BE8A-4857-A97B-068FD56C27A1}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{EEF9FE4C-34C4-4C76-94C4-D11930C88DE1}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{EEF9FE4C-34C4-4C76-94C4-D11930C88DE1}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{EEF9FE4C-34C4-4C76-94C4-D11930C88DE1}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{EEF9FE4C-34C4-4C76-94C4-D11930C88DE1}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{606257AE-E882-4C66-84C0-72331642D09F}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{527BBF7C-631F-486B-8E4F-EA594299A71A}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{B9C37E51-E357-4019-B4B5-71C42E1FCD11}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{B9C37E51-E357-4019-B4B5-71C42E1FCD11}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{B9C37E51-E357-4019-B4B5-71C42E1FCD11}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{B9C37E51-E357-4019-B4B5-71C42E1FCD11}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
@ -1,8 +0,0 @@
|
|||||||
|
|
||||||
all:
|
|
||||||
$(MAKE) -C .. examples
|
|
||||||
|
|
||||||
%: %.cpp
|
|
||||||
$(MAKE) -C .. examples/$@
|
|
||||||
|
|
||||||
.PHONY: all
|
|
@ -1,26 +0,0 @@
|
|||||||
These mostly come in pairs, with the description in front then the
|
|
||||||
client or server tag
|
|
||||||
|
|
||||||
clientCommandLister - A client that just connects to the server then lists the
|
|
||||||
data that the server has available. Also useful as a testing/diagnostic tool.
|
|
||||||
|
|
||||||
configClient - A client that will get the ArConfig information from the server
|
|
||||||
|
|
||||||
configClientToServer - A client that will send ArConfig information from
|
|
||||||
a config file to the server
|
|
||||||
|
|
||||||
configServer - A server that takes the ArConfig information and
|
|
||||||
makes it available to the client, use in conjunction with configClient
|
|
||||||
|
|
||||||
configServerRobot - Serves up a robot parameter file to edit (example)
|
|
||||||
|
|
||||||
serverDemo - An example that will show the setting up of a
|
|
||||||
server with robot sensor visualization, robot control, and more...
|
|
||||||
connect with MobileEyes.
|
|
||||||
|
|
||||||
drawingsExample - Shows how to display custom graphics (drawings) in
|
|
||||||
a client
|
|
||||||
|
|
||||||
drawingsExampleWithRobot - Shows how to display custom graphics (drawings)
|
|
||||||
in a client, along with the robot and its sensors.
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Aria::init();
|
|
||||||
ArLog::init(ArLog::StdOut, ArLog::Normal);
|
|
||||||
ArClientBase client;
|
|
||||||
|
|
||||||
ArArgumentParser parser(&argc, argv);
|
|
||||||
|
|
||||||
ArClientSimpleConnector clientConnector(&parser);
|
|
||||||
parser.loadDefaultArguments();
|
|
||||||
|
|
||||||
if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
clientConnector.logOptions();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clientConnector.connectClient(&client))
|
|
||||||
{
|
|
||||||
if (client.wasRejected())
|
|
||||||
printf("Server '%s' rejected connection, exiting\n", client.getHost());
|
|
||||||
else
|
|
||||||
printf("Could not connect to server '%s', exiting\n", client.getHost());
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
client.setRobotName(client.getHost()); // include server hostname in log messages
|
|
||||||
client.runAsync();
|
|
||||||
ArUtil::sleep(500);
|
|
||||||
client.logDataList();
|
|
||||||
Aria::shutdown();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,181 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="7.10"
|
|
||||||
Name="clientDemo"
|
|
||||||
ProjectGUID="{806E0C42-BE8A-4857-A97B-068FD56C27A1}"
|
|
||||||
SccProjectName=""
|
|
||||||
SccLocalPath="">
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"/>
|
|
||||||
</Platforms>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory=".\../../bin"
|
|
||||||
IntermediateDirectory=".\../../obj/$(ConfigurationName)-VC7"
|
|
||||||
ConfigurationType="1"
|
|
||||||
UseOfMFC="0"
|
|
||||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
|
||||||
BasicRuntimeChecks="0"
|
|
||||||
RuntimeLibrary="3"
|
|
||||||
BufferSecurityCheck="FALSE"
|
|
||||||
PrecompiledHeaderFile=".\../../obj/clientDemo.pch"
|
|
||||||
AssemblerListingLocation=".\../../obj/"
|
|
||||||
ObjectFile=".\../../obj/"
|
|
||||||
ProgramDataBaseFileName="$(IntDir)/$(TargetName)-VC7.pdb"
|
|
||||||
BrowseInformation="1"
|
|
||||||
WarningLevel="3"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
CompileAs="0"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaDebug.lib ArNetworkingDebug.lib"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
|
||||||
Version="1.0"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
GenerateDebugInformation="TRUE"
|
|
||||||
ProgramDatabaseFile="$(IntDir)/$(ProjectName).pdb"
|
|
||||||
SubSystem="1"
|
|
||||||
TargetMachine="1"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
TypeLibraryName=".\../../bin/clientDemo.tlb"
|
|
||||||
HeaderFileName=""/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="_DEBUG"
|
|
||||||
Culture="1033"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory=".\../../bin"
|
|
||||||
IntermediateDirectory=".\../../obj/$(ConfigurationName)-VC7"
|
|
||||||
ConfigurationType="1"
|
|
||||||
UseOfMFC="0"
|
|
||||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="2"
|
|
||||||
InlineFunctionExpansion="1"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
|
||||||
StringPooling="TRUE"
|
|
||||||
RuntimeLibrary="2"
|
|
||||||
BufferSecurityCheck="FALSE"
|
|
||||||
EnableFunctionLevelLinking="FALSE"
|
|
||||||
PrecompiledHeaderFile=".\../../obj/clientDemo.pch"
|
|
||||||
AssemblerListingLocation=".\../../obj/"
|
|
||||||
ObjectFile=".\../../obj/"
|
|
||||||
ProgramDataBaseFileName="$(IntDir)/$(TargetName)-VC7.pdb"
|
|
||||||
WarningLevel="3"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
CompileAs="0"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="Aria.lib ArNetworking.lib advapi32.lib"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
|
||||||
Version="1.0"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
ProgramDatabaseFile="$(IntDir)/$(ProjectName).pdb"
|
|
||||||
SubSystem="1"
|
|
||||||
TargetMachine="1"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
TypeLibraryName=".\../../bin/clientDemo.tlb"
|
|
||||||
HeaderFileName=""/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="NDEBUG"
|
|
||||||
Culture="1033"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="Source Files"
|
|
||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
|
||||||
<File
|
|
||||||
RelativePath="clientDemo.cpp">
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories=""
|
|
||||||
PreprocessorDefinitions=""
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
BrowseInformation="1"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="2"
|
|
||||||
AdditionalIncludeDirectories=""
|
|
||||||
PreprocessorDefinitions=""/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Header Files"
|
|
||||||
Filter="h;hpp;hxx;hm;inl">
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource Files"
|
|
||||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
@ -1,251 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="9.00"
|
|
||||||
Name="clientDemo"
|
|
||||||
ProjectGUID="{806E0C42-BE8A-4857-A97B-068FD56C27A1}"
|
|
||||||
TargetFrameworkVersion="131072"
|
|
||||||
>
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"
|
|
||||||
/>
|
|
||||||
</Platforms>
|
|
||||||
<ToolFiles>
|
|
||||||
</ToolFiles>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="../../bin"
|
|
||||||
IntermediateDirectory="../../obj/$(ConfigurationName)-VC9"
|
|
||||||
ConfigurationType="1"
|
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
|
||||||
UseOfMFC="0"
|
|
||||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
|
||||||
CharacterSet="2"
|
|
||||||
BuildLogFile="$(IntDir)\$(ProjectName)BuildLog.htm"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
TypeLibraryName=".\../../bin/clientDemo.tlb"
|
|
||||||
HeaderFileName=""
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
|
||||||
BasicRuntimeChecks="0"
|
|
||||||
RuntimeLibrary="3"
|
|
||||||
BufferSecurityCheck="false"
|
|
||||||
PrecompiledHeaderFile=""
|
|
||||||
AssemblerListingLocation=".\../../obj/"
|
|
||||||
ObjectFile=".\../../obj/"
|
|
||||||
ProgramDataBaseFileName="$(IntDir)\vc90.pdb"
|
|
||||||
BrowseInformation="1"
|
|
||||||
WarningLevel="3"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
CompileAs="0"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="_DEBUG"
|
|
||||||
Culture="1033"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaDebugVC9.lib ArNetworkingDebugVC9.lib $(NOINHERIT)"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName)DebugVC9.exe"
|
|
||||||
Version="1.0"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
SubSystem="1"
|
|
||||||
RandomizedBaseAddress="1"
|
|
||||||
DataExecutionPrevention="0"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="../../bin"
|
|
||||||
IntermediateDirectory="../../obj/$(ConfigurationName)-VC9"
|
|
||||||
ConfigurationType="1"
|
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
|
||||||
UseOfMFC="0"
|
|
||||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
|
||||||
CharacterSet="2"
|
|
||||||
BuildLogFile="$(IntDir)\$(ProjectName)BuildLog.htm"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
TypeLibraryName=".\../../bin/clientDemo.tlb"
|
|
||||||
HeaderFileName=""
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="2"
|
|
||||||
InlineFunctionExpansion="2"
|
|
||||||
EnableIntrinsicFunctions="true"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
|
||||||
StringPooling="true"
|
|
||||||
RuntimeLibrary="2"
|
|
||||||
BufferSecurityCheck="false"
|
|
||||||
EnableFunctionLevelLinking="false"
|
|
||||||
PrecompiledHeaderFile=".\../../obj/clientDemo.pch"
|
|
||||||
AssemblerListingLocation=".\../../obj/"
|
|
||||||
ObjectFile=".\../../obj/"
|
|
||||||
ProgramDataBaseFileName=".\../../obj/"
|
|
||||||
WarningLevel="3"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
CompileAs="0"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="NDEBUG"
|
|
||||||
Culture="1033"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaVC9.lib ArNetworkingVC9.lib $(NOINHERIT)"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName)VC9.exe"
|
|
||||||
Version="1.0"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
SubSystem="1"
|
|
||||||
RandomizedBaseAddress="1"
|
|
||||||
DataExecutionPrevention="0"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="Source Files"
|
|
||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath="clientDemo.cpp"
|
|
||||||
>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories=""
|
|
||||||
PreprocessorDefinitions=""
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
BrowseInformation="1"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="2"
|
|
||||||
AdditionalIncludeDirectories=""
|
|
||||||
PreprocessorDefinitions=""
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Header Files"
|
|
||||||
Filter="h;hpp;hxx;hm;inl"
|
|
||||||
>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource Files"
|
|
||||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
|
||||||
>
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
@ -1,159 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectName>clientDemo</ProjectName>
|
|
||||||
<ProjectGuid>{806E0C42-BE8A-4857-A97B-068FD56C27A1}</ProjectGuid>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<PlatformToolset>v100</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<PlatformToolset>v100</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../bin/</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../obj/$(ProjectName)-$(Configuration)-VC10/</IntDir>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../bin/</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../obj/$(ProjectName)-$(Configuration)-VC10/</IntDir>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">clientDemoDebugVC10</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)VC10</TargetName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<BuildLog>
|
|
||||||
<Path>$(IntDir)$(ProjectName)BuildLog.htm</Path>
|
|
||||||
</BuildLog>
|
|
||||||
<Midl>
|
|
||||||
<TypeLibraryName>.\../../bin/clientDemo.tlb</TypeLibraryName>
|
|
||||||
<HeaderFileName>
|
|
||||||
</HeaderFileName>
|
|
||||||
</Midl>
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<AdditionalIncludeDirectories>..\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
|
||||||
<PrecompiledHeaderOutputFile>
|
|
||||||
</PrecompiledHeaderOutputFile>
|
|
||||||
<AssemblerListingLocation>.\../../obj/</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>.\../../obj/</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>$(IntDir)vc100.pdb</ProgramDataBaseFileName>
|
|
||||||
<BrowseInformation>true</BrowseInformation>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<CompileAs>Default</CompileAs>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<Culture>0x0409</Culture>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>AriaDebugVC10.lib;ArNetworkingDebugVC10.lib</AdditionalDependencies>
|
|
||||||
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
|
|
||||||
<Version>1.0</Version>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
|
||||||
<DataExecutionPrevention>
|
|
||||||
</DataExecutionPrevention>
|
|
||||||
<TargetMachine>MachineX86</TargetMachine>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<BuildLog>
|
|
||||||
<Path>$(IntDir)$(ProjectName)BuildLog.htm</Path>
|
|
||||||
</BuildLog>
|
|
||||||
<Midl>
|
|
||||||
<TypeLibraryName>.\../../bin/clientDemo.tlb</TypeLibraryName>
|
|
||||||
<HeaderFileName>
|
|
||||||
</HeaderFileName>
|
|
||||||
</Midl>
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<AdditionalIncludeDirectories>..\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<StringPooling>true</StringPooling>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
|
||||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
|
||||||
<PrecompiledHeaderOutputFile>.\../../obj/clientDemo.pch</PrecompiledHeaderOutputFile>
|
|
||||||
<AssemblerListingLocation>.\../../obj/</AssemblerListingLocation>
|
|
||||||
<ObjectFileName>.\../../obj/</ObjectFileName>
|
|
||||||
<ProgramDataBaseFileName>.\../../obj/</ProgramDataBaseFileName>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<CompileAs>Default</CompileAs>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<Culture>0x0409</Culture>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>AriaVC10.lib;ArNetworkingVC10.lib</AdditionalDependencies>
|
|
||||||
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
|
|
||||||
<Version>1.0</Version>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
|
||||||
<DataExecutionPrevention>
|
|
||||||
</DataExecutionPrevention>
|
|
||||||
<TargetMachine>MachineX86</TargetMachine>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="clientDemo.cpp">
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
|
||||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
|
||||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,634 +0,0 @@
|
|||||||
/* This is the ArNetworking example client.
|
|
||||||
* It connects to an ArNetworking server, and provides continuous
|
|
||||||
* information about the robot state (position, speed, server mode, etc.),
|
|
||||||
* and, if the server supports the commands, lets you drive the robot with
|
|
||||||
* the keyboard.
|
|
||||||
*
|
|
||||||
* To see the example client in action, first run a server on the robot's
|
|
||||||
* onboard computer, for example, serverDemo, testServer, guiServer (from ARNL),
|
|
||||||
* or ARAM. Make sure the robot computer is on a network, and run this
|
|
||||||
* clientDemo with the hostname of the robot computer as an argument:
|
|
||||||
*
|
|
||||||
* ./clientDemo -host myrobot
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* This class provides callback functions which are called by the ArKeyHandler
|
|
||||||
* object when the user presses keys. These callback functions adjust member
|
|
||||||
* variables. The sendInput() method sends a command with those values
|
|
||||||
* to the server using the "ratioDrive" request.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class InputHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @param client Our client networking object
|
|
||||||
* @param keyHandler Key handler to register command callbacks with
|
|
||||||
*/
|
|
||||||
InputHandler(ArClientBase *client, ArKeyHandler *keyHandler);
|
|
||||||
virtual ~InputHandler(void);
|
|
||||||
|
|
||||||
/// Up arrow key handler: drive the robot forward
|
|
||||||
void up(void);
|
|
||||||
|
|
||||||
/// Down arrow key handler: drive the robot backward
|
|
||||||
void down(void);
|
|
||||||
|
|
||||||
/// Left arrow key handler: turn the robot left
|
|
||||||
void left(void);
|
|
||||||
|
|
||||||
/// Right arrow key handler: turn the robot right
|
|
||||||
void right(void);
|
|
||||||
|
|
||||||
/// Move the robot laterally right (q key)
|
|
||||||
void lateralLeft(void);
|
|
||||||
|
|
||||||
/// Move the robot laterally right (e key)
|
|
||||||
void lateralRight(void);
|
|
||||||
|
|
||||||
/// Send drive request to the server with stored values
|
|
||||||
void sendInput(void);
|
|
||||||
|
|
||||||
/// Send a request to enable "safe drive" mode on the server
|
|
||||||
void safeDrive();
|
|
||||||
|
|
||||||
/// Send a request to disable "safe drive" mode on the server
|
|
||||||
void unsafeDrive();
|
|
||||||
|
|
||||||
void listData();
|
|
||||||
|
|
||||||
void logTrackingTerse();
|
|
||||||
void logTrackingVerbose();
|
|
||||||
void resetTracking();
|
|
||||||
protected:
|
|
||||||
ArClientBase *myClient;
|
|
||||||
ArKeyHandler *myKeyHandler;
|
|
||||||
|
|
||||||
/// Set this to true in the constructor to print out debugging information
|
|
||||||
bool myPrinting;
|
|
||||||
|
|
||||||
/// Current translation value (a percentage of the maximum speed)
|
|
||||||
double myTransRatio;
|
|
||||||
|
|
||||||
/// Current rotation ration value (a percentage of the maximum rotational velocity)
|
|
||||||
double myRotRatio;
|
|
||||||
|
|
||||||
/// Current rotation ration value (a percentage of the maximum rotational velocity)
|
|
||||||
double myLatRatio;
|
|
||||||
|
|
||||||
/** Functor objects, given to the key handler, which then call our handler
|
|
||||||
* methods above */
|
|
||||||
///@{
|
|
||||||
ArFunctorC<InputHandler> myUpCB;
|
|
||||||
ArFunctorC<InputHandler> myDownCB;
|
|
||||||
ArFunctorC<InputHandler> myLeftCB;
|
|
||||||
ArFunctorC<InputHandler> myRightCB;
|
|
||||||
ArFunctorC<InputHandler> myLateralLeftCB;
|
|
||||||
ArFunctorC<InputHandler> myLateralRightCB;
|
|
||||||
ArFunctorC<InputHandler> mySafeDriveCB;
|
|
||||||
ArFunctorC<InputHandler> myUnsafeDriveCB;
|
|
||||||
ArFunctorC<InputHandler> myListDataCB;
|
|
||||||
ArFunctorC<InputHandler> myLogTrackingTerseCB;
|
|
||||||
ArFunctorC<InputHandler> myLogTrackingVerboseCB;
|
|
||||||
ArFunctorC<InputHandler> myResetTrackingCB;
|
|
||||||
///@}
|
|
||||||
};
|
|
||||||
|
|
||||||
InputHandler::InputHandler(ArClientBase *client, ArKeyHandler *keyHandler) :
|
|
||||||
myClient(client), myKeyHandler(keyHandler),
|
|
||||||
myPrinting(false), myTransRatio(0.0), myRotRatio(0.0), myLatRatio(0.0),
|
|
||||||
|
|
||||||
/* Initialize functor objects with pointers to our handler methods: */
|
|
||||||
myUpCB(this, &InputHandler::up),
|
|
||||||
myDownCB(this, &InputHandler::down),
|
|
||||||
myLeftCB(this, &InputHandler::left),
|
|
||||||
myRightCB(this, &InputHandler::right),
|
|
||||||
myLateralLeftCB(this, &InputHandler::lateralLeft),
|
|
||||||
myLateralRightCB(this, &InputHandler::lateralRight),
|
|
||||||
mySafeDriveCB(this, &InputHandler::safeDrive),
|
|
||||||
myUnsafeDriveCB(this, &InputHandler::unsafeDrive),
|
|
||||||
myListDataCB(this, &InputHandler::listData),
|
|
||||||
myLogTrackingTerseCB(this, &InputHandler::logTrackingTerse),
|
|
||||||
myLogTrackingVerboseCB(this, &InputHandler::logTrackingVerbose),
|
|
||||||
myResetTrackingCB(this, &InputHandler::resetTracking)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Add our functor objects to the key handler, associated with the appropriate
|
|
||||||
* keys: */
|
|
||||||
myKeyHandler->addKeyHandler(ArKeyHandler::UP, &myUpCB);
|
|
||||||
myKeyHandler->addKeyHandler(ArKeyHandler::DOWN, &myDownCB);
|
|
||||||
myKeyHandler->addKeyHandler(ArKeyHandler::LEFT, &myLeftCB);
|
|
||||||
myKeyHandler->addKeyHandler(ArKeyHandler::RIGHT, &myRightCB);
|
|
||||||
myKeyHandler->addKeyHandler('q', &myLateralLeftCB);
|
|
||||||
myKeyHandler->addKeyHandler('e', &myLateralRightCB);
|
|
||||||
myKeyHandler->addKeyHandler('s', &mySafeDriveCB);
|
|
||||||
myKeyHandler->addKeyHandler('u', &myUnsafeDriveCB);
|
|
||||||
myKeyHandler->addKeyHandler('l', &myListDataCB);
|
|
||||||
myKeyHandler->addKeyHandler('t', &myLogTrackingTerseCB);
|
|
||||||
myKeyHandler->addKeyHandler('v', &myLogTrackingVerboseCB);
|
|
||||||
myKeyHandler->addKeyHandler('r', &myResetTrackingCB);
|
|
||||||
}
|
|
||||||
|
|
||||||
InputHandler::~InputHandler(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::up(void)
|
|
||||||
{
|
|
||||||
if (myPrinting)
|
|
||||||
printf("Forwards\n");
|
|
||||||
myTransRatio = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::down(void)
|
|
||||||
{
|
|
||||||
if (myPrinting)
|
|
||||||
printf("Backwards\n");
|
|
||||||
myTransRatio = -100;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::left(void)
|
|
||||||
{
|
|
||||||
if (myPrinting)
|
|
||||||
printf("Left\n");
|
|
||||||
myRotRatio = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::right(void)
|
|
||||||
{
|
|
||||||
if (myPrinting)
|
|
||||||
printf("Right\n");
|
|
||||||
myRotRatio = -100;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::lateralLeft(void)
|
|
||||||
{
|
|
||||||
if (myPrinting)
|
|
||||||
printf("Lateral left\n");
|
|
||||||
myLatRatio = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::lateralRight(void)
|
|
||||||
{
|
|
||||||
if (myPrinting)
|
|
||||||
printf("Lateral right\n");
|
|
||||||
myLatRatio = -100;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::safeDrive()
|
|
||||||
{
|
|
||||||
/* Construct a request packet. The data is a single byte, with value
|
|
||||||
* 1 to enable safe drive, 0 to disable. */
|
|
||||||
ArNetPacket p;
|
|
||||||
p.byteToBuf(1);
|
|
||||||
|
|
||||||
/* Send the packet as a single request: */
|
|
||||||
if(myPrinting)
|
|
||||||
printf("Sending setSafeDrive 1.\n");
|
|
||||||
myClient->requestOnce("setSafeDrive",&p);
|
|
||||||
if(myPrinting)
|
|
||||||
printf("\nSent enable safe drive.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::unsafeDrive()
|
|
||||||
{
|
|
||||||
/* Construct a request packet. The data is a single byte, with value
|
|
||||||
* 1 to enable safe drive, 0 to disable. */
|
|
||||||
ArNetPacket p;
|
|
||||||
p.byteToBuf(0);
|
|
||||||
|
|
||||||
/* Send the packet as a single request: */
|
|
||||||
if(myPrinting)
|
|
||||||
printf("Sending setSafeDrive 0.\n");
|
|
||||||
myClient->requestOnce("setSafeDrive",&p);
|
|
||||||
if(myPrinting)
|
|
||||||
printf("\nSent disable safe drive command. Your robot WILL run over things if you're not careful.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::listData()
|
|
||||||
{
|
|
||||||
myClient->logDataList();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::logTrackingTerse()
|
|
||||||
{
|
|
||||||
myClient->logTracking(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::logTrackingVerbose()
|
|
||||||
{
|
|
||||||
myClient->logTracking(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::resetTracking()
|
|
||||||
{
|
|
||||||
myClient->resetTracking();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InputHandler::sendInput(void)
|
|
||||||
{
|
|
||||||
/* This method is called by the main function to send a ratioDrive
|
|
||||||
* request with our current velocity values. If the server does
|
|
||||||
* not support the ratioDrive request, then we abort now: */
|
|
||||||
if(!myClient->dataExists("ratioDrive")) return;
|
|
||||||
|
|
||||||
/* Construct a ratioDrive request packet. It consists
|
|
||||||
* of three doubles: translation ratio, rotation ratio, and an overall scaling
|
|
||||||
* factor. */
|
|
||||||
ArNetPacket packet;
|
|
||||||
packet.doubleToBuf(myTransRatio);
|
|
||||||
packet.doubleToBuf(myRotRatio);
|
|
||||||
packet.doubleToBuf(50); // use half of the robot's maximum.
|
|
||||||
packet.doubleToBuf(myLatRatio);
|
|
||||||
if (myPrinting)
|
|
||||||
printf("Sending\n");
|
|
||||||
myClient->requestOnce("ratioDrive", &packet);
|
|
||||||
myTransRatio = 0;
|
|
||||||
myRotRatio = 0;
|
|
||||||
myLatRatio = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** This class requests continual data updates from the server and prints them
|
|
||||||
* out.
|
|
||||||
*/
|
|
||||||
class OutputHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OutputHandler(ArClientBase *client);
|
|
||||||
virtual ~OutputHandler(void);
|
|
||||||
|
|
||||||
/// This callback is called when an update on general robot state arrives
|
|
||||||
void handleOutput(ArNetPacket *packet);
|
|
||||||
/// This callback is called when an update on general robot state arrives
|
|
||||||
void handleOutputNumbers(ArNetPacket *packet);
|
|
||||||
/// This callback is called when an update on general robot state arrives
|
|
||||||
void handleOutputStrings(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// This callback is called when an update on the battery configuration changes
|
|
||||||
void handleBatteryInfo(ArNetPacket *packet);
|
|
||||||
/// This is called when the physical robot information comes back
|
|
||||||
void handlePhysicalInfo(ArNetPacket *packet);
|
|
||||||
/// This callback is called when an update on the temperature information changes
|
|
||||||
void handleTemperatureInfo(ArNetPacket *packet);
|
|
||||||
/// Called when the map on the server changes.
|
|
||||||
void handleMapUpdated(ArNetPacket *packet);
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// The results from the data update are stored in these variables
|
|
||||||
//@{
|
|
||||||
double myX;
|
|
||||||
double myY;
|
|
||||||
double myTh;
|
|
||||||
double myVel;
|
|
||||||
double myRotVel;
|
|
||||||
double myLatVel;
|
|
||||||
bool myVoltageIsStateOfCharge;
|
|
||||||
char myTemperature;
|
|
||||||
double myVoltage;
|
|
||||||
char myStatus[256];
|
|
||||||
char myMode[256];
|
|
||||||
//@}
|
|
||||||
ArClientBase *myClient;
|
|
||||||
|
|
||||||
/** These functor objects are given to the client to receive updates when they
|
|
||||||
* arrive from the server.
|
|
||||||
*/
|
|
||||||
//@{
|
|
||||||
ArFunctor1C<OutputHandler, ArNetPacket *> myHandleOutputCB;
|
|
||||||
ArFunctor1C<OutputHandler, ArNetPacket *> myHandleOutputNumbersCB;
|
|
||||||
ArFunctor1C<OutputHandler, ArNetPacket *> myHandleOutputStringsCB;
|
|
||||||
ArFunctor1C<OutputHandler, ArNetPacket *> myHandleBatteryInfoCB;
|
|
||||||
ArFunctor1C<OutputHandler, ArNetPacket *> myHandlePhysicalInfoCB;
|
|
||||||
ArFunctor1C<OutputHandler, ArNetPacket *> myHandleTemperatureInfoCB;
|
|
||||||
ArFunctor1C<OutputHandler, ArNetPacket *> myHandleMapUpdatedCB;
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// A header for the columns in the data printout is sometimes printed
|
|
||||||
bool myNeedToPrintHeader;
|
|
||||||
/// Don't print any information until we get the battery info
|
|
||||||
bool myGotBatteryInfo;
|
|
||||||
};
|
|
||||||
|
|
||||||
OutputHandler::OutputHandler(ArClientBase *client) :
|
|
||||||
myClient(client),
|
|
||||||
myHandleOutputCB(this, &OutputHandler::handleOutput),
|
|
||||||
myHandleOutputNumbersCB(this, &OutputHandler::handleOutputNumbers),
|
|
||||||
myHandleOutputStringsCB(this, &OutputHandler::handleOutputStrings),
|
|
||||||
myHandleBatteryInfoCB(this, &OutputHandler::handleBatteryInfo),
|
|
||||||
myHandlePhysicalInfoCB(this, &OutputHandler::handlePhysicalInfo),
|
|
||||||
myHandleTemperatureInfoCB(this, &OutputHandler::handleTemperatureInfo),
|
|
||||||
myHandleMapUpdatedCB(this, &OutputHandler::handleMapUpdated),
|
|
||||||
myNeedToPrintHeader(false),
|
|
||||||
myGotBatteryInfo(false)
|
|
||||||
{
|
|
||||||
/* Add a handler for battery info, and make a single request for it */
|
|
||||||
myClient->addHandler("physicalInfo", &myHandlePhysicalInfoCB);
|
|
||||||
myClient->requestOnce("physicalInfo");
|
|
||||||
|
|
||||||
|
|
||||||
/* Add a handler for battery info, and make a single request for it */
|
|
||||||
myClient->addHandler("batteryInfo", &myHandleBatteryInfoCB);
|
|
||||||
myClient->requestOnce("batteryInfo");
|
|
||||||
|
|
||||||
/* If it exists add a handler for temperature info, and make a
|
|
||||||
* single request for it */
|
|
||||||
if (myClient->dataExists("temperatureInfo"))
|
|
||||||
{
|
|
||||||
myClient->addHandler("temperatureInfo", &myHandleTemperatureInfoCB);
|
|
||||||
myClient->requestOnce("temperatureInfo");
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we have the new way of broadcasting that only pushes strings
|
|
||||||
// when they change then use that
|
|
||||||
if (myClient->dataExists("updateNumbers") &&
|
|
||||||
myClient->dataExists("updateStrings"))
|
|
||||||
{
|
|
||||||
printf("Using new updates\n");
|
|
||||||
// get the numbers every 100 ms
|
|
||||||
myClient->addHandler("updateNumbers", &myHandleOutputNumbersCB);
|
|
||||||
myClient->request("updateNumbers", 100);
|
|
||||||
// and the strings whenever they change (and are broadcast)
|
|
||||||
myClient->addHandler("updateStrings", &myHandleOutputStringsCB);
|
|
||||||
myClient->request("updateStrings", -1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Using old updates\n");
|
|
||||||
// For the old way, just Add a handler for general info, and
|
|
||||||
// request it to be called every 100 ms
|
|
||||||
myClient->addHandler("update", &myHandleOutputCB);
|
|
||||||
myClient->request("update", 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(myClient->dataExists("mapUpdated"))
|
|
||||||
{
|
|
||||||
myClient->addHandler("mapUpdated", &myHandleMapUpdatedCB);
|
|
||||||
myClient->request("mapUpdated", -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OutputHandler::~OutputHandler(void)
|
|
||||||
{
|
|
||||||
/* Halt the request for data updates */
|
|
||||||
myClient->requestStop("update");
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputHandler::handleOutput(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
/* Extract the data from the update packet. Its format is status and
|
|
||||||
* mode (null-terminated strings), then 6 doubles for battery voltage,
|
|
||||||
* x position, y position and orientation (theta) (from odometry), current
|
|
||||||
* translational velocity, and current rotational velocity. Translation is
|
|
||||||
* always milimeters, rotation in degrees.
|
|
||||||
*/
|
|
||||||
memset(myStatus, 0, sizeof(myStatus));
|
|
||||||
memset(myMode, 0, sizeof(myMode));
|
|
||||||
packet->bufToStr(myStatus, sizeof(myStatus));
|
|
||||||
packet->bufToStr(myMode, sizeof(myMode));
|
|
||||||
myVoltage = ( (double) packet->bufToByte2() )/10.0;
|
|
||||||
myX = (double) packet->bufToByte4();
|
|
||||||
myY = (double) packet->bufToByte4();
|
|
||||||
myTh = (double) packet->bufToByte2();
|
|
||||||
myVel = (double) packet->bufToByte2();
|
|
||||||
myRotVel = (double) packet->bufToByte2();
|
|
||||||
myLatVel = (double) packet->bufToByte2();
|
|
||||||
myTemperature = (double) packet->bufToByte();
|
|
||||||
|
|
||||||
if(myNeedToPrintHeader)
|
|
||||||
{
|
|
||||||
printf("\n%6s|%6s|%6s|%6s|%6s|%6s|%4s|%6s|%15s|%20s|\n",
|
|
||||||
"x","y","theta", "vel", "rotVel", "latVel", "temp", myVoltageIsStateOfCharge ? "charge" : "volts", "mode","status");
|
|
||||||
fflush(stdout);
|
|
||||||
myNeedToPrintHeader = false;
|
|
||||||
}
|
|
||||||
if (myGotBatteryInfo)
|
|
||||||
printf("%6.0f|%6.0f|%6.1f|%6.0f|%6.0f|%6.0f|%4.0d|%6.1f|%15s|%20s|\r",
|
|
||||||
myX, myY, myTh, myVel, myRotVel, myLatVel, myTemperature, myVoltage, myMode, myStatus);
|
|
||||||
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputHandler::handleOutputNumbers(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
/* Extract the data from the updateNumbers packet. Its format is 6
|
|
||||||
* doubles for battery voltage, x position, y position and
|
|
||||||
* orientation (theta) (from odometry), current translational
|
|
||||||
* velocity, and current rotational velocity. Translation is always
|
|
||||||
* milimeters, rotation in degrees.
|
|
||||||
*/
|
|
||||||
myVoltage = ( (double) packet->bufToByte2() )/10.0;
|
|
||||||
myX = (double) packet->bufToByte4();
|
|
||||||
myY = (double) packet->bufToByte4();
|
|
||||||
myTh = (double) packet->bufToByte2();
|
|
||||||
myVel = (double) packet->bufToByte2();
|
|
||||||
myRotVel = (double) packet->bufToByte2();
|
|
||||||
myLatVel = (double) packet->bufToByte2();
|
|
||||||
myTemperature = (double) packet->bufToByte();
|
|
||||||
|
|
||||||
if(myNeedToPrintHeader)
|
|
||||||
{
|
|
||||||
printf("\n%6s|%6s|%6s|%6s|%6s|%6s|%4s|%6s|%15s|%20s|\n",
|
|
||||||
"x","y","theta", "vel", "rotVel", "latVel", "temp", myVoltageIsStateOfCharge ? "charge" : "volts", "mode","status");
|
|
||||||
fflush(stdout);
|
|
||||||
myNeedToPrintHeader = false;
|
|
||||||
}
|
|
||||||
if (myGotBatteryInfo)
|
|
||||||
printf("%6.0f|%6.0f|%6.1f|%6.0f|%6.0f|%6.0f|%4.0d|%6.1f|%15s|%20s|\r",
|
|
||||||
myX, myY, myTh, myVel, myRotVel, myLatVel, myTemperature, myVoltage, myMode, myStatus);
|
|
||||||
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputHandler::handleOutputStrings(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
/* Extract the data from the updateStrings packet. Its format is
|
|
||||||
* status and mode (null-terminated strings).
|
|
||||||
*/
|
|
||||||
memset(myStatus, 0, sizeof(myStatus));
|
|
||||||
memset(myMode, 0, sizeof(myMode));
|
|
||||||
packet->bufToStr(myStatus, sizeof(myStatus));
|
|
||||||
packet->bufToStr(myMode, sizeof(myMode));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputHandler::handleBatteryInfo(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
/* Get battery configuration parameters: when the robot will begin beeping and
|
|
||||||
* warning about low battery, and when it will automatically disconnect and
|
|
||||||
* shutdown. */
|
|
||||||
double lowBattery = packet->bufToDouble();
|
|
||||||
double shutdown = packet->bufToDouble();
|
|
||||||
printf("Low battery voltage: %6g Shutdown battery voltage: %6g\n", lowBattery, shutdown);
|
|
||||||
fflush(stdout);
|
|
||||||
myNeedToPrintHeader = true;
|
|
||||||
myGotBatteryInfo = true;
|
|
||||||
|
|
||||||
if (packet->getDataReadLength() == packet->getDataLength())
|
|
||||||
{
|
|
||||||
printf("Packet is too small so its an old server, though you could just get to the bufToUByte anyways, since it'd be 0 anyhow\n");
|
|
||||||
myVoltageIsStateOfCharge = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
myVoltageIsStateOfCharge = (packet->bufToUByte() == 1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void OutputHandler::handlePhysicalInfo(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
/* Get phyiscal configuration parameters: */
|
|
||||||
char robotType[512];
|
|
||||||
char robotSubtype[512];
|
|
||||||
int width;
|
|
||||||
int lengthFront;
|
|
||||||
int lengthRear;
|
|
||||||
|
|
||||||
packet->bufToStr(robotType, sizeof(robotType));
|
|
||||||
packet->bufToStr(robotSubtype, sizeof(robotSubtype));
|
|
||||||
width = packet->bufToByte2();
|
|
||||||
lengthFront = packet->bufToByte2();
|
|
||||||
lengthRear = packet->bufToByte2();
|
|
||||||
|
|
||||||
printf("Type: %s Subtype: %s Width %d: LengthFront: %d LengthRear: %d\n",
|
|
||||||
robotType, robotSubtype, width, lengthFront, lengthRear);
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputHandler::handleTemperatureInfo(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
char warning = packet->bufToByte();
|
|
||||||
char shutdown = packet->bufToByte();
|
|
||||||
printf("High temperature warning: %4d High temperature shutdown: %4d\n", warning, shutdown);
|
|
||||||
fflush(stdout);
|
|
||||||
myNeedToPrintHeader = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputHandler::handleMapUpdated(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
printf("\nMap changed.\n");
|
|
||||||
fflush(stdout);
|
|
||||||
myNeedToPrintHeader = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Key handler for the escape key: shutdown all of Aria. */
|
|
||||||
void escape(void)
|
|
||||||
{
|
|
||||||
printf("esc pressed, shutting down aria\n");
|
|
||||||
Aria::shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
/* Aria initialization: */
|
|
||||||
Aria::init();
|
|
||||||
|
|
||||||
//ArLog::init(ArLog::StdErr, ArLog::Verbose);
|
|
||||||
|
|
||||||
|
|
||||||
/* Create our client object. This is the object which connects with a remote
|
|
||||||
* server over the network, and which manages all of our communication with it
|
|
||||||
* once connected by sending data "requests". Requests may be sent once, or
|
|
||||||
* may be repeated at any frequency. Requests and replies to requsets contain
|
|
||||||
* payload "packets", into which various data types may be packed (when making a
|
|
||||||
* request), and from which they may also be extracted (when handling a reply).
|
|
||||||
* See the InputHandler and OutputHandler classes above for
|
|
||||||
* examples of making requests and reading/writing the data in packets.
|
|
||||||
*/
|
|
||||||
ArClientBase client;
|
|
||||||
|
|
||||||
/* Aria components use this to get options off the command line: */
|
|
||||||
ArArgumentParser parser(&argc, argv);
|
|
||||||
|
|
||||||
/* This will be used to connect our client to the server, including
|
|
||||||
* various bits of handshaking (e.g. sending a password, retrieving a list
|
|
||||||
* of data requests and commands...)
|
|
||||||
* It will get the hostname from the -host command line argument: */
|
|
||||||
ArClientSimpleConnector clientConnector(&parser);
|
|
||||||
|
|
||||||
parser.loadDefaultArguments();
|
|
||||||
|
|
||||||
/* Check for -help, and unhandled arguments: */
|
|
||||||
if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
Aria::logOptions();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Connect our client object to the remote server: */
|
|
||||||
if (!clientConnector.connectClient(&client))
|
|
||||||
{
|
|
||||||
if (client.wasRejected())
|
|
||||||
printf("Server '%s' rejected connection, exiting\n", client.getHost());
|
|
||||||
else
|
|
||||||
printf("Could not connect to server '%s', exiting\n", client.getHost());
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Connected to server.\n");
|
|
||||||
|
|
||||||
client.setRobotName(client.getHost()); // include server name in log messages
|
|
||||||
|
|
||||||
/* Create a key handler and also tell Aria about it */
|
|
||||||
ArKeyHandler keyHandler;
|
|
||||||
Aria::setKeyHandler(&keyHandler);
|
|
||||||
|
|
||||||
/* Global escape-key handler to shut everythnig down */
|
|
||||||
ArGlobalFunctor escapeCB(&escape);
|
|
||||||
keyHandler.addKeyHandler(ArKeyHandler::ESCAPE, &escapeCB);
|
|
||||||
|
|
||||||
/* Now that we're connected, we can run the client in a background thread,
|
|
||||||
* sending requests and receiving replies. When a reply to a request arrives,
|
|
||||||
* or the server makes a request of the client, a handler functor is invoked.
|
|
||||||
* The handlers for this program are registered with the client by the
|
|
||||||
* InputHandler and OutputHandler classes (in their constructors, above) */
|
|
||||||
client.runAsync();
|
|
||||||
|
|
||||||
/* Create the InputHandler object and request safe-drive mode */
|
|
||||||
InputHandler inputHandler(&client, &keyHandler);
|
|
||||||
inputHandler.safeDrive();
|
|
||||||
|
|
||||||
/* Use ArClientBase::dataExists() to see if the "ratioDrive" request is available on the
|
|
||||||
* currently connected server. */
|
|
||||||
if(!client.dataExists("ratioDrive") )
|
|
||||||
printf("Warning: server does not have ratioDrive command, can not use drive commands!\n");
|
|
||||||
else
|
|
||||||
printf("Keys are:\nUP: Forward\nDOWN: Backward\nLEFT: Turn Left\nRIGHT: Turn Right\n");
|
|
||||||
printf("s: Enable safe drive mode (if supported).\nu: Disable safe drive mode (if supported).\nl: list all data requests on server\n\nDrive commands use 'ratioDrive'.\nt: logs the network tracking tersely\nv: logs the network tracking verbosely\nr: resets the network tracking\n\n");
|
|
||||||
|
|
||||||
|
|
||||||
/* Create the OutputHandler object. It will begin printing out data from the
|
|
||||||
* server. */
|
|
||||||
OutputHandler outputHandler(&client);
|
|
||||||
|
|
||||||
|
|
||||||
/* Begin capturing keys into the key handler. Callbacks will be called
|
|
||||||
* asyncrosously from this main thread when pressed. */
|
|
||||||
|
|
||||||
/* While the client is still running (getRunningWithLock locks the "running"
|
|
||||||
* flag until it returns), check keys on the key handler (which will call
|
|
||||||
* our callbacks), then tell the input handler to send drive commands.
|
|
||||||
* Sleep a fraction of a second as well to avoid using
|
|
||||||
* too much CPU time, and give other threads time to work.
|
|
||||||
*/
|
|
||||||
while (client.getRunningWithLock())
|
|
||||||
{
|
|
||||||
keyHandler.checkKeys();
|
|
||||||
inputHandler.sendInput();
|
|
||||||
ArUtil::sleep(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The client stopped running, due to disconnection from the server, general
|
|
||||||
* Aria shutdown, or some other reason. */
|
|
||||||
client.disconnect();
|
|
||||||
Aria::shutdown();
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="7.10"
|
|
||||||
Name="clientDemoStatic"
|
|
||||||
ProjectGUID="{0A8A179D-832B-44B2-829A-AB6E61BFF46E}"
|
|
||||||
RootNamespace="clientDemoStatic"
|
|
||||||
Keyword="ManagedCProj">
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"/>
|
|
||||||
</Platforms>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="..\bin"
|
|
||||||
IntermediateDirectory="../obj/$(ConfigurationName)-Static-VC7"
|
|
||||||
ConfigurationType="1"
|
|
||||||
CharacterSet="2"
|
|
||||||
ManagedExtensions="FALSE">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;ARIA_STATIC"
|
|
||||||
MinimalRebuild="FALSE"
|
|
||||||
BasicRuntimeChecks="0"
|
|
||||||
RuntimeLibrary="1"
|
|
||||||
BufferSecurityCheck="FALSE"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
ProgramDataBaseFileName="$(IntDir)/$(TargetName)-VC7.pdb"
|
|
||||||
WarningLevel="3"
|
|
||||||
DebugInformationFormat="3"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaStaticDebug.lib ArNetworkingStaticDebug.lib winmm.lib ws2_32.lib advapi32.lib"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
|
||||||
LinkIncremental="2"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
IgnoreDefaultLibraryNames=""
|
|
||||||
GenerateDebugInformation="TRUE"
|
|
||||||
AssemblyDebug="1"
|
|
||||||
ProgramDatabaseFile="$(IntDir)/$(ProjectName).pdb"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="..\bin"
|
|
||||||
IntermediateDirectory="../obj/$(ConfigurationName)-Static-VC7"
|
|
||||||
ConfigurationType="1"
|
|
||||||
CharacterSet="2"
|
|
||||||
ManagedExtensions="FALSE">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;ARIA_STATIC"
|
|
||||||
MinimalRebuild="FALSE"
|
|
||||||
RuntimeLibrary="0"
|
|
||||||
BufferSecurityCheck="FALSE"
|
|
||||||
RuntimeTypeInfo="TRUE"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
ProgramDataBaseFileName="$(IntDir)/$(TargetName)-VC7.pdb"
|
|
||||||
WarningLevel="3"
|
|
||||||
DebugInformationFormat="3"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaStatic.lib ArNetworkingStatic.lib winmm.lib ws2_32.lib advapi32.lib"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
IgnoreDefaultLibraryNames=""
|
|
||||||
GenerateDebugInformation="FALSE"
|
|
||||||
ProgramDatabaseFile="$(IntDir)/$(ProjectName).pdb"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="mscorlib.dll"/>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="System.dll"/>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="System.Data.dll"/>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<File
|
|
||||||
RelativePath="..\examples\clientDemo.cpp">
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
@ -1,214 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="9.00"
|
|
||||||
Name="clientDemoStatic"
|
|
||||||
ProjectGUID="{0A8A179D-832B-44B2-829A-AB6E61BFF46E}"
|
|
||||||
RootNamespace="clientDemoStatic"
|
|
||||||
Keyword="ManagedCProj"
|
|
||||||
TargetFrameworkVersion="131072"
|
|
||||||
>
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"
|
|
||||||
/>
|
|
||||||
</Platforms>
|
|
||||||
<ToolFiles>
|
|
||||||
</ToolFiles>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="..\..\bin"
|
|
||||||
IntermediateDirectory="..\..\obj\$(ConfigurationName)-VC9-Static"
|
|
||||||
ConfigurationType="1"
|
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
|
||||||
CharacterSet="2"
|
|
||||||
ManagedExtensions="0"
|
|
||||||
BuildLogFile="$(IntDir)\$(ProjectName)BuildLog.htm"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="..\..\include;..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;ARIA_STATIC"
|
|
||||||
MinimalRebuild="false"
|
|
||||||
BasicRuntimeChecks="0"
|
|
||||||
RuntimeLibrary="1"
|
|
||||||
BufferSecurityCheck="false"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
LinkLibraryDependencies="false"
|
|
||||||
AdditionalDependencies="ArNetworkingStaticDebugVC9.lib AriaStaticDebugVC9.lib ws2_32.lib winmm.lib advapi32.lib $(NOINHERIT)"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName)DebugVC9.exe"
|
|
||||||
LinkIncremental="2"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
IgnoreDefaultLibraryNames=""
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
AssemblyDebug="1"
|
|
||||||
RandomizedBaseAddress="1"
|
|
||||||
DataExecutionPrevention="0"
|
|
||||||
TargetMachine="0"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="..\..\bin"
|
|
||||||
IntermediateDirectory="..\..\obj\$(ConfigurationName)-VC9-Static"
|
|
||||||
ConfigurationType="1"
|
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
|
||||||
CharacterSet="2"
|
|
||||||
ManagedExtensions="0"
|
|
||||||
BuildLogFile="$(IntDir)\$(ProjectName)BuildLog.htm"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
InlineFunctionExpansion="2"
|
|
||||||
EnableIntrinsicFunctions="true"
|
|
||||||
AdditionalIncludeDirectories="..\..\include;..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;ARIA_STATIC"
|
|
||||||
MinimalRebuild="false"
|
|
||||||
RuntimeLibrary="0"
|
|
||||||
BufferSecurityCheck="false"
|
|
||||||
RuntimeTypeInfo="true"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
LinkLibraryDependencies="false"
|
|
||||||
AdditionalDependencies="ArNetworkingStaticVC9.lib AriaStaticVC9.lib winmm.lib ws2_32.lib advapi32.lib"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName)VC9.exe"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
IgnoreDefaultLibraryNames=""
|
|
||||||
GenerateDebugInformation="false"
|
|
||||||
RandomizedBaseAddress="1"
|
|
||||||
DataExecutionPrevention="0"
|
|
||||||
ImportLibrary=""
|
|
||||||
TargetMachine="0"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="mscorlib.dll"
|
|
||||||
AssemblyName="mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=IA64"
|
|
||||||
MinFrameworkVersion="131072"
|
|
||||||
/>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="System.dll"
|
|
||||||
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
|
|
||||||
MinFrameworkVersion="131072"
|
|
||||||
/>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="System.Data.dll"
|
|
||||||
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
|
|
||||||
MinFrameworkVersion="131072"
|
|
||||||
/>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<File
|
|
||||||
RelativePath=".\clientDemo.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
@ -1,146 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectName>clientDemoStatic</ProjectName>
|
|
||||||
<ProjectGuid>{0A8A179D-832B-44B2-829A-AB6E61BFF46E}</ProjectGuid>
|
|
||||||
<RootNamespace>clientDemoStatic</RootNamespace>
|
|
||||||
<Keyword>ManagedCProj</Keyword>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<CLRSupport>false</CLRSupport>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<CLRSupport>false</CLRSupport>
|
|
||||||
<PlatformToolset>v100</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\bin\</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../obj/$(ProjectName)-$(Configuration)-VC10/</IntDir>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\bin\</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../obj/$(ProjectName)-$(Configuration)-VC10/</IntDir>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">clientDemoStaticDebugVC10</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)VC10</TargetName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<BuildLog>
|
|
||||||
<Path>$(IntDir)$(ProjectName)BuildLog.htm</Path>
|
|
||||||
</BuildLog>
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<AdditionalIncludeDirectories>..\..\include;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;ARIA_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>ArNetworkingStaticDebugVC10.lib;AriaStaticDebugVC10.lib;ws2_32.lib;winmm.lib;advapi32.lib</AdditionalDependencies>
|
|
||||||
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AssemblyDebug>true</AssemblyDebug>
|
|
||||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
|
||||||
<DataExecutionPrevention>
|
|
||||||
</DataExecutionPrevention>
|
|
||||||
<TargetMachine>NotSet</TargetMachine>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<BuildLog>
|
|
||||||
<Path>$(IntDir)$(ProjectName)BuildLog.htm</Path>
|
|
||||||
</BuildLog>
|
|
||||||
<ClCompile>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<AdditionalIncludeDirectories>..\..\include;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;ARIA_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>ArNetworkingStaticVC10.lib;AriaStaticVC10.lib;winmm.lib;ws2_32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
|
||||||
<DataExecutionPrevention>
|
|
||||||
</DataExecutionPrevention>
|
|
||||||
<ImportLibrary>
|
|
||||||
</ImportLibrary>
|
|
||||||
<TargetMachine>NotSet</TargetMachine>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="mscorlib">
|
|
||||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
|
||||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System">
|
|
||||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
|
||||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Data">
|
|
||||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
|
||||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="clientDemo.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,66 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
ArClientBase *client;
|
|
||||||
ArClientHandlerConfig *configHandler;
|
|
||||||
bool done = false;
|
|
||||||
|
|
||||||
void gotConfig(void)
|
|
||||||
{
|
|
||||||
ArConfig *newConfig;
|
|
||||||
done = true;
|
|
||||||
configHandler->getConfig()->writeFile("configClient.txt");
|
|
||||||
newConfig = new ArConfig(*(configHandler->getConfig()));
|
|
||||||
newConfig->writeFile("configClientNew.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Aria::init();
|
|
||||||
ArGlobalFunctor gotConfigCB(&gotConfig);
|
|
||||||
std::string hostname;
|
|
||||||
|
|
||||||
client = new ArClientBase;
|
|
||||||
configHandler = new ArClientHandlerConfig(client);
|
|
||||||
|
|
||||||
configHandler->addGotConfigCB(&gotConfigCB);
|
|
||||||
|
|
||||||
ArArgumentParser parser(&argc, argv);
|
|
||||||
|
|
||||||
ArClientSimpleConnector clientConnector(&parser);
|
|
||||||
|
|
||||||
parser.loadDefaultArguments();
|
|
||||||
|
|
||||||
/* Check for -help, and unhandled arguments: */
|
|
||||||
if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
Aria::logOptions();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
/* Connect our client object to the remote server: */
|
|
||||||
if (!clientConnector.connectClient(client))
|
|
||||||
{
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
client->setRobotName(client->getHost()); // include server hostname in log messages
|
|
||||||
|
|
||||||
configHandler->requestConfigFromServer();
|
|
||||||
client->runAsync();
|
|
||||||
|
|
||||||
while (!done)
|
|
||||||
ArUtil::sleep(100);
|
|
||||||
|
|
||||||
if (configHandler->canRequestDefaults())
|
|
||||||
{
|
|
||||||
configHandler->requestDefaultConfigFromServer();
|
|
||||||
while (!configHandler->haveGottenDefaults())
|
|
||||||
ArUtil::sleep(100);
|
|
||||||
printf("%d\n", configHandler->haveGottenDefaults());
|
|
||||||
configHandler->getDefaultConfig()->writeFile("configClientDefaults.txt");
|
|
||||||
printf("wrote defaults\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Aria::exit(0);
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
Pass this a file to send to the server (should be made by configClient then modified).
|
|
||||||
|
|
||||||
Takes a file to send, and can take the host to send to too
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
ArClientBase *client;
|
|
||||||
ArClientHandlerConfig *configHandler;
|
|
||||||
|
|
||||||
char *file;
|
|
||||||
|
|
||||||
void saveConfigSucceeded(void)
|
|
||||||
{
|
|
||||||
printf("HERE: Save config succeeded\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveConfigFailed(const char *str)
|
|
||||||
{
|
|
||||||
printf("HERE: Save config failed: %s\n", str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void gotConfig(void)
|
|
||||||
{
|
|
||||||
char errorBuffer[1024];
|
|
||||||
ArConfig *newConfig;
|
|
||||||
if (!configHandler->getConfig()->parseFile(file, false, false, errorBuffer,
|
|
||||||
sizeof(errorBuffer)))
|
|
||||||
printf("Error loading file: %s\n", errorBuffer);
|
|
||||||
|
|
||||||
configHandler->saveConfigToServer();
|
|
||||||
client->loopOnce();
|
|
||||||
ArUtil::sleep(1000);
|
|
||||||
client->loopOnce();
|
|
||||||
ArUtil::sleep(1000);
|
|
||||||
client->disconnect();
|
|
||||||
Aria::shutdown();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Aria::init();
|
|
||||||
//ArLog::init(ArLog::StdOut, ArLog::Verbose);
|
|
||||||
ArGlobalFunctor gotConfigCB(&gotConfig);
|
|
||||||
ArGlobalFunctor saveConfigSucceededCB(&saveConfigSucceeded);
|
|
||||||
ArGlobalFunctor1<const char *> saveConfigFailedCB(&saveConfigFailed);
|
|
||||||
std::string hostname;
|
|
||||||
|
|
||||||
client = new ArClientBase;
|
|
||||||
configHandler = new ArClientHandlerConfig(client, true);
|
|
||||||
|
|
||||||
configHandler->addGotConfigCB(&gotConfigCB);
|
|
||||||
configHandler->addSaveConfigSucceededCB(&saveConfigSucceededCB);
|
|
||||||
configHandler->addSaveConfigFailedCB(&saveConfigFailedCB);
|
|
||||||
|
|
||||||
if (argc == 1)
|
|
||||||
{
|
|
||||||
printf("Usage: %s <file> <host>\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
file = argv[1];
|
|
||||||
if (argc == 2)
|
|
||||||
hostname = "localhost";
|
|
||||||
else
|
|
||||||
hostname = argv[2];
|
|
||||||
|
|
||||||
|
|
||||||
if (!client->blockingConnect(hostname.c_str(), 7272))
|
|
||||||
{
|
|
||||||
printf("Could not connect to server, exiting\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
//client->requestOnce("setConfig");
|
|
||||||
configHandler->requestConfigFromServer();
|
|
||||||
//client->requestOnce("setConfig");
|
|
||||||
client->run();
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Aria::init();
|
|
||||||
ArServerBase server;
|
|
||||||
|
|
||||||
ArConfig *config;
|
|
||||||
config = Aria::getConfig();
|
|
||||||
std::string section;
|
|
||||||
char joy[512];
|
|
||||||
sprintf(joy, "Joy");
|
|
||||||
section = "section1";
|
|
||||||
config->addParam(ArConfigArg("int", new int, "fun int", 0), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("double", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("bool", new bool, "fun bool"), section.c_str(), ArPriority::IMPORTANT);
|
|
||||||
config->addParam(ArConfigArg("string", joy, "fun string", sizeof(joy)), section.c_str(), ArPriority::TRIVIAL);
|
|
||||||
section = "section8";
|
|
||||||
config->addParam(ArConfigArg("int", new int, "fun int", 0), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("double", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("doubleFOUR", (double).4, "fun double", 0.0, 1.0), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("double three", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("double two", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("double one", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("double", new double, "fun double", 0, 1), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("bool", new bool, "fun bool"), section.c_str(), ArPriority::IMPORTANT);
|
|
||||||
config->addParam(ArConfigArg("string", joy, "fun string", sizeof(joy)), section.c_str(), ArPriority::TRIVIAL);
|
|
||||||
section = "some section";
|
|
||||||
config->setSectionComment("some section", "this is a random section with 4 ints");
|
|
||||||
config->addParam(ArConfigArg("int1", new int, "fun int"), section.c_str(), ArPriority::TRIVIAL);
|
|
||||||
config->addParam(ArConfigArg("int2", new int, "fun int", -1, 1200), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("int3", new int, "fun int"), section.c_str(), ArPriority::IMPORTANT);
|
|
||||||
config->addParam(ArConfigArg("int4", new int, "fun int"), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("int4", new int, "fun int"), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("int1", new int, "fun int"), section.c_str(), ArPriority::TRIVIAL);
|
|
||||||
section = "another section";
|
|
||||||
config->setSectionComment("another section", "this is another section with 1 of each type");
|
|
||||||
config->addParam(ArConfigArg("inta", new int, "fun int"), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("doublea", new double, "fun double"), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("boola", new bool, "fun bool"), section.c_str(), ArPriority::NORMAL);
|
|
||||||
config->addParam(ArConfigArg("stringa", new char[512], "fun string", 512), section.c_str(), ArPriority::NORMAL);
|
|
||||||
|
|
||||||
if (!server.open(7272))
|
|
||||||
{
|
|
||||||
printf("Could not open server port\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
config->setBaseDirectory("./");
|
|
||||||
config->writeFile("default.txt");
|
|
||||||
config->parseFile("modified.txt");
|
|
||||||
config->writeFile("modifiedModified.txt");
|
|
||||||
ArServerHandlerConfig configHandler(&server, Aria::getConfig(),
|
|
||||||
"default.txt");
|
|
||||||
|
|
||||||
server.run();
|
|
||||||
|
|
||||||
Aria::shutdown();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Aria::init();
|
|
||||||
ArServerBase server;
|
|
||||||
|
|
||||||
//ArLog::init(ArLog::StdOut, ArLog::Verbose);
|
|
||||||
ArConfig *config;
|
|
||||||
config = Aria::getConfig();
|
|
||||||
|
|
||||||
ArRobotP3DX dx;
|
|
||||||
//dx.writeFile("dx.txt");
|
|
||||||
*Aria::getConfig() = dx;
|
|
||||||
//Aria::getConfig()->writeFile("dxcopy.txt");
|
|
||||||
|
|
||||||
if (!server.open(7272))
|
|
||||||
{
|
|
||||||
printf("Could not open server port\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArServerHandlerConfig configHandler(&server, Aria::getConfig());
|
|
||||||
server.run();
|
|
||||||
|
|
||||||
Aria::shutdown();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,287 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
|
|
||||||
/** @example drawingsExample.cpp Example showing how to draw custom graphics in
|
|
||||||
* clients such as MobileEyes
|
|
||||||
*
|
|
||||||
* This is an example server that shows how to draw arbitrary figures in a
|
|
||||||
* client (e.g. MobileEyes) via ArServerInfoDrawings. It draws some lines, "arrows", and moving dots
|
|
||||||
* with various sizes and colors. You can use these drawings for debugging
|
|
||||||
* or visualization, for example, to represent sensor readings. In fact,
|
|
||||||
* specific support for ArRobot, ArSick, ArSonarDevice, ArIRs and ArBumpers
|
|
||||||
* are built in to ArServerInfoDrawings: see drawingsExampleWithRobot.cpp
|
|
||||||
* or serverDemo.cpp.
|
|
||||||
*
|
|
||||||
* @sa drawingsExampleWithRobot.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* These are some callbacks that respond to client requests for the drawings'
|
|
||||||
* geometry data. */
|
|
||||||
void exampleHomeDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt);
|
|
||||||
void exampleDotsDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt);
|
|
||||||
void exampleXDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt);
|
|
||||||
void exampleArrowsDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt);
|
|
||||||
|
|
||||||
|
|
||||||
/* This class shows how to encapsulate the various aspects of a drawing into one
|
|
||||||
* object that other parts of the program can easily access in a more general
|
|
||||||
* (and thread-safe) way. It lets you change position, radius, resolution
|
|
||||||
* (number of dots), and dot drawing properties.
|
|
||||||
* The default radius is 1 meter and the default number of points is 360.
|
|
||||||
*
|
|
||||||
* In this example program, the radius is updated periodically by a loop in the
|
|
||||||
* main thread (see main() function), while ArNetworking requests are handled
|
|
||||||
* in the separate ArNetworking server thread, calling drawingServerCB() callback (this is
|
|
||||||
* registered with the server when we register the drawing with the
|
|
||||||
* ArServerInfoDrawings object). So note the use of an ArMutex object to
|
|
||||||
* control this asyrchronous access to the reply packet.
|
|
||||||
*/
|
|
||||||
class Circle
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ArNetPacket myReply;
|
|
||||||
ArMutex myMutex; // mutex around myReply
|
|
||||||
ArPose myPos;
|
|
||||||
double myRadius;
|
|
||||||
unsigned int myNumPoints;
|
|
||||||
void drawingServerCB(ArServerClient *client, ArNetPacket *pkt);
|
|
||||||
ArFunctor2C<Circle, ArServerClient*, ArNetPacket*> callback;
|
|
||||||
void regenerate();
|
|
||||||
public:
|
|
||||||
Circle(ArServerInfoDrawings *drawingsServer, const std::string& name, ArDrawingData *drawData);
|
|
||||||
~Circle();
|
|
||||||
|
|
||||||
void setPos(const ArPose& p)
|
|
||||||
{
|
|
||||||
myPos = p;
|
|
||||||
regenerate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setRadius(double r)
|
|
||||||
{
|
|
||||||
myRadius = r;
|
|
||||||
regenerate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setNumPoints(unsigned int r)
|
|
||||||
{
|
|
||||||
myNumPoints = r;
|
|
||||||
regenerate();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Circle::Circle(ArServerInfoDrawings *drawingsServer, const std::string& name, ArDrawingData* drawData) :
|
|
||||||
myRadius(1000.0),
|
|
||||||
myNumPoints(360),
|
|
||||||
callback(this, &Circle::drawingServerCB)
|
|
||||||
{
|
|
||||||
drawingsServer->addDrawing(drawData, name.c_str(), &callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
Circle::~Circle()
|
|
||||||
{
|
|
||||||
// TODO remove drawing from the server, but not implemented yet
|
|
||||||
}
|
|
||||||
|
|
||||||
void Circle::drawingServerCB(ArServerClient *client, ArNetPacket *pkt)
|
|
||||||
{
|
|
||||||
myMutex.lock();
|
|
||||||
client->sendPacketUdp(&myReply);
|
|
||||||
myMutex.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method called by accessor methods when properties changed. This reconstructs
|
|
||||||
// the myReply packet sent in response to requests from clients
|
|
||||||
void Circle::regenerate()
|
|
||||||
{
|
|
||||||
myMutex.lock();
|
|
||||||
myReply.empty();
|
|
||||||
myReply.byte4ToBuf(myNumPoints);
|
|
||||||
double a = 360.0/myNumPoints;
|
|
||||||
for(unsigned int i = 0; i < myNumPoints; ++i)
|
|
||||||
{
|
|
||||||
myReply.byte4ToBuf(ArMath::roundInt(myPos.getX()+ArMath::cos(i*a)*myRadius)); // X
|
|
||||||
myReply.byte4ToBuf(ArMath::roundInt(myPos.getY()+ArMath::sin(i*a)*myRadius)); // Y
|
|
||||||
}
|
|
||||||
myMutex.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Aria::init();
|
|
||||||
ArServerBase server;
|
|
||||||
|
|
||||||
ArArgumentParser parser(&argc, argv);
|
|
||||||
ArServerSimpleOpener simpleOpener(&parser);
|
|
||||||
|
|
||||||
// parse the command line... fail and print the help if the parsing fails
|
|
||||||
// or if help was requested
|
|
||||||
parser.loadDefaultArguments();
|
|
||||||
if (!simpleOpener.parseArgs() || !parser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
simpleOpener.logOptions();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// first open the server up
|
|
||||||
if (!simpleOpener.open(&server))
|
|
||||||
{
|
|
||||||
if (simpleOpener.wasUserFileBad())
|
|
||||||
printf("Error: Bad user/password/permissions file.\n");
|
|
||||||
else
|
|
||||||
printf("Error: Could not open server port. Use -help to see options.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// This is the service that provides drawing data to the client.
|
|
||||||
ArServerInfoDrawings drawings(&server);
|
|
||||||
|
|
||||||
// Add our custom drawings
|
|
||||||
drawings.addDrawing(
|
|
||||||
// shape: color: size: layer:
|
|
||||||
new ArDrawingData("polyLine", ArColor(255, 0, 0), 2, 49),
|
|
||||||
"exampleDrawing_Home",
|
|
||||||
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleHomeDrawingNetCallback)
|
|
||||||
);
|
|
||||||
drawings.addDrawing(
|
|
||||||
new ArDrawingData("polyDots", ArColor(0, 255, 0), 250, 48),
|
|
||||||
"exampleDrawing_Dots",
|
|
||||||
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleDotsDrawingNetCallback)
|
|
||||||
);
|
|
||||||
drawings.addDrawing(
|
|
||||||
new ArDrawingData("polySegments", ArColor(0, 0, 0), 4, 52),
|
|
||||||
"exampleDrawing_XMarksTheSpot",
|
|
||||||
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleXDrawingNetCallback)
|
|
||||||
);
|
|
||||||
drawings.addDrawing(
|
|
||||||
new ArDrawingData("polyArrows", ArColor(255, 0, 255), 500, 100),
|
|
||||||
"exampleDrawing_Arrows",
|
|
||||||
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleArrowsDrawingNetCallback)
|
|
||||||
);
|
|
||||||
|
|
||||||
Circle circle(&drawings, "exampleDrawing_circle",
|
|
||||||
new ArDrawingData("polySegments", ArColor(255, 150, 0), 3, 120));
|
|
||||||
circle.setPos(ArPose(0, -5000));
|
|
||||||
circle.setRadius(1000);
|
|
||||||
circle.setNumPoints(360);
|
|
||||||
|
|
||||||
// log whatever we wanted to before the runAsync
|
|
||||||
simpleOpener.checkAndLog();
|
|
||||||
|
|
||||||
// run the server thread in the background
|
|
||||||
server.runAsync();
|
|
||||||
|
|
||||||
printf("Server is now running...\n");
|
|
||||||
|
|
||||||
|
|
||||||
// Add a key handler mostly that windows can exit by pressing
|
|
||||||
// escape, note that the key handler prevents you from running this program
|
|
||||||
// in the background on Linux.
|
|
||||||
ArKeyHandler *keyHandler;
|
|
||||||
if ((keyHandler = Aria::getKeyHandler()) == NULL)
|
|
||||||
{
|
|
||||||
keyHandler = new ArKeyHandler;
|
|
||||||
Aria::setKeyHandler(keyHandler);
|
|
||||||
printf("To exit, press escape.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
double circleRadius = 1000;
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
ArUtil::sleep(100);
|
|
||||||
circleRadius += 50;
|
|
||||||
if(circleRadius > 5000)
|
|
||||||
circleRadius = 0;
|
|
||||||
circle.setRadius(circleRadius);
|
|
||||||
}
|
|
||||||
|
|
||||||
Aria::shutdown();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Network callbacks for drawings' current geometry data:
|
|
||||||
|
|
||||||
void exampleHomeDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
|
|
||||||
ArNetPacket reply;
|
|
||||||
|
|
||||||
// 7 Vertices
|
|
||||||
reply.byte4ToBuf(7);
|
|
||||||
|
|
||||||
// Centered on 0,0.
|
|
||||||
// X: Y:
|
|
||||||
reply.byte4ToBuf(-500); reply.byte4ToBuf(500); // Vertex 1
|
|
||||||
reply.byte4ToBuf(-500); reply.byte4ToBuf(-500); // Vertex 2
|
|
||||||
reply.byte4ToBuf(500); reply.byte4ToBuf(-500); // Vertex 3
|
|
||||||
reply.byte4ToBuf(500); reply.byte4ToBuf(500); // Vertex 4
|
|
||||||
reply.byte4ToBuf(0); reply.byte4ToBuf(1000); // Vertex 5
|
|
||||||
reply.byte4ToBuf(-500); reply.byte4ToBuf(500); // Vertex 6
|
|
||||||
reply.byte4ToBuf(500); reply.byte4ToBuf(500); // Vertex 7
|
|
||||||
|
|
||||||
client->sendPacketUdp(&reply);
|
|
||||||
}
|
|
||||||
|
|
||||||
void exampleDotsDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
|
|
||||||
ArNetPacket reply;
|
|
||||||
|
|
||||||
unsigned int tik = ArUtil::getTime() % 200;
|
|
||||||
double t = tik / 5.0;
|
|
||||||
|
|
||||||
// Three dots
|
|
||||||
reply.byte4ToBuf(3);
|
|
||||||
|
|
||||||
// Dot 1:
|
|
||||||
reply.byte4ToBuf(3000); // X coordinate (mm)
|
|
||||||
reply.byte4ToBuf((int) (sin(t) * 1000));// Y
|
|
||||||
|
|
||||||
// Dot 2:
|
|
||||||
reply.byte4ToBuf(3500); // X
|
|
||||||
reply.byte4ToBuf((int) (sin(t+500) * 1000));// Y
|
|
||||||
|
|
||||||
// Dot 3:
|
|
||||||
reply.byte4ToBuf(4000); // X
|
|
||||||
reply.byte4ToBuf((int) (sin(t+1000) * 1000));// Y
|
|
||||||
|
|
||||||
client->sendPacketUdp(&reply);
|
|
||||||
}
|
|
||||||
|
|
||||||
void exampleXDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
|
|
||||||
ArNetPacket reply;
|
|
||||||
|
|
||||||
// X marks the spot. 2 line segments, so 4 vertices:
|
|
||||||
reply.byte4ToBuf(4);
|
|
||||||
|
|
||||||
// Segment 1:
|
|
||||||
reply.byte4ToBuf(-4250); // X1
|
|
||||||
reply.byte4ToBuf(250); // Y1
|
|
||||||
reply.byte4ToBuf(-3750); // X2
|
|
||||||
reply.byte4ToBuf(-250); // Y2
|
|
||||||
|
|
||||||
// Segment 2:
|
|
||||||
reply.byte4ToBuf(-4250); // X1
|
|
||||||
reply.byte4ToBuf(-250); // Y1
|
|
||||||
reply.byte4ToBuf(-3750); // X2
|
|
||||||
reply.byte4ToBuf(250); // Y2
|
|
||||||
|
|
||||||
client->sendPacketUdp(&reply);
|
|
||||||
}
|
|
||||||
|
|
||||||
void exampleArrowsDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
|
|
||||||
// 1 Arrow that points at the robot
|
|
||||||
ArNetPacket reply;
|
|
||||||
reply.byte4ToBuf(1);
|
|
||||||
reply.byte4ToBuf(0); // Pos. X
|
|
||||||
reply.byte4ToBuf(700); // Pos. Y
|
|
||||||
client->sendPacketUdp(&reply);
|
|
||||||
}
|
|
||||||
|
|
@ -1,256 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
/** @example drawingsExampleWithRobot.cpp Example showing how to draw custom
|
|
||||||
* graphics in clients such as MobileEyes, and enable drawing of sensor
|
|
||||||
* readings as well.
|
|
||||||
*
|
|
||||||
* This is an example server that shows how to draw arbitrary figures in a
|
|
||||||
* client (e.g. MobileEyes). It also uses the convenient built-in
|
|
||||||
* support for visualization built in to ArRobot, ArSick, ArSonarDevice,
|
|
||||||
* etc.
|
|
||||||
*
|
|
||||||
* @sa drawingsExample.cpp which does not include robot and sensor drawings
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* These are callbacks that respond to client requests for the drawings'
|
|
||||||
* geometry data. */
|
|
||||||
void exampleHomeDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt);
|
|
||||||
void exampleDotsDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt);
|
|
||||||
void exampleXDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt);
|
|
||||||
void exampleArrowsDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt);
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Aria::init();
|
|
||||||
ArRobot robot;
|
|
||||||
ArServerBase server;
|
|
||||||
|
|
||||||
ArArgumentParser parser(&argc, argv);
|
|
||||||
ArSimpleConnector simpleConnector(&parser);
|
|
||||||
ArServerSimpleOpener simpleOpener(&parser);
|
|
||||||
|
|
||||||
|
|
||||||
// parse the command line... fail and print the help if the parsing fails
|
|
||||||
// or if help was requested
|
|
||||||
parser.loadDefaultArguments();
|
|
||||||
if (!simpleConnector.parseArgs() || !simpleOpener.parseArgs() ||
|
|
||||||
!parser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
simpleConnector.logOptions();
|
|
||||||
simpleOpener.logOptions();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up where we'll look for files such as config file, user/password file,
|
|
||||||
// etc.
|
|
||||||
char fileDir[1024];
|
|
||||||
ArUtil::addDirectories(fileDir, sizeof(fileDir), Aria::getDirectory(),
|
|
||||||
"ArNetworking/examples");
|
|
||||||
|
|
||||||
// first open the server up
|
|
||||||
if (!simpleOpener.open(&server, fileDir, 240))
|
|
||||||
{
|
|
||||||
if (simpleOpener.wasUserFileBad())
|
|
||||||
printf("Error: Bad user/password/permissions file.\n");
|
|
||||||
else
|
|
||||||
printf("Error: Could not open server port. Use -help to see options.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Devices
|
|
||||||
ArAnalogGyro gyro(&robot);
|
|
||||||
|
|
||||||
ArSonarDevice sonarDev;
|
|
||||||
robot.addRangeDevice(&sonarDev);
|
|
||||||
|
|
||||||
ArIRs irs;
|
|
||||||
robot.addRangeDevice(&irs);
|
|
||||||
|
|
||||||
ArBumpers bumpers;
|
|
||||||
robot.addRangeDevice(&bumpers);
|
|
||||||
|
|
||||||
ArSick sick(361, 180);
|
|
||||||
robot.addRangeDevice(&sick);
|
|
||||||
|
|
||||||
|
|
||||||
ArServerInfoRobot serverInfoRobot(&server, &robot);
|
|
||||||
ArServerInfoSensor serverInfoSensor(&server, &robot);
|
|
||||||
|
|
||||||
// This is the service that provides drawing data to the client.
|
|
||||||
ArServerInfoDrawings drawings(&server);
|
|
||||||
|
|
||||||
// Convenience function that sets up drawings for all the robot's current
|
|
||||||
// range devices (using default shape and color info)
|
|
||||||
drawings.addRobotsRangeDevices(&robot);
|
|
||||||
|
|
||||||
// Add our custom drawings
|
|
||||||
drawings.addDrawing(
|
|
||||||
// shape: color: size: layer:
|
|
||||||
new ArDrawingData("polyLine", ArColor(255, 0, 0), 2, 49),
|
|
||||||
"exampleDrawing_Home",
|
|
||||||
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleHomeDrawingNetCallback)
|
|
||||||
);
|
|
||||||
drawings.addDrawing(
|
|
||||||
new ArDrawingData("polyDots", ArColor(0, 255, 0), 250, 48),
|
|
||||||
"exampleDrawing_Dots",
|
|
||||||
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleDotsDrawingNetCallback)
|
|
||||||
);
|
|
||||||
drawings.addDrawing(
|
|
||||||
new ArDrawingData("polySegments", ArColor(0, 0, 0), 4, 52),
|
|
||||||
"exampleDrawing_XMarksTheSpot",
|
|
||||||
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleXDrawingNetCallback)
|
|
||||||
);
|
|
||||||
drawings.addDrawing(
|
|
||||||
new ArDrawingData("polyArrows", ArColor(255, 0, 255), 500, 100),
|
|
||||||
"exampleDrawing_Arrows",
|
|
||||||
new ArGlobalFunctor2<ArServerClient*, ArNetPacket*>(&exampleArrowsDrawingNetCallback)
|
|
||||||
);
|
|
||||||
|
|
||||||
// modes for moving the robot
|
|
||||||
ArServerModeStop modeStop(&server, &robot);
|
|
||||||
ArServerModeDrive modeDrive(&server, &robot);
|
|
||||||
ArServerModeRatioDrive modeRatioDrive(&server, &robot);
|
|
||||||
ArServerModeWander modeWander(&server, &robot);
|
|
||||||
modeStop.addAsDefaultMode();
|
|
||||||
modeStop.activate();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Connect to the robot.
|
|
||||||
if (!simpleConnector.connectRobot(&robot))
|
|
||||||
{
|
|
||||||
printf("Error: Could not connect to robot... exiting\n");
|
|
||||||
Aria::shutdown();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set up the laser before handing it to the laser mode
|
|
||||||
simpleConnector.setupLaser(&sick);
|
|
||||||
|
|
||||||
robot.enableMotors();
|
|
||||||
|
|
||||||
// start the robot cycle running in a background thread
|
|
||||||
robot.runAsync(true);
|
|
||||||
|
|
||||||
// start the laser processing cycle in a background thread
|
|
||||||
sick.runAsync();
|
|
||||||
|
|
||||||
// connect the laser if it was requested
|
|
||||||
if (!simpleConnector.connectLaser(&sick))
|
|
||||||
{
|
|
||||||
printf("Error: Could not connect to laser... exiting\n");
|
|
||||||
Aria::shutdown();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// log whatever we wanted to before the runAsync
|
|
||||||
simpleOpener.checkAndLog();
|
|
||||||
|
|
||||||
// run the server thread in the background
|
|
||||||
server.runAsync();
|
|
||||||
|
|
||||||
printf("Server is now running...\n");
|
|
||||||
|
|
||||||
|
|
||||||
// Add a key handler mostly that windows can exit by pressing
|
|
||||||
// escape, note that the key handler prevents you from running this program
|
|
||||||
// in the background on Linux.
|
|
||||||
ArKeyHandler *keyHandler;
|
|
||||||
if ((keyHandler = Aria::getKeyHandler()) == NULL)
|
|
||||||
{
|
|
||||||
keyHandler = new ArKeyHandler;
|
|
||||||
Aria::setKeyHandler(keyHandler);
|
|
||||||
robot.lock();
|
|
||||||
robot.attachKeyHandler(keyHandler);
|
|
||||||
robot.unlock();
|
|
||||||
printf("To exit, press escape.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
robot.waitForRunExit();
|
|
||||||
|
|
||||||
|
|
||||||
Aria::shutdown();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Network callbacks for drawings' current geometry data:
|
|
||||||
|
|
||||||
void exampleHomeDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
|
|
||||||
ArNetPacket reply;
|
|
||||||
|
|
||||||
// 7 Vertices
|
|
||||||
reply.byte4ToBuf(7);
|
|
||||||
|
|
||||||
// Centered on 0,0.
|
|
||||||
// X: Y:
|
|
||||||
reply.byte4ToBuf(-500); reply.byte4ToBuf(500); // Vertex 1
|
|
||||||
reply.byte4ToBuf(-500); reply.byte4ToBuf(-500); // Vertex 2
|
|
||||||
reply.byte4ToBuf(500); reply.byte4ToBuf(-500); // Vertex 3
|
|
||||||
reply.byte4ToBuf(500); reply.byte4ToBuf(500); // Vertex 4
|
|
||||||
reply.byte4ToBuf(0); reply.byte4ToBuf(1000); // Vertex 5
|
|
||||||
reply.byte4ToBuf(-500); reply.byte4ToBuf(500); // Vertex 6
|
|
||||||
reply.byte4ToBuf(500); reply.byte4ToBuf(500); // Vertex 7
|
|
||||||
|
|
||||||
client->sendPacketUdp(&reply);
|
|
||||||
}
|
|
||||||
|
|
||||||
void exampleDotsDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
|
|
||||||
ArNetPacket reply;
|
|
||||||
|
|
||||||
unsigned int tik = ArUtil::getTime() % 200;
|
|
||||||
double t = tik / 5.0;
|
|
||||||
|
|
||||||
// Three dots
|
|
||||||
reply.byte4ToBuf(3);
|
|
||||||
|
|
||||||
// Dot 1:
|
|
||||||
reply.byte4ToBuf(3000); // X coordinate (mm)
|
|
||||||
reply.byte4ToBuf((int) (sin(t) * 1000));// Y
|
|
||||||
|
|
||||||
// Dot 2:
|
|
||||||
reply.byte4ToBuf(3500); // X
|
|
||||||
reply.byte4ToBuf((int) (sin(t+500) * 1000));// Y
|
|
||||||
|
|
||||||
// Dot 3:
|
|
||||||
reply.byte4ToBuf(4000); // X
|
|
||||||
reply.byte4ToBuf((int) (sin(t+1000) * 1000));// Y
|
|
||||||
|
|
||||||
client->sendPacketUdp(&reply);
|
|
||||||
}
|
|
||||||
|
|
||||||
void exampleXDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
|
|
||||||
ArNetPacket reply;
|
|
||||||
|
|
||||||
// X marks the spot. 2 line segments, so 4 vertices:
|
|
||||||
reply.byte4ToBuf(4);
|
|
||||||
|
|
||||||
// Segment 1:
|
|
||||||
reply.byte4ToBuf(-4250); // X1
|
|
||||||
reply.byte4ToBuf(250); // Y1
|
|
||||||
reply.byte4ToBuf(-3750); // X2
|
|
||||||
reply.byte4ToBuf(-250); // Y2
|
|
||||||
|
|
||||||
// Segment 2:
|
|
||||||
reply.byte4ToBuf(-4250); // X1
|
|
||||||
reply.byte4ToBuf(-250); // Y1
|
|
||||||
reply.byte4ToBuf(-3750); // X2
|
|
||||||
reply.byte4ToBuf(250); // Y2
|
|
||||||
|
|
||||||
client->sendPacketUdp(&reply);
|
|
||||||
}
|
|
||||||
|
|
||||||
void exampleArrowsDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
|
|
||||||
// 1 Arrow that points at the robot
|
|
||||||
ArNetPacket reply;
|
|
||||||
reply.byte4ToBuf(1);
|
|
||||||
reply.byte4ToBuf(0); // Pos. X
|
|
||||||
reply.byte4ToBuf(700); // Pos. Y
|
|
||||||
client->sendPacketUdp(&reply);
|
|
||||||
}
|
|
||||||
|
|
@ -1,164 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
/** @example getVideoExample.cpp
|
|
||||||
*
|
|
||||||
* This example client requests video images from the server
|
|
||||||
* and saves them repeatedly to a file named "video.jpg", or
|
|
||||||
* to a series of files ("video1.jpg", "video2.jpg", etc.) if
|
|
||||||
* you give the -counter option. Give the image request rate
|
|
||||||
* in images per second with the -rate option (or use -1 to let
|
|
||||||
* the server decide when to send image; may not work with all servers).
|
|
||||||
*
|
|
||||||
* Connect to SAVserver, ACTS, or another video server to get
|
|
||||||
* images.
|
|
||||||
*
|
|
||||||
* To make a movie from the images, you can use ffmpeg on Linux.
|
|
||||||
* First run with frame rate and counter options to save multiple images:
|
|
||||||
* ./getVideoExample -host robothost -port 7272 -rate 20 -counter
|
|
||||||
* Then use ffmpeg:
|
|
||||||
* ffmpeg -i video%d.jpeg -r 20 movie.mpeg
|
|
||||||
* See ffmpeg -h for full list of options.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
bool useCounter = false;
|
|
||||||
unsigned long counter = 1;
|
|
||||||
|
|
||||||
double rate = 0;
|
|
||||||
int rateAsTime = 0;
|
|
||||||
|
|
||||||
void jpegHandler(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
static unsigned char jpeg[50000];
|
|
||||||
int jpegSize;
|
|
||||||
FILE *file;
|
|
||||||
|
|
||||||
width = packet->bufToUByte2();
|
|
||||||
height = packet->bufToUByte2();
|
|
||||||
jpegSize = packet->getDataLength() - packet->getDataReadLength();
|
|
||||||
if(jpegSize > 50000)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "Cannot save image, it's too big. (image is %d bytes, my buffer is 50000 bytes)", jpegSize);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
packet->bufToData((char *)jpeg, jpegSize);
|
|
||||||
char filename[128];
|
|
||||||
char tmpFilename[128];
|
|
||||||
sprintf(tmpFilename, "tmp.jpg");
|
|
||||||
if ((file = ArUtil::fopen(tmpFilename, "wb")) != NULL)
|
|
||||||
{
|
|
||||||
fwrite(jpeg, jpegSize, 1, file);
|
|
||||||
fclose(file);
|
|
||||||
if(useCounter)
|
|
||||||
snprintf(filename, 64, "video%lu.jpg", counter++);
|
|
||||||
else
|
|
||||||
strcpy(filename, "video.jpg");
|
|
||||||
#ifdef WIN32
|
|
||||||
// On windows, rename() fails if the new file already exists
|
|
||||||
unlink(filename);
|
|
||||||
#endif
|
|
||||||
if (rename(tmpFilename, filename) == 0)
|
|
||||||
ArLog::log(ArLog::Normal, "Wrote a %dx%d image, %d bytes, named %s.", width, height, jpegSize, filename);
|
|
||||||
else
|
|
||||||
ArLog::log(ArLog::Normal, "Wrote a %dx%d image, %d bytes, named %s (could not rename to real name).", width, height, jpegSize, tmpFilename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ArLog::log(ArLog::Normal, "Could not write temp file %s", tmpFilename);
|
|
||||||
|
|
||||||
if (rate == 0 || rateAsTime == 0)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "Only one frame was requested, so exiting");
|
|
||||||
Aria::exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
ArDaemonizer daemonizer(&argc, argv, false);
|
|
||||||
bool isDaemonized = false;
|
|
||||||
if (!daemonizer.daemonize())
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Terse, "Could not daemonize process");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (daemonizer.isDaemonized())
|
|
||||||
isDaemonized = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Aria::init();
|
|
||||||
ArLog::init(ArLog::File, ArLog::Normal, "getVideoLog.txt", true, true, true);
|
|
||||||
|
|
||||||
ArArgumentParser argParser(&argc, argv);
|
|
||||||
argParser.loadDefaultArguments();
|
|
||||||
|
|
||||||
ArClientSimpleConnector clientConnector(&argParser);
|
|
||||||
|
|
||||||
if(argParser.checkParameterArgumentDouble("-rate", &rate) && rate != 0.0)
|
|
||||||
{
|
|
||||||
if(rate == -1)
|
|
||||||
rateAsTime = -1;
|
|
||||||
else
|
|
||||||
rateAsTime = ArMath::roundInt(1000.0 / rate);
|
|
||||||
}
|
|
||||||
|
|
||||||
useCounter = argParser.checkArgument("-counter");
|
|
||||||
|
|
||||||
if(!Aria::parseArgs() || !argParser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
Aria::logOptions();
|
|
||||||
ArLog::log(ArLog::Terse, "\n\n%s options:\n-rate <FramesPerSecondAsDouble> (If this isn't given, then the program will take one frame then exit, note that it is a double (so you can do .5 to do one frame per 2 seconds) and that if you set it to be too fast you'll saturate the robot's bandwidth and make it useless)\n-counter (default no)\n", argv[0]);
|
|
||||||
|
|
||||||
ArLog::log(ArLog::Terse, "\n\nNotes:\nThis program saves the images as video.jpg if you aren't using a counter, or video<counter>.jpg if you are using the counter.\nIt puts its logs into getVideoLog.txt, and overwrites it whenever it runs\n");
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ArClientBase client;
|
|
||||||
if (!clientConnector.connectClient(&client))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "Could not connect to server, exiting\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArGlobalFunctor1<ArNetPacket *> jpegHandlerCB(&jpegHandler);
|
|
||||||
|
|
||||||
if(client.dataExists("getPictureCam1"))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "Requesting images using \"getPictureCam1\" request.");
|
|
||||||
client.addHandler("getPictureCam1", &jpegHandlerCB);
|
|
||||||
if (rate != 0 && rateAsTime != 0)
|
|
||||||
client.request("getPictureCam1", rateAsTime);
|
|
||||||
else
|
|
||||||
client.requestOnce("getPictureCam1");
|
|
||||||
}
|
|
||||||
else if(client.dataExists("sendVideo"))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "Server does not have \"getPictureCam1\" request, requesting images using old \"sendVideo\" request.");
|
|
||||||
client.addHandler("sendVideo", &jpegHandlerCB);
|
|
||||||
if (rate != 0 && rateAsTime != 0)
|
|
||||||
client.request("sendVideo", rateAsTime);
|
|
||||||
else
|
|
||||||
client.requestOnce("sendVideo");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Terse, "Error: Server does not have \"getPictureCam1\" or \"sendVideo\" request, cannot request images.");
|
|
||||||
Aria::exit(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
client.run();
|
|
||||||
|
|
||||||
Aria::shutdown();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,189 +0,0 @@
|
|||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
/** @example popupExample.cpp Shows how to create popup windows in a client like MobileEyes
|
|
||||||
*
|
|
||||||
* This example server program connects to a robot, and sends a message to clients (e.g. MobileEyes) to display
|
|
||||||
* in a dialog box when a sensor reading is detected in front of the robot
|
|
||||||
* within 1 meter. It also checks to see if that obstacle is not at the same
|
|
||||||
* angle as the previous detected obstacle -- it's probably the same one,
|
|
||||||
* unmoved -- to avoid sending repeated popups. The popup offers three choices,
|
|
||||||
* acknowlege and do nothing, turn the robot around 180 degrees, or exit the server.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
class SensorDetectPopup
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SensorDetectPopup(ArRobot *robot, ArServerHandlerPopup *popupServer);
|
|
||||||
protected:
|
|
||||||
ArRobot *myRobot;
|
|
||||||
ArServerHandlerPopup *myPopupServer;
|
|
||||||
bool myPopupDisplayed;
|
|
||||||
double myPrevObstacleAngle;
|
|
||||||
bool myPrevObstacleAngleValid;
|
|
||||||
ArFunctor2C<SensorDetectPopup, ArTypes::Byte4, int> *myPopupClosedCB;
|
|
||||||
|
|
||||||
void popupClosed(ArTypes::Byte4 popupID, int button);
|
|
||||||
void sensorTask(void) ;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Aria::init();
|
|
||||||
ArRobot robot;
|
|
||||||
ArSonarDevice sonar;
|
|
||||||
ArSick sick;
|
|
||||||
robot.addRangeDevice(&sonar);
|
|
||||||
ArServerBase server;
|
|
||||||
|
|
||||||
// Argument parser:
|
|
||||||
ArArgumentParser parser(&argc, argv);
|
|
||||||
parser.loadDefaultArguments();
|
|
||||||
|
|
||||||
// Connector and server opener:
|
|
||||||
ArRobotConnector robotConnector(&parser, &robot);
|
|
||||||
if(!robotConnector.connectRobot())
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Terse, "popupExample: Could not connect to the robot.");
|
|
||||||
if(parser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
Aria::logOptions();
|
|
||||||
}
|
|
||||||
Aria::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArLaserConnector laserConnector(&parser, &robot, &robotConnector);
|
|
||||||
|
|
||||||
ArServerSimpleOpener simpleOpener(&parser);
|
|
||||||
|
|
||||||
// Get command-line and other parameters
|
|
||||||
if(!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
Aria::logOptions();
|
|
||||||
Aria::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
robot.runAsync(true);
|
|
||||||
|
|
||||||
// connect to the laser
|
|
||||||
if(!laserConnector.connectLasers())
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "popupExample: Warning: Could not connect to lasers.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Open the server
|
|
||||||
if(!simpleOpener.open(&server))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Terse, "popupExample: Error, could not open server.");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
server.runAsync();
|
|
||||||
ArLog::log(ArLog::Normal, "popupExample: Server running. Press control-C to exit.");
|
|
||||||
ArLog::log(ArLog::Normal, "popupExample: Each time an obstacle is detected near the robot, a new popup message will be created. Connect with MobileEyes to see them.");
|
|
||||||
|
|
||||||
// Sends robot position etc.
|
|
||||||
ArServerInfoRobot robotInfoServer(&server, &robot);
|
|
||||||
|
|
||||||
// This service sends drawings e.g. showing range device positions
|
|
||||||
ArServerInfoDrawings drawingsServer(&server);
|
|
||||||
drawingsServer.addRobotsRangeDevices(&robot);
|
|
||||||
|
|
||||||
// This service can send messages to clients to display as popup dialogs:
|
|
||||||
ArServerHandlerPopup popupServer(&server);
|
|
||||||
|
|
||||||
// This object contains the robot sensor interpretation task and creates
|
|
||||||
// popups:
|
|
||||||
SensorDetectPopup(&robot, &popupServer);
|
|
||||||
|
|
||||||
robot.enableMotors();
|
|
||||||
robot.waitForRunExit();
|
|
||||||
|
|
||||||
Aria::exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SensorDetectPopup::SensorDetectPopup(ArRobot *robot, ArServerHandlerPopup *popupServer) :
|
|
||||||
myRobot(robot),
|
|
||||||
myPopupServer(popupServer),
|
|
||||||
myPopupDisplayed(false),
|
|
||||||
myPrevObstacleAngleValid(false)
|
|
||||||
{
|
|
||||||
myRobot->lock();
|
|
||||||
myRobot->addSensorInterpTask("sensorDetectPopup", 50, new ArFunctorC<SensorDetectPopup>(this, &SensorDetectPopup::sensorTask));
|
|
||||||
myPopupClosedCB = new ArFunctor2C<SensorDetectPopup, ArTypes::Byte4, int>(this, &SensorDetectPopup::popupClosed);
|
|
||||||
myRobot->unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SensorDetectPopup::sensorTask(void)
|
|
||||||
{
|
|
||||||
// Basic obstacle detection
|
|
||||||
|
|
||||||
if (myPopupDisplayed) return;
|
|
||||||
double detectAngle, detectRange;
|
|
||||||
detectRange = myRobot->checkRangeDevicesCurrentPolar(-90, 90, &detectAngle);
|
|
||||||
if (detectRange > 0 && detectRange <= 500)
|
|
||||||
{
|
|
||||||
if(myPrevObstacleAngleValid && fabs(detectAngle - myPrevObstacleAngle) < 0.0001)
|
|
||||||
return;
|
|
||||||
ArLog::log(ArLog::Normal, "popupExample: New obstacle detected at range %f, angle %f. Displaying popup dialog on client...", detectRange, detectAngle);
|
|
||||||
|
|
||||||
ArServerHandlerPopupInfo info("popupExample", // ID
|
|
||||||
"Object Detected", // Title
|
|
||||||
"A range sensor detected a reading within 0.5 meters of the robot.", // Message
|
|
||||||
ArServerHandlerPopup::INFORMATION, // Type
|
|
||||||
0, // Default button
|
|
||||||
0, // Cancel/escape button
|
|
||||||
5, // Timeout (sec.)
|
|
||||||
NULL, // Timeout String
|
|
||||||
"OK", "Acknowleged.", // Button 0 Label/Acknowlegement
|
|
||||||
"Turn Around", "Requested rotate...", // Button 1 Label/Acknowlegement
|
|
||||||
"Shut Down", "Shutting down server..." // Button 2 Label/Acknowlegement
|
|
||||||
);
|
|
||||||
int id = myPopupServer->createPopup(&info, myPopupClosedCB);
|
|
||||||
ArLog::log(ArLog::Normal, "\t...Created a popup with ID=%d", id);
|
|
||||||
myPopupDisplayed = true;
|
|
||||||
myPrevObstacleAngle = detectAngle;
|
|
||||||
myPrevObstacleAngleValid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SensorDetectPopup::popupClosed(ArTypes::Byte4 popupID, int button)
|
|
||||||
{
|
|
||||||
// A client closed the popup
|
|
||||||
ArLog::log(ArLog::Normal, "popupExample: a client closed popup dialog window with id=%d. Button=%d...", popupID, button);
|
|
||||||
myPopupDisplayed = false;
|
|
||||||
|
|
||||||
if(button < 0)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "\t...popup timed out or closed due to an error.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (button == 0)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "\t...OK pressed.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(button == 1)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "\t...180 degree rotate requested.");
|
|
||||||
myRobot->lock();
|
|
||||||
myRobot->setDeltaHeading(180);
|
|
||||||
myRobot->unlock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(button == 2)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "\t...exit requested.");
|
|
||||||
myRobot->stopRunning();
|
|
||||||
Aria::shutdown();
|
|
||||||
Aria::exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,334 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
|
|
||||||
/** @example ptzCameraClientExample.cpp Example client showing how to control a Pan/Tilt/Zoom
|
|
||||||
* camera remotely.
|
|
||||||
*
|
|
||||||
* To use, serverDemo, arnlServer from ARNL, sonarnlServer from SONARNL, or
|
|
||||||
* your own server program that includes an ArServerHandlerCamera object.
|
|
||||||
* Then from another host, run ptzCameraClientExample with the -host argument.
|
|
||||||
* For example, if the hostname of the robot's onboard computer is "robot", run:
|
|
||||||
* ptzCameraClientExample -host robot
|
|
||||||
* Or use an IP address, for example, if the address is 10.0.126.32:
|
|
||||||
* ptzCameraClientExample -host 10.0.126.32
|
|
||||||
*
|
|
||||||
* This program connects to the server, gets a list of cameras if neccesary, and
|
|
||||||
* for each camera on the robot, it receives and prints out one information
|
|
||||||
* packet, then a continuous stream of data packets, and then sends requests
|
|
||||||
* to cycle through each of its pan and tilt limits.
|
|
||||||
*
|
|
||||||
* This program does not get any video images from the server. To do so, use
|
|
||||||
* a video server (e.g. SAV server or ACTS), and see getVideoExample for an
|
|
||||||
* example client.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** A request packet that is able to send a copy of itself, with data packed in,
|
|
||||||
* to a server.
|
|
||||||
*/
|
|
||||||
class ArNetCameraRequest : public ArNetPacket
|
|
||||||
{
|
|
||||||
ArClientBase *myClient;
|
|
||||||
std::string myAbsReqName;
|
|
||||||
public:
|
|
||||||
ArNetCameraRequest(ArClientBase *client, const char *cameraName = "") : myClient(client), myAbsReqName(std::string("setCameraAbs")+cameraName)
|
|
||||||
{}
|
|
||||||
void setCameraName(const char *name) {
|
|
||||||
myAbsReqName = std::string("setCameraAbs") + name;
|
|
||||||
}
|
|
||||||
bool requestPanTiltZoomAbs(double pan, double tilt, double zoom);
|
|
||||||
bool requestPanTiltAbs(double pan, double tilt);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** Includes callbacks for receiving info and data packets from a
|
|
||||||
* camera server and storing the values parsed from them.
|
|
||||||
*/
|
|
||||||
class ArClientHandlerCamera {
|
|
||||||
public:
|
|
||||||
std::string name;
|
|
||||||
std::string type;
|
|
||||||
std::string displayName;
|
|
||||||
std::string displayType;
|
|
||||||
double minPan, maxPan, minTilt, maxTilt, minZoom, maxZoom;
|
|
||||||
bool haveZoom;
|
|
||||||
double pan, tilt, zoom;
|
|
||||||
|
|
||||||
void handleCameraInfoReply(ArNetPacket *packet);
|
|
||||||
void handleCameraDataReply(ArNetPacket *packet);
|
|
||||||
|
|
||||||
ArClientBase *myClient;
|
|
||||||
ArNetCameraRequest request;
|
|
||||||
ArMutex myMutex;
|
|
||||||
|
|
||||||
ArFunctor1C<ArClientHandlerCamera, ArNetPacket*> myCameraInfoReplyFunc;
|
|
||||||
ArFunctor1C<ArClientHandlerCamera, ArNetPacket*> myCameraDataReplyFunc;
|
|
||||||
|
|
||||||
ArClientHandlerCamera(ArClientBase *client, const char *cameraName) :
|
|
||||||
name(cameraName), myClient(client), request(client, cameraName) ,
|
|
||||||
myCameraInfoReplyFunc(this, &ArClientHandlerCamera::handleCameraInfoReply),
|
|
||||||
myCameraDataReplyFunc(this, &ArClientHandlerCamera::handleCameraDataReply)
|
|
||||||
{
|
|
||||||
myClient->addHandler((std::string("getCameraInfo")+name).c_str(), &myCameraInfoReplyFunc);
|
|
||||||
myClient->addHandler((std::string("getCameraData")+name).c_str(), &myCameraDataReplyFunc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void requestUpdates(int dataRequestFreq) {
|
|
||||||
myClient->request((std::string("getCameraInfo")+name).c_str(), -1);
|
|
||||||
myClient->request((std::string("getCameraData")+name).c_str(), 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lock() { myMutex.lock(); }
|
|
||||||
void unlock() { myMutex.unlock(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** Requests a list of cameras if neccesary, maintains a list of cameras, and implements example pan/tilt movements */
|
|
||||||
class PtzCameraExample
|
|
||||||
{
|
|
||||||
ArClientBase *myClient;
|
|
||||||
|
|
||||||
std::set<ArClientHandlerCamera*> myCameras;
|
|
||||||
ArMutex mutex;
|
|
||||||
|
|
||||||
ArFunctor1C<PtzCameraExample, ArNetPacket*> myCameraListReplyFunc;
|
|
||||||
|
|
||||||
void handleCameraListReply(ArNetPacket *packet);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
PtzCameraExample(ArClientBase *client) :
|
|
||||||
myClient(client),
|
|
||||||
myCameraListReplyFunc(this, &PtzCameraExample::handleCameraListReply)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool init();
|
|
||||||
void run();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Aria::init();
|
|
||||||
ArClientBase client;
|
|
||||||
|
|
||||||
ArArgumentParser parser(&argc, argv);
|
|
||||||
ArClientSimpleConnector clientConnector(&parser);
|
|
||||||
parser.loadDefaultArguments();
|
|
||||||
if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
Aria::logOptions();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clientConnector.connectClient(&client))
|
|
||||||
{
|
|
||||||
if(client.wasRejected())
|
|
||||||
ArLog::log(ArLog::Terse, "Error, server '%s' rejected connection. Exiting.", client.getHost());
|
|
||||||
else
|
|
||||||
ArLog::log(ArLog::Terse, "Error, could not connect to server '%s'. Exiting.", client.getHost());
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
client.setRobotName(client.getHost()); // include server hostname in log messages
|
|
||||||
|
|
||||||
client.runAsync();
|
|
||||||
|
|
||||||
PtzCameraExample example(&client);
|
|
||||||
if(!example.init())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
example.run();
|
|
||||||
|
|
||||||
|
|
||||||
Aria::shutdown();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool PtzCameraExample::init()
|
|
||||||
{
|
|
||||||
// If the server has the "getCameraList" request, then it's using
|
|
||||||
// ArServerHandlerCameraCollection, and migth have multiple PTZs/cameras each with
|
|
||||||
// its own set of requests. So send a "getCameraList" request, and when its
|
|
||||||
// reply is received, the handler will send "getCameraInfo" requests for each.
|
|
||||||
// If the server does not have "getCameraList", it only has one PTZ camera, just
|
|
||||||
// send "getCameraInfo". The handler for that will send various control
|
|
||||||
// commands.
|
|
||||||
// If the server does not have "getCameraInfo", then it doesn't provide any
|
|
||||||
// access to PTZ cameras.
|
|
||||||
if(myClient->dataExists("getCameraList"))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "Server may have multiple cameras. Requesting list.");
|
|
||||||
myClient->addHandler("getCameraList", &myCameraListReplyFunc);
|
|
||||||
myClient->requestOnce("getCameraList");
|
|
||||||
}
|
|
||||||
else if(myClient->dataExists("getCameraInfo"))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "Server does not support multiple cameras. Requesting info for its camera.");
|
|
||||||
ArClientHandlerCamera *camClient = new ArClientHandlerCamera(myClient, "");
|
|
||||||
camClient->requestUpdates(100);
|
|
||||||
mutex.lock();
|
|
||||||
myCameras.insert(camClient);
|
|
||||||
mutex.unlock();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Terse, "Error, server does not have any camera control requests. (Was the server run with video features enabled or video forwarding active?)");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PtzCameraExample::handleCameraListReply(ArNetPacket *pkt)
|
|
||||||
{
|
|
||||||
ArTypes::Byte2 numCams = pkt->bufToByte2();
|
|
||||||
ArLog::log(ArLog::Normal, "%d cameras in list.", numCams);
|
|
||||||
char camName[128];
|
|
||||||
char camType[128];
|
|
||||||
char displayName[128];
|
|
||||||
char displayType[128];
|
|
||||||
char cmdDesc[128];
|
|
||||||
char cmdName[128];
|
|
||||||
ArTypes::Byte4 cmdFreq;
|
|
||||||
int dataReqFreq = 100;
|
|
||||||
for(ArTypes::Byte2 i = 0; i < numCams; ++i)
|
|
||||||
{
|
|
||||||
memset(camName, 0, 128);
|
|
||||||
memset(camType, 0, 128);
|
|
||||||
memset(displayName, 0, 128);
|
|
||||||
memset(displayType, 0, 128);
|
|
||||||
pkt->bufToStr(camName, 128); // name
|
|
||||||
|
|
||||||
ArClientHandlerCamera *cam = new ArClientHandlerCamera(myClient, camName);
|
|
||||||
|
|
||||||
pkt->bufToStr(camType, 128); // type
|
|
||||||
cam->type = camType;
|
|
||||||
pkt->bufToStr(displayName, 128); // description
|
|
||||||
cam->displayName = displayName;
|
|
||||||
pkt->bufToStr(displayType, 128); // description
|
|
||||||
cam->displayType = displayType;
|
|
||||||
ArTypes::Byte2 numCmds = pkt->bufToByte2();
|
|
||||||
ArLog::log(ArLog::Normal, "%d commands for camera \'%s\' (%s) / \'%s\' (%s)", numCmds, camName, camType, displayName, displayType);
|
|
||||||
for(ArTypes::Byte2 c = 0; c < numCmds; ++c)
|
|
||||||
{
|
|
||||||
memset(cmdDesc, 0, 128);
|
|
||||||
memset(cmdName, 0, 128);
|
|
||||||
char cmdDesc[128];
|
|
||||||
char cmdName[128];
|
|
||||||
pkt->bufToStr(cmdDesc, 128); // description
|
|
||||||
pkt->bufToStr(cmdName, 128); // request name
|
|
||||||
cmdFreq = pkt->bufToByte4(); // recommended request frequency
|
|
||||||
ArLog::log(ArLog::Normal, "Camera %s has %s command named %s with recommended request frequency %d.", camName, cmdDesc, cmdName, cmdFreq);
|
|
||||||
|
|
||||||
if(strcmp(cmdDesc, "getCameraData") == 0)
|
|
||||||
dataReqFreq = cmdFreq;
|
|
||||||
}
|
|
||||||
ArTypes::Byte2 numParams = pkt->bufToByte2();
|
|
||||||
ArLog::log(ArLog::Normal, "Camera %s has %d parameters.", camName, numParams);
|
|
||||||
for(ArTypes::Byte2 p = 0; p < numParams; ++p)
|
|
||||||
{
|
|
||||||
ArClientArg carg;
|
|
||||||
ArConfigArg arg;
|
|
||||||
if(!carg.bufToArgValue(pkt, arg))
|
|
||||||
ArLog::log(ArLog::Normal, "Hmm, error getting ArClientArg for camera %s's parameter #%d.", camName, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
cam->requestUpdates(dataReqFreq);
|
|
||||||
mutex.lock();
|
|
||||||
myCameras.insert(cam);
|
|
||||||
mutex.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArClientHandlerCamera::handleCameraInfoReply(ArNetPacket *pkt)
|
|
||||||
{
|
|
||||||
lock();
|
|
||||||
minPan = pkt->bufToByte2() / 1000.0;
|
|
||||||
maxPan = pkt->bufToByte2() / 1000.0;
|
|
||||||
minTilt = pkt->bufToByte2() / 1000.0;
|
|
||||||
maxTilt = pkt->bufToByte2() / 1000.0;
|
|
||||||
minZoom = pkt->bufToByte2() / 1000.0;
|
|
||||||
maxZoom = pkt->bufToByte2() / 1000.0;
|
|
||||||
haveZoom = pkt->bufToByte();
|
|
||||||
ArLog::log(ArLog::Normal, "Got getCameraInfo reply with pan range (%f, %f), tilt range (%f, %f), zoom range (%f, %f), zoom valid %d.", minPan, maxPan, minTilt, maxTilt, minZoom, maxZoom, haveZoom);
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArClientHandlerCamera::handleCameraDataReply(ArNetPacket *pkt)
|
|
||||||
{
|
|
||||||
lock();
|
|
||||||
pan = pkt->bufToByte2() / 1000.0;
|
|
||||||
tilt = pkt->bufToByte2() / 1000.0;
|
|
||||||
zoom = pkt->bufToByte2() /1000.0;
|
|
||||||
ArLog::log(ArLog::Normal, "Got camera data from camera %s with current pan=%f, tilt=%f, zoom=%f.", name.c_str(), pan, tilt, zoom);
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ArNetCameraRequest::requestPanTiltAbs(double pan, double tilt)
|
|
||||||
{
|
|
||||||
empty();
|
|
||||||
byte2ToBuf((ArTypes::Byte2)(pan * 1000.0));
|
|
||||||
byte2ToBuf((ArTypes::Byte2)(tilt * 1000.0));
|
|
||||||
finalizePacket();
|
|
||||||
return myClient->requestOnce(myAbsReqName.c_str(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ArNetCameraRequest::requestPanTiltZoomAbs(double pan, double tilt, double zoom)
|
|
||||||
{
|
|
||||||
empty();
|
|
||||||
byte2ToBuf((ArTypes::Byte2)(pan * 1000.0));
|
|
||||||
byte2ToBuf((ArTypes::Byte2)(tilt * 1000.0));
|
|
||||||
byte2ToBuf((ArTypes::Byte2)(zoom * 1000.0));
|
|
||||||
finalizePacket();
|
|
||||||
return myClient->requestOnce(myAbsReqName.c_str(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PtzCameraExample::run()
|
|
||||||
{
|
|
||||||
enum { MinPan, MaxPan, Center1, MinTilt, MaxTilt, Center2} stage;
|
|
||||||
stage = MinPan;
|
|
||||||
while(myClient->isConnected())
|
|
||||||
{
|
|
||||||
mutex.lock();
|
|
||||||
for(std::set<ArClientHandlerCamera*>::const_iterator i = myCameras.begin(); i != myCameras.end(); ++i)
|
|
||||||
{
|
|
||||||
ArClientHandlerCamera* c = (*i);
|
|
||||||
c->lock();
|
|
||||||
switch(stage)
|
|
||||||
{
|
|
||||||
case MinPan:
|
|
||||||
c->request.requestPanTiltAbs(c->minPan, 0);
|
|
||||||
stage = MaxPan;
|
|
||||||
break;
|
|
||||||
case MaxPan:
|
|
||||||
c->request.requestPanTiltAbs(c->maxPan, 0);
|
|
||||||
stage = Center1;
|
|
||||||
break;
|
|
||||||
case Center1:
|
|
||||||
c->request.requestPanTiltAbs(0, 0);
|
|
||||||
stage = MinTilt;
|
|
||||||
break;
|
|
||||||
case MinTilt:
|
|
||||||
c->request.requestPanTiltAbs(0, c->minTilt);
|
|
||||||
stage = MaxTilt;
|
|
||||||
break;
|
|
||||||
case MaxTilt:
|
|
||||||
c->request.requestPanTiltAbs(0, c->maxTilt);
|
|
||||||
stage = Center2;
|
|
||||||
break;
|
|
||||||
case Center2:
|
|
||||||
c->request.requestPanTiltAbs(0, 0);
|
|
||||||
stage = MinPan;
|
|
||||||
}
|
|
||||||
c->unlock();
|
|
||||||
}
|
|
||||||
mutex.unlock();
|
|
||||||
ArUtil::sleep(3000);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,180 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="7.10"
|
|
||||||
Name="serverDemo"
|
|
||||||
ProjectGUID="{7AEA7E4D-0984-4A16-8A3F-AF36B1A27836}"
|
|
||||||
SccProjectName=""
|
|
||||||
SccLocalPath="">
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"/>
|
|
||||||
</Platforms>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory=".\../../bin"
|
|
||||||
IntermediateDirectory="../../obj/$(ConfigurationName)-VC7"
|
|
||||||
ConfigurationType="1"
|
|
||||||
UseOfMFC="0"
|
|
||||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
|
||||||
StringPooling="FALSE"
|
|
||||||
BasicRuntimeChecks="0"
|
|
||||||
RuntimeLibrary="3"
|
|
||||||
BufferSecurityCheck="TRUE"
|
|
||||||
EnableFunctionLevelLinking="FALSE"
|
|
||||||
RuntimeTypeInfo="TRUE"
|
|
||||||
ProgramDataBaseFileName="$(IntDir)/$(TargetName)-VC7.pdb"
|
|
||||||
BrowseInformation="1"
|
|
||||||
WarningLevel="3"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
CompileAs="0"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaDebug.lib ArNetworkingDebug.lib $(NOINHERIT)"
|
|
||||||
Version="1.0"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
GenerateDebugInformation="TRUE"
|
|
||||||
ProgramDatabaseFile="$(IntDir)/$(ProjectName).pdb"
|
|
||||||
SubSystem="1"
|
|
||||||
TargetMachine="1"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
TypeLibraryName=".\../../bin/serverDemo.tlb"
|
|
||||||
HeaderFileName=""/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="_DEBUG"
|
|
||||||
Culture="1033"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"
|
|
||||||
RelativePath="binNet"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory=".\../../bin"
|
|
||||||
IntermediateDirectory="../../obj/$(ConfigurationName)-VC7"
|
|
||||||
ConfigurationType="1"
|
|
||||||
UseOfMFC="0"
|
|
||||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="2"
|
|
||||||
InlineFunctionExpansion="1"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
|
||||||
StringPooling="FALSE"
|
|
||||||
BasicRuntimeChecks="0"
|
|
||||||
RuntimeLibrary="2"
|
|
||||||
BufferSecurityCheck="FALSE"
|
|
||||||
EnableFunctionLevelLinking="FALSE"
|
|
||||||
RuntimeTypeInfo="TRUE"
|
|
||||||
ProgramDataBaseFileName="$(IntDir)/$(TargetName)-VC7.pdb"
|
|
||||||
WarningLevel="3"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
CompileAs="0"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="Aria.lib ArNetworking.lib advapi32.lib wsock32.lib winmm.lib"
|
|
||||||
Version="1.0"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
ProgramDatabaseFile="$(IntDir)/$(ProjectName).pdb"
|
|
||||||
SubSystem="1"
|
|
||||||
TargetMachine="1"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
TypeLibraryName=".\../../bin/serverDemo.tlb"
|
|
||||||
HeaderFileName=""/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="NDEBUG"
|
|
||||||
Culture="1033"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"
|
|
||||||
RelativePath="binNet"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="Source Files"
|
|
||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
|
||||||
<File
|
|
||||||
RelativePath="serverDemo.cpp">
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories=""
|
|
||||||
PreprocessorDefinitions=""
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
BrowseInformation="1"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="2"
|
|
||||||
AdditionalIncludeDirectories=""
|
|
||||||
PreprocessorDefinitions=""/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Header Files"
|
|
||||||
Filter="h;hpp;hxx;hm;inl">
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource Files"
|
|
||||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
@ -1,247 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="9.00"
|
|
||||||
Name="serverDemo"
|
|
||||||
ProjectGUID="{B9C37E51-E357-4019-B4B5-71C42E1FCD11}"
|
|
||||||
TargetFrameworkVersion="131072"
|
|
||||||
>
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"
|
|
||||||
/>
|
|
||||||
</Platforms>
|
|
||||||
<ToolFiles>
|
|
||||||
</ToolFiles>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory=".\../../bin"
|
|
||||||
IntermediateDirectory="../../obj/$(ConfigurationName)-VC9"
|
|
||||||
ConfigurationType="1"
|
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
|
||||||
UseOfMFC="0"
|
|
||||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
|
||||||
CharacterSet="2"
|
|
||||||
BuildLogFile="$(IntDir)\$(ProjectName)BuildLog.htm"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
TypeLibraryName=".\../../bin/serverDemo.tlb"
|
|
||||||
HeaderFileName=""
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
|
||||||
StringPooling="false"
|
|
||||||
BasicRuntimeChecks="0"
|
|
||||||
RuntimeLibrary="3"
|
|
||||||
BufferSecurityCheck="false"
|
|
||||||
EnableFunctionLevelLinking="false"
|
|
||||||
RuntimeTypeInfo="true"
|
|
||||||
BrowseInformation="1"
|
|
||||||
WarningLevel="3"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
CompileAs="0"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="_DEBUG"
|
|
||||||
Culture="1033"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaDebugVC9.lib ArNetworkingDebugVC9.lib $(NOINHERIT)"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName)DebugVC9.exe"
|
|
||||||
Version="1.0"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
SubSystem="1"
|
|
||||||
RandomizedBaseAddress="1"
|
|
||||||
DataExecutionPrevention="0"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory=".\../../bin"
|
|
||||||
IntermediateDirectory="../../obj/$(ConfigurationName)-VC9"
|
|
||||||
ConfigurationType="1"
|
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
|
||||||
UseOfMFC="0"
|
|
||||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
|
||||||
CharacterSet="2"
|
|
||||||
BuildLogFile="$(IntDir)\$(ProjectName)BuildLog.htm"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
TypeLibraryName=".\../../bin/serverDemo.tlb"
|
|
||||||
HeaderFileName=""
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="2"
|
|
||||||
InlineFunctionExpansion="1"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
|
||||||
StringPooling="false"
|
|
||||||
BasicRuntimeChecks="0"
|
|
||||||
RuntimeLibrary="2"
|
|
||||||
BufferSecurityCheck="false"
|
|
||||||
EnableFunctionLevelLinking="false"
|
|
||||||
RuntimeTypeInfo="true"
|
|
||||||
WarningLevel="3"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
CompileAs="0"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="NDEBUG"
|
|
||||||
Culture="1033"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaVC9.lib ArNetworkingVC9.lib $(NOINHERIT)"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName)VC9.exe"
|
|
||||||
Version="1.0"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
SubSystem="1"
|
|
||||||
RandomizedBaseAddress="1"
|
|
||||||
DataExecutionPrevention="0"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="Source Files"
|
|
||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath="serverDemo.cpp"
|
|
||||||
>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories=""
|
|
||||||
PreprocessorDefinitions=""
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
BrowseInformation="1"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="2"
|
|
||||||
AdditionalIncludeDirectories=""
|
|
||||||
PreprocessorDefinitions=""
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Header Files"
|
|
||||||
Filter="h;hpp;hxx;hm;inl"
|
|
||||||
>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource Files"
|
|
||||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
|
||||||
>
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
@ -1,152 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectName>serverDemo</ProjectName>
|
|
||||||
<ProjectGuid>{B9C37E51-E357-4019-B4B5-71C42E1FCD11}</ProjectGuid>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../bin/</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../obj/$(ProjectName)-$(Configuration)-VC10/</IntDir>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../bin/</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../obj/$(ProjectName)-$(Configuration)-VC10/</IntDir>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">serverDemoDebug</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)</TargetName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<BuildLog>
|
|
||||||
<Path>$(IntDir)$(ProjectName)BuildLog.htm</Path>
|
|
||||||
</BuildLog>
|
|
||||||
<Midl>
|
|
||||||
<TypeLibraryName>.\../../bin/serverDemo.tlb</TypeLibraryName>
|
|
||||||
<HeaderFileName>
|
|
||||||
</HeaderFileName>
|
|
||||||
</Midl>
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<AdditionalIncludeDirectories>..\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<StringPooling>false</StringPooling>
|
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
|
||||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<BrowseInformation>true</BrowseInformation>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<CompileAs>Default</CompileAs>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<Culture>0x0409</Culture>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>AriaDebugVC10.lib;ArNetworkingDebugVC10.lib</AdditionalDependencies>
|
|
||||||
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
|
|
||||||
<Version>1.0</Version>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
|
||||||
<DataExecutionPrevention>
|
|
||||||
</DataExecutionPrevention>
|
|
||||||
<TargetMachine>MachineX86</TargetMachine>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<BuildLog>
|
|
||||||
<Path>$(IntDir)$(ProjectName)BuildLog.htm</Path>
|
|
||||||
</BuildLog>
|
|
||||||
<Midl>
|
|
||||||
<TypeLibraryName>.\../../bin/serverDemo.tlb</TypeLibraryName>
|
|
||||||
<HeaderFileName>
|
|
||||||
</HeaderFileName>
|
|
||||||
</Midl>
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
|
||||||
<AdditionalIncludeDirectories>..\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<StringPooling>false</StringPooling>
|
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
|
||||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<CompileAs>Default</CompileAs>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<ResourceCompile>
|
|
||||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<Culture>0x0409</Culture>
|
|
||||||
</ResourceCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>AriaVC10.lib;ArNetworkingVC10.lib</AdditionalDependencies>
|
|
||||||
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
|
|
||||||
<Version>1.0</Version>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
|
||||||
<DataExecutionPrevention>
|
|
||||||
</DataExecutionPrevention>
|
|
||||||
<TargetMachine>MachineX86</TargetMachine>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="serverDemo.cpp">
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
|
||||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
|
||||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
|
||||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,257 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
/** @example serverDemo.cpp Example ArNetworking server providing teleoperation,
|
|
||||||
* sonar data, control the camera, etc.
|
|
||||||
*
|
|
||||||
* This is a basic ArNetworking server. It connects to a robot or simulator,
|
|
||||||
* including, if available, IRs, gyro, and bumpers. Give the option
|
|
||||||
* "-connectLaser" on the command line to enable the laser rangefinder,
|
|
||||||
* if available.
|
|
||||||
*
|
|
||||||
* Run "./serverDemo -help" for a full list of command line options.
|
|
||||||
*
|
|
||||||
* Once running, connect to this server with a a client such as
|
|
||||||
* MobileEyes.
|
|
||||||
*
|
|
||||||
* This server provides the following services:
|
|
||||||
* - User login (optional)
|
|
||||||
* - Basic robot telemetry information
|
|
||||||
* - Range sensor data values (not used by MobileEyes)
|
|
||||||
* - Graphics representing range sensor reading positions
|
|
||||||
* - Teleoperation modes (including safe/unsafe drive modes)
|
|
||||||
* - Wander mode
|
|
||||||
* - Various advanced "custom" commands to control logging, debugging, etc.
|
|
||||||
* - If an ACTS or SAV server is running, forward the video stream
|
|
||||||
* - Camera control (pan/tilt/zoom) if cameras are available
|
|
||||||
*
|
|
||||||
* Note that this program requires a terminal to run -- i.e. you can't run
|
|
||||||
* it in the background in Linux. To modify it to allow that, remove the key
|
|
||||||
* handler code in main().
|
|
||||||
*/
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
// mandatory init
|
|
||||||
Aria::init();
|
|
||||||
|
|
||||||
//ArLog::init(ArLog::StdOut, ArLog::Verbose);
|
|
||||||
|
|
||||||
// set up our parser
|
|
||||||
ArArgumentParser parser(&argc, argv);
|
|
||||||
|
|
||||||
// load the default arguments
|
|
||||||
parser.loadDefaultArguments();
|
|
||||||
|
|
||||||
// robot
|
|
||||||
ArRobot robot;
|
|
||||||
// set up our simple connector
|
|
||||||
ArRobotConnector robotConnector(&parser, &robot);
|
|
||||||
|
|
||||||
|
|
||||||
// add a gyro, it'll see if it should attach to the robot or not
|
|
||||||
ArAnalogGyro gyro(&robot);
|
|
||||||
|
|
||||||
|
|
||||||
// set up the robot for connecting
|
|
||||||
if (!robotConnector.connectRobot())
|
|
||||||
{
|
|
||||||
printf("Could not connect to robot... exiting\n");
|
|
||||||
Aria::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArDataLogger dataLogger(&robot, "dataLog.txt");
|
|
||||||
dataLogger.addToConfig(Aria::getConfig());
|
|
||||||
|
|
||||||
// our base server object
|
|
||||||
ArServerBase server;
|
|
||||||
|
|
||||||
ArLaserConnector laserConnector(&parser, &robot, &robotConnector);
|
|
||||||
ArServerSimpleOpener simpleOpener(&parser);
|
|
||||||
|
|
||||||
|
|
||||||
ArClientSwitchManager clientSwitchManager(&server, &parser);
|
|
||||||
|
|
||||||
// parse the command line... fail and print the help if the parsing fails
|
|
||||||
// or if the help was requested
|
|
||||||
if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
Aria::logOptions();
|
|
||||||
Aria::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up where we'll look for files such as user/password
|
|
||||||
char fileDir[1024];
|
|
||||||
ArUtil::addDirectories(fileDir, sizeof(fileDir), Aria::getDirectory(),
|
|
||||||
"ArNetworking/examples");
|
|
||||||
|
|
||||||
// first open the server up
|
|
||||||
if (!simpleOpener.open(&server, fileDir, 240))
|
|
||||||
{
|
|
||||||
if (simpleOpener.wasUserFileBad())
|
|
||||||
printf("Bad user/password/permissions file\n");
|
|
||||||
else
|
|
||||||
printf("Could not open server port\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Range devices:
|
|
||||||
|
|
||||||
|
|
||||||
ArSonarDevice sonarDev;
|
|
||||||
robot.addRangeDevice(&sonarDev);
|
|
||||||
|
|
||||||
ArIRs irs;
|
|
||||||
robot.addRangeDevice(&irs);
|
|
||||||
|
|
||||||
ArBumpers bumpers;
|
|
||||||
robot.addRangeDevice(&bumpers);
|
|
||||||
|
|
||||||
// attach services to the server
|
|
||||||
ArServerInfoRobot serverInfoRobot(&server, &robot);
|
|
||||||
ArServerInfoSensor serverInfoSensor(&server, &robot);
|
|
||||||
ArServerInfoDrawings drawings(&server);
|
|
||||||
|
|
||||||
// modes for controlling robot movement
|
|
||||||
ArServerModeStop modeStop(&server, &robot);
|
|
||||||
ArServerModeRatioDrive modeRatioDrive(&server, &robot);
|
|
||||||
ArServerModeWander modeWander(&server, &robot);
|
|
||||||
modeStop.addAsDefaultMode();
|
|
||||||
modeStop.activate();
|
|
||||||
|
|
||||||
// set up the simple commands
|
|
||||||
ArServerHandlerCommands commands(&server);
|
|
||||||
ArServerSimpleComUC uCCommands(&commands, &robot); // send commands directly to microcontroller
|
|
||||||
ArServerSimpleComMovementLogging loggingCommands(&commands, &robot); // control debug logging
|
|
||||||
ArServerSimpleComGyro gyroCommands(&commands, &robot, &gyro); // configure gyro
|
|
||||||
ArServerSimpleComLogRobotConfig configCommands(&commands, &robot); // control more debug logging
|
|
||||||
ArServerSimpleServerCommands serverCommands(&commands, &server); // control ArNetworking debug logging
|
|
||||||
ArServerSimpleLogRobotDebugPackets logRobotDebugPackets(&commands, &robot, "."); // debugging tool
|
|
||||||
|
|
||||||
// ArServerModeDrive is an older drive mode. ArServerModeRatioDrive is newer and generally performs better,
|
|
||||||
// but you can use this for old clients if neccesary.
|
|
||||||
//ArServerModeDrive modeDrive(&server, &robot);
|
|
||||||
//modeDrive.addControlCommands(&commands); // configure the drive modes (e.g. enable/disable safe drive)
|
|
||||||
|
|
||||||
ArServerHandlerConfig serverHandlerConfig(&server, Aria::getConfig()); // make a config handler
|
|
||||||
ArLog::addToConfig(Aria::getConfig()); // let people configure logging
|
|
||||||
|
|
||||||
modeRatioDrive.addToConfig(Aria::getConfig(), "Teleop settings"); // able to configure teleop settings
|
|
||||||
modeRatioDrive.addControlCommands(&commands);
|
|
||||||
|
|
||||||
// Forward video if either ACTS or SAV server are running.
|
|
||||||
// You can find out more about SAV and ACTS on our website
|
|
||||||
// http://robots.activmedia.com. ACTS is for color tracking and is
|
|
||||||
// a separate product. SAV just does software A/V transmitting and is
|
|
||||||
// free to all our customers. Just run ACTS or SAV server before you
|
|
||||||
// start this program and this class here will forward video from the
|
|
||||||
// server to the client.
|
|
||||||
ArHybridForwarderVideo videoForwarder(&server, "localhost", 7070);
|
|
||||||
|
|
||||||
// Control a pan/tilt/zoom camera, if one is installed, and the video
|
|
||||||
// forwarder was enabled above.
|
|
||||||
ArPTZ *camera = NULL;
|
|
||||||
ArServerHandlerCamera *handlerCamera = NULL;
|
|
||||||
ArCameraCollection *cameraCollection = NULL;
|
|
||||||
if (videoForwarder.isForwardingVideo())
|
|
||||||
{
|
|
||||||
bool invertedCamera = false;
|
|
||||||
camera = new ArVCC4(&robot, invertedCamera,
|
|
||||||
ArVCC4::COMM_UNKNOWN, true, true);
|
|
||||||
camera->init();
|
|
||||||
|
|
||||||
cameraCollection = new ArCameraCollection();
|
|
||||||
cameraCollection->addCamera("Cam1", "VCC4", "Camera", "VCC4");
|
|
||||||
handlerCamera = new ArServerHandlerCamera("Cam1",
|
|
||||||
&server,
|
|
||||||
&robot,
|
|
||||||
camera,
|
|
||||||
cameraCollection);
|
|
||||||
}
|
|
||||||
|
|
||||||
// You can use this class to send a set of arbitrary strings
|
|
||||||
// for MobileEyes to display, this is just a small example
|
|
||||||
ArServerInfoStrings stringInfo(&server);
|
|
||||||
Aria::getInfoGroup()->addAddStringCallback(stringInfo.getAddStringFunctor());
|
|
||||||
Aria::getInfoGroup()->addStringInt(
|
|
||||||
"Motor Packet Count", 10,
|
|
||||||
new ArConstRetFunctorC<int, ArRobot>(&robot,
|
|
||||||
&ArRobot::getMotorPacCount));
|
|
||||||
/*
|
|
||||||
Aria::getInfoGroup()->addStringInt(
|
|
||||||
"Laser Packet Count", 10,
|
|
||||||
new ArRetFunctorC<int, ArSick>(&sick,
|
|
||||||
&ArSick::getSickPacCount));
|
|
||||||
*/
|
|
||||||
|
|
||||||
// start the robot running, true means that if we lose connection the run thread stops
|
|
||||||
robot.runAsync(true);
|
|
||||||
|
|
||||||
|
|
||||||
// connect the laser(s) if it was requested
|
|
||||||
if (!laserConnector.connectLasers())
|
|
||||||
{
|
|
||||||
printf("Could not connect to lasers... exiting\n");
|
|
||||||
Aria::exit(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
drawings.addRobotsRangeDevices(&robot);
|
|
||||||
|
|
||||||
// log whatever we wanted to before the runAsync
|
|
||||||
simpleOpener.checkAndLog();
|
|
||||||
// now let it spin off in its own thread
|
|
||||||
server.runAsync();
|
|
||||||
|
|
||||||
printf("Server is now running...\n");
|
|
||||||
|
|
||||||
// Add a key handler so that you can exit by pressing
|
|
||||||
// escape. Note that a key handler prevents you from running
|
|
||||||
// a program in the background on Linux, since it expects an
|
|
||||||
// active terminal to read keys from; remove this if you want
|
|
||||||
// to run it in the background.
|
|
||||||
ArKeyHandler *keyHandler;
|
|
||||||
if ((keyHandler = Aria::getKeyHandler()) == NULL)
|
|
||||||
{
|
|
||||||
keyHandler = new ArKeyHandler;
|
|
||||||
Aria::setKeyHandler(keyHandler);
|
|
||||||
robot.lock();
|
|
||||||
robot.attachKeyHandler(keyHandler);
|
|
||||||
robot.unlock();
|
|
||||||
printf("To exit, press escape.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read in parameter files.
|
|
||||||
std::string configFile = "serverDemoConfig.txt";
|
|
||||||
Aria::getConfig()->setBaseDirectory("./");
|
|
||||||
if (Aria::getConfig()->parseFile(configFile.c_str(), true, true))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "Loaded config file %s", configFile.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ArUtil::findFile(configFile.c_str()))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"Trouble loading configuration file %s, continuing",
|
|
||||||
configFile.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"No configuration file %s, will try to create if config used",
|
|
||||||
configFile.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clientSwitchManager.runAsync();
|
|
||||||
|
|
||||||
robot.lock();
|
|
||||||
robot.enableMotors();
|
|
||||||
robot.unlock();
|
|
||||||
|
|
||||||
robot.waitForRunExit();
|
|
||||||
Aria::exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
; You'll want to change the . below to the actual password you want
|
|
||||||
; used for the different accounts, also note you can start up serverDemo
|
|
||||||
; with this information by giving it the '-userInfo <userInfoFile>'
|
|
||||||
; argument on the command line
|
|
||||||
UserInfoVersion1
|
|
||||||
user user . CustomCommands Movement RobotInfo SensorInfo Stop UnsafeMovement
|
|
||||||
user guest . CustomCommands Movement RobotInfo SensorInfo Stop UnsafeMovement
|
|
||||||
user administrator . all
|
|
@ -1,138 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="7.10"
|
|
||||||
Name="serverDemoStatic"
|
|
||||||
ProjectGUID="{31A8793E-E70A-4C52-B470-971BAF9DE5E0}"
|
|
||||||
RootNamespace="serverDemoStatic"
|
|
||||||
Keyword="ManagedCProj">
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"/>
|
|
||||||
</Platforms>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="..\..\bin"
|
|
||||||
IntermediateDirectory="..\obj\$(ConfigurationName)-Static-VC7"
|
|
||||||
ConfigurationType="1"
|
|
||||||
CharacterSet="2"
|
|
||||||
ManagedExtensions="FALSE">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;ARIA_STATIC"
|
|
||||||
MinimalRebuild="FALSE"
|
|
||||||
BasicRuntimeChecks="0"
|
|
||||||
RuntimeLibrary="1"
|
|
||||||
BufferSecurityCheck="FALSE"
|
|
||||||
RuntimeTypeInfo="TRUE"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
ProgramDataBaseFileName="$(IntDir)/$(TargetName)-VC7.pdb"
|
|
||||||
WarningLevel="3"
|
|
||||||
DebugInformationFormat="3"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaStaticDebug.lib ArNetworkingStaticDebug.lib winmm.lib ws2_32.lib advapi32.lib"
|
|
||||||
OutputFile="$(OutDir)\serverDemoStaticDebug.exe"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
IgnoreDefaultLibraryNames=""
|
|
||||||
GenerateDebugInformation="TRUE"
|
|
||||||
AssemblyDebug="1"
|
|
||||||
ProgramDatabaseFile="$(IntDir)/$(ProjectName).pdb"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="..\..\bin"
|
|
||||||
IntermediateDirectory="..\obj\$(ConfigurationName)-Static-VC7"
|
|
||||||
ConfigurationType="1"
|
|
||||||
CharacterSet="2"
|
|
||||||
ManagedExtensions="FALSE">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories="..\include,..\..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;ARIA_STATIC"
|
|
||||||
MinimalRebuild="FALSE"
|
|
||||||
RuntimeLibrary="0"
|
|
||||||
BufferSecurityCheck="FALSE"
|
|
||||||
RuntimeTypeInfo="TRUE"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
ProgramDataBaseFileName="$(IntDir)/$(TargetName)-VC7.pdb"
|
|
||||||
WarningLevel="3"
|
|
||||||
DebugInformationFormat="0"
|
|
||||||
CompileAs="2"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaStatic.lib ArNetworkingStatic.lib winmm.lib ws2_32.lib advapi32.lib"
|
|
||||||
OutputFile="$(OutDir)\serverDemoStatic.exe"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
IgnoreDefaultLibraryNames=""
|
|
||||||
GenerateDebugInformation="FALSE"
|
|
||||||
ProgramDatabaseFile="$(IntDir)/$(ProjectName).pdb"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="mscorlib.dll"/>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="System.dll"/>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="System.Data.dll"/>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<File
|
|
||||||
RelativePath="..\examples\serverDemo.cpp">
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
@ -1,213 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="9.00"
|
|
||||||
Name="serverDemoStatic"
|
|
||||||
ProjectGUID="{EEF9FE4C-34C4-4C76-94C4-D11930C88DE1}"
|
|
||||||
RootNamespace="serverDemoStatic"
|
|
||||||
Keyword="ManagedCProj"
|
|
||||||
TargetFrameworkVersion="131072"
|
|
||||||
>
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"
|
|
||||||
/>
|
|
||||||
</Platforms>
|
|
||||||
<ToolFiles>
|
|
||||||
</ToolFiles>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="..\..\bin"
|
|
||||||
IntermediateDirectory="..\..\obj\$(ConfigurationName)-VC9-Static"
|
|
||||||
ConfigurationType="1"
|
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
|
||||||
CharacterSet="2"
|
|
||||||
ManagedExtensions="0"
|
|
||||||
BuildLogFile="$(IntDir)\$(ProjectName)BuildLog.htm"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="..\..\include;..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;ARIA_STATIC"
|
|
||||||
MinimalRebuild="false"
|
|
||||||
BasicRuntimeChecks="0"
|
|
||||||
RuntimeLibrary="1"
|
|
||||||
BufferSecurityCheck="false"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
LinkLibraryDependencies="false"
|
|
||||||
AdditionalDependencies="AriaStaticDebugVC9.lib ws2_32.lib winmm.lib advapi32.lib ArNetworkingStaticDebugVC9.lib $(NOINHERIT)"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName)Debug.exe"
|
|
||||||
LinkIncremental="2"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
IgnoreDefaultLibraryNames=""
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
AssemblyDebug="1"
|
|
||||||
RandomizedBaseAddress="1"
|
|
||||||
DataExecutionPrevention="0"
|
|
||||||
TargetMachine="0"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="..\..\bin"
|
|
||||||
IntermediateDirectory="..\..\obj\$(ConfigurationName)-VC9-Static"
|
|
||||||
ConfigurationType="1"
|
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
|
||||||
CharacterSet="2"
|
|
||||||
ManagedExtensions="0"
|
|
||||||
BuildLogFile="$(IntDir)\$(ProjectName)BuildLog.htm"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
InlineFunctionExpansion="2"
|
|
||||||
EnableIntrinsicFunctions="true"
|
|
||||||
AdditionalIncludeDirectories="..\..\include;..\include"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;ARIA_STATIC"
|
|
||||||
MinimalRebuild="false"
|
|
||||||
RuntimeLibrary="0"
|
|
||||||
BufferSecurityCheck="false"
|
|
||||||
RuntimeTypeInfo="true"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="AriaStaticVC9.lib ArNetworkingStaticVC9.lib winmm.lib ws2_32.lib"
|
|
||||||
OutputFile="$(OutDir)\$(ProjectName)VC9.exe"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="true"
|
|
||||||
AdditionalLibraryDirectories="..\..\lib"
|
|
||||||
IgnoreDefaultLibraryNames=""
|
|
||||||
GenerateDebugInformation="false"
|
|
||||||
RandomizedBaseAddress="1"
|
|
||||||
DataExecutionPrevention="0"
|
|
||||||
ImportLibrary=""
|
|
||||||
TargetMachine="0"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="mscorlib.dll"
|
|
||||||
AssemblyName="mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=IA64"
|
|
||||||
MinFrameworkVersion="131072"
|
|
||||||
/>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="System.dll"
|
|
||||||
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
|
|
||||||
MinFrameworkVersion="131072"
|
|
||||||
/>
|
|
||||||
<AssemblyReference
|
|
||||||
RelativePath="System.Data.dll"
|
|
||||||
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
|
|
||||||
MinFrameworkVersion="131072"
|
|
||||||
/>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<File
|
|
||||||
RelativePath=".\serverDemo.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
@ -1,143 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectName>serverDemoStatic</ProjectName>
|
|
||||||
<ProjectGuid>{EEF9FE4C-34C4-4C76-94C4-D11930C88DE1}</ProjectGuid>
|
|
||||||
<RootNamespace>serverDemoStatic</RootNamespace>
|
|
||||||
<Keyword>ManagedCProj</Keyword>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<CLRSupport>false</CLRSupport>
|
|
||||||
<PlatformToolset>v100</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<CLRSupport>false</CLRSupport>
|
|
||||||
<PlatformToolset>v100</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\bin\</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../obj/$(ProjectName)-$(Configuration)-VC10/</IntDir>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
|
||||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\bin\</OutDir>
|
|
||||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../obj/$(ProjectName)-$(Configuration)-VC10/</IntDir>
|
|
||||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">serverDemoStaticDebug</TargetName>
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)</TargetName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<BuildLog>
|
|
||||||
<Path>$(IntDir)$(ProjectName)BuildLog.htm</Path>
|
|
||||||
</BuildLog>
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<AdditionalIncludeDirectories>..\..\include;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;ARIA_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>AriaStaticDebugVC10.lib;ws2_32.lib;winmm.lib;advapi32.lib;ArNetworkingStaticDebugVC10.lib</AdditionalDependencies>
|
|
||||||
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AssemblyDebug>true</AssemblyDebug>
|
|
||||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
|
||||||
<DataExecutionPrevention>
|
|
||||||
</DataExecutionPrevention>
|
|
||||||
<TargetMachine>NotSet</TargetMachine>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<BuildLog>
|
|
||||||
<Path>$(IntDir)$(ProjectName)BuildLog.htm</Path>
|
|
||||||
</BuildLog>
|
|
||||||
<ClCompile>
|
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<AdditionalIncludeDirectories>..\..\include;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;ARIA_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
|
||||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
|
||||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<AdditionalDependencies>AriaStaticVC10.lib;ArNetworkingStaticVC10.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
|
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
||||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
|
||||||
<DataExecutionPrevention>
|
|
||||||
</DataExecutionPrevention>
|
|
||||||
<ImportLibrary>
|
|
||||||
</ImportLibrary>
|
|
||||||
<TargetMachine>NotSet</TargetMachine>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="mscorlib">
|
|
||||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
|
||||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System">
|
|
||||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
|
||||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Data">
|
|
||||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
|
||||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="serverDemo.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,129 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
|
|
||||||
/** @example simpleServerExample.cpp This is a simple example of an ArNetworking server.
|
|
||||||
* This server provides range sensor data to the client, and teleoperation
|
|
||||||
* controls. It also includes an example of a custom command (using
|
|
||||||
* ArServerHandlerCommands).
|
|
||||||
*
|
|
||||||
* For a more complete server, see serverDemo.cpp.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* This function is called ArServerHandlerCommands when our custom command is
|
|
||||||
* recieved. */
|
|
||||||
void customCommandHandler(ArArgumentBuilder *args)
|
|
||||||
{
|
|
||||||
if(args && args->getArg(0))
|
|
||||||
ArLog::log(ArLog::Normal, "Recieved custom command with argument \"%s\".", args->getArg(0));
|
|
||||||
else
|
|
||||||
ArLog::log(ArLog::Normal, "Recieved custom command with no arguments.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
Aria::init();
|
|
||||||
ArRobot robot;
|
|
||||||
ArArgumentParser parser(&argc, argv);
|
|
||||||
ArSimpleConnector simpleConnector(&parser);
|
|
||||||
|
|
||||||
// The base server object, manages all connections to clients.
|
|
||||||
ArServerBase server;
|
|
||||||
|
|
||||||
// This object simplifies configuration and opening of the ArServerBase
|
|
||||||
// object.
|
|
||||||
ArServerSimpleOpener simpleOpener(&parser);
|
|
||||||
|
|
||||||
// parse the command line. fail and print the help if the parsing fails
|
|
||||||
// or if the help was requested with -help
|
|
||||||
parser.loadDefaultArguments();
|
|
||||||
if (!simpleConnector.parseArgs() || !simpleOpener.parseArgs() ||
|
|
||||||
!parser.checkHelpAndWarnUnparsed())
|
|
||||||
{
|
|
||||||
simpleConnector.logOptions();
|
|
||||||
simpleOpener.logOptions();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use the ArSimpleOpener to open the server port
|
|
||||||
if (!simpleOpener.open(&server))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Terse, "Error: Could not open server on port %d", simpleOpener.getPort());
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Create services attached to the base server:
|
|
||||||
//
|
|
||||||
|
|
||||||
// Robot position etc.:
|
|
||||||
ArServerInfoRobot serverInfoRobot(&server, &robot);
|
|
||||||
|
|
||||||
// Robot control modes (only one mode can be active at once):
|
|
||||||
ArServerModeStop modeStop(&server, &robot);
|
|
||||||
// old ArServerModeDrive modeDrive(&server, &robot);
|
|
||||||
ArServerModeRatioDrive modeRatioDrive(&server, &robot);
|
|
||||||
ArServerModeWander modeWander(&server, &robot);
|
|
||||||
modeStop.addAsDefaultMode();
|
|
||||||
modeStop.activate();
|
|
||||||
|
|
||||||
// This provides a simple way to add new commands.
|
|
||||||
ArServerHandlerCommands commands(&server);
|
|
||||||
|
|
||||||
// Add our custom command. ArServerHandlerCommands also has other methods
|
|
||||||
// for adding commands taht take different kinds of arguments, or no
|
|
||||||
// arguments.
|
|
||||||
ArGlobalFunctor1<ArArgumentBuilder*> customCommandFunctor(&customCommandHandler);
|
|
||||||
commands.addStringCommand("ExampleCustomCommand", "Example of a custom command. simpleServerExample will print out the text sent with the command.", &customCommandFunctor);
|
|
||||||
|
|
||||||
// These objects provide various debugging and diagnostic custom commands:
|
|
||||||
ArServerSimpleComUC uCCommands(&commands, &robot); // Get information about the robot
|
|
||||||
ArServerSimpleComMovementLogging loggingCommands(&commands, &robot); // Control logging
|
|
||||||
modeRatioDrive.addControlCommands(&commands); // Drive mode diagnostics
|
|
||||||
|
|
||||||
// This provides the client (e.g. MobileEyes) with a simple table of string values
|
|
||||||
// (called an InfoGroup). An InfoGroup is kept globally by Aria.
|
|
||||||
// The values in the table sent to clients are retrieved periodically by calling a
|
|
||||||
// functor.
|
|
||||||
ArServerInfoStrings stringInfo(&server);
|
|
||||||
Aria::getInfoGroup()->addAddStringCallback(stringInfo.getAddStringFunctor());
|
|
||||||
|
|
||||||
// Here are some example entries in the InfoGroup:
|
|
||||||
Aria::getInfoGroup()->addStringInt(
|
|
||||||
"Motor Packet Count", 10,
|
|
||||||
new ArConstRetFunctorC<int, ArRobot>(&robot,
|
|
||||||
&ArRobot::getMotorPacCount));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Connect to the robot:
|
|
||||||
//
|
|
||||||
|
|
||||||
if (!simpleConnector.connectRobot(&robot))
|
|
||||||
{
|
|
||||||
printf("Error: Could not connect to robot... exiting\n");
|
|
||||||
Aria::shutdown();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
robot.enableMotors();
|
|
||||||
robot.runAsync(true);
|
|
||||||
|
|
||||||
// The simple opener might have information to display right before starting
|
|
||||||
// the server thread:
|
|
||||||
simpleOpener.checkAndLog();
|
|
||||||
|
|
||||||
// now let the server base run in a new thread, accepting client connections.
|
|
||||||
server.runAsync();
|
|
||||||
|
|
||||||
ArLog::log(ArLog::Normal, "Server is now running... Press Ctrl-C to exit.");
|
|
||||||
|
|
||||||
robot.waitForRunExit();
|
|
||||||
Aria::shutdown();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,168 +0,0 @@
|
|||||||
#ifndef ARCENTRALFORWARDER_H
|
|
||||||
#define ARCENTRALFORWARDER_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
#include "ArClientBase.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
Class for forwarding... You sould use the commands on this instead
|
|
||||||
of the ones on the server and client it holds.
|
|
||||||
|
|
||||||
requestStop is missing since that'd only cause problems.
|
|
||||||
|
|
||||||
request doesn't take a packet since that'd cause problems with the
|
|
||||||
proxying, other than that everything should be like the client.
|
|
||||||
|
|
||||||
Talk to MattL if there's questions.
|
|
||||||
**/
|
|
||||||
class ArCentralForwarder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AREXPORT ArCentralForwarder(
|
|
||||||
ArServerBase *mainServer, ArSocket *socket,
|
|
||||||
const char *robotName, int startingPort,
|
|
||||||
std::map<int, ArTime *> *usedPorts,
|
|
||||||
ArFunctor2<ArCentralForwarder *,
|
|
||||||
ArServerClient *> *notifyServerClientRemovedCB,
|
|
||||||
const char *enforceProtocolVersion,
|
|
||||||
ArServerCommands::Type enforceType
|
|
||||||
);
|
|
||||||
AREXPORT ~ArCentralForwarder();
|
|
||||||
|
|
||||||
/// Gets the robot name
|
|
||||||
const char *getRobotName(void) { return myRobotName.c_str(); }
|
|
||||||
|
|
||||||
/// Adds a functor for some particular data
|
|
||||||
AREXPORT bool addHandler(const char *name,
|
|
||||||
ArFunctor1 <ArNetPacket *> *functor);
|
|
||||||
|
|
||||||
/// Removes a functor for some particular data by name
|
|
||||||
AREXPORT bool remHandler(const char *name, ArFunctor1<ArNetPacket *> *functor);
|
|
||||||
|
|
||||||
/// Request some data every @a mSec milliseconds
|
|
||||||
AREXPORT bool request(const char *name, long mSec);
|
|
||||||
|
|
||||||
/// Request some data (or send a command) just once
|
|
||||||
AREXPORT bool requestOnce(const char *name,
|
|
||||||
ArNetPacket *packet = NULL,
|
|
||||||
bool quiet = false);
|
|
||||||
|
|
||||||
/// Request some data (or send a command) just once by UDP
|
|
||||||
AREXPORT bool requestOnceUdp(const char *name,
|
|
||||||
ArNetPacket *packet = NULL,
|
|
||||||
bool quiet = false);
|
|
||||||
|
|
||||||
/// Request some data (or send a command) just once with a string as argument
|
|
||||||
AREXPORT bool requestOnceWithString(const char *name, const char *str);
|
|
||||||
|
|
||||||
/// Sees if this data exists
|
|
||||||
AREXPORT bool dataExists(const char *name);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Gets the server (shouldn't need to be used by anyone)
|
|
||||||
ArServerBase *getServer(void) { return myServer; }
|
|
||||||
/// Gets the client (shouldn't need to be used by anyone)
|
|
||||||
ArClientBase *getClient(void) { return myClient; }
|
|
||||||
/// Gets the port (shouldn't need to be used by anyone)
|
|
||||||
int getPort(void) { return myPort; }
|
|
||||||
AREXPORT bool callOnce(
|
|
||||||
double heartbeatTimeout, double udpHeartbeatTimeout,
|
|
||||||
double robotBackupTimeout, double clientBackupTimeout);
|
|
||||||
AREXPORT bool isConnected(void) { return myState == STATE_CONNECTED; }
|
|
||||||
AREXPORT void willReplace(void) { myBeingReplaced = true; }
|
|
||||||
protected:
|
|
||||||
AREXPORT void netCentralHeartbeat(ArNetPacket *packet);
|
|
||||||
|
|
||||||
void robotServerClientRemoved(ArServerClient *client);
|
|
||||||
void clientServerClientRemoved(ArServerClient *client);
|
|
||||||
void receiveData(ArNetPacket *packet);
|
|
||||||
void internalRequestChanged(long interval, unsigned int command);
|
|
||||||
bool internalRequestOnce(ArServerClient *client, ArNetPacket *packet,
|
|
||||||
bool tcp);
|
|
||||||
|
|
||||||
AREXPORT bool startingCallOnce(
|
|
||||||
double heartbeatTimeout, double udpHeartbeatTimeout,
|
|
||||||
double robotBackupTimeout, double clientBackupTimeout);
|
|
||||||
AREXPORT bool connectingCallOnce(
|
|
||||||
double heartbeatTimeout, double udpHeartbeatTimeout,
|
|
||||||
double robotBackupTimeout, double clientBackupTimeout);
|
|
||||||
AREXPORT bool gatheringCallOnce(
|
|
||||||
double heartbeatTimeout, double udpHeartbeatTimeout,
|
|
||||||
double robotBackupTimeout, double clientBackupTimeout);
|
|
||||||
AREXPORT bool connectedCallOnce(
|
|
||||||
double heartbeatTimeout, double udpHeartbeatTimeout,
|
|
||||||
double robotBackupTimeout, double clientBackupTimeout);
|
|
||||||
|
|
||||||
std::string myEnforceProtocolVersion;
|
|
||||||
ArServerCommands::Type myEnforceType;
|
|
||||||
|
|
||||||
ArServerBase *myMainServer;
|
|
||||||
ArSocket *mySocket;
|
|
||||||
std::string myRobotName;
|
|
||||||
std::string myPrefix;
|
|
||||||
int myStartingPort;
|
|
||||||
std::map<int, ArTime *> *myUsedPorts;
|
|
||||||
ArFunctor2<ArCentralForwarder *,
|
|
||||||
ArServerClient *> *myForwarderServerClientRemovedCB;
|
|
||||||
|
|
||||||
enum State
|
|
||||||
{
|
|
||||||
STATE_STARTING,
|
|
||||||
STATE_CONNECTING,
|
|
||||||
STATE_GATHERING,
|
|
||||||
STATE_CONNECTED
|
|
||||||
};
|
|
||||||
bool myBeingReplaced;
|
|
||||||
|
|
||||||
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArClientBase *myClient;
|
|
||||||
State myState;
|
|
||||||
int myPort;
|
|
||||||
ArServerBase *server;
|
|
||||||
ArClientBase *client;
|
|
||||||
|
|
||||||
bool myRobotHasCentralServerHeartbeat;
|
|
||||||
ArTime myLastSentCentralServerHeartbeat;
|
|
||||||
|
|
||||||
enum ReturnType
|
|
||||||
{
|
|
||||||
RETURN_NONE,
|
|
||||||
RETURN_SINGLE,
|
|
||||||
RETURN_VIDEO,
|
|
||||||
RETURN_UNTIL_EMPTY,
|
|
||||||
RETURN_COMPLEX,
|
|
||||||
RETURN_VIDEO_OPTIM,
|
|
||||||
};
|
|
||||||
|
|
||||||
std::map<unsigned int, ReturnType> myReturnTypes;
|
|
||||||
std::map<unsigned int, std::list<ArServerClient *> *> myRequestOnces;
|
|
||||||
std::map<unsigned int, ArTime *> myLastRequest;
|
|
||||||
std::map<unsigned int, ArTime *> myLastBroadcast;
|
|
||||||
|
|
||||||
ReturnType getReturnType(int command);
|
|
||||||
void checkRequestOnces(unsigned int command);
|
|
||||||
void setLastRequest(unsigned int command);
|
|
||||||
void setLastBroadcast(unsigned int command);
|
|
||||||
|
|
||||||
ArTime myLastTcpHeartbeat;
|
|
||||||
ArTime myLastUdpHeartbeat;
|
|
||||||
|
|
||||||
ArFunctor1C<ArCentralForwarder, ArNetPacket *> myReceiveDataFunctor;
|
|
||||||
ArFunctor2C<ArCentralForwarder,
|
|
||||||
long, unsigned int> myInternalRequestChangedFunctor;
|
|
||||||
ArRetFunctor3C<bool, ArCentralForwarder, ArServerClient *,
|
|
||||||
ArNetPacket *, bool> myInternalRequestOnceFunctor;
|
|
||||||
ArFunctor1C<ArCentralForwarder,
|
|
||||||
ArServerClient *> myRobotServerClientRemovedCB;
|
|
||||||
ArFunctor1C<ArCentralForwarder,
|
|
||||||
ArNetPacket *> myNetCentralHeartbeatCB;
|
|
||||||
ArFunctor1C<ArCentralForwarder,
|
|
||||||
ArServerClient *> myClientServerClientRemovedCB;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ARSERVERSWITCHFORWARDER
|
|
@ -1,88 +0,0 @@
|
|||||||
#ifndef ARCENTRALMANAGER
|
|
||||||
#define ARCENTRALMANAGER
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
#include "ArCentralForwarder.h"
|
|
||||||
|
|
||||||
class ArCentralManager : public ArASyncTask
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArCentralManager(ArServerBase *robotServer, ArServerBase *clientServer);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArCentralManager();
|
|
||||||
/// Logs all the connection information
|
|
||||||
void logConnections(void);
|
|
||||||
/// Enforces that everything is using this protocol version
|
|
||||||
AREXPORT void enforceProtocolVersion(const char *protocolVersion);
|
|
||||||
/// Enforces that the robots that connect are this type
|
|
||||||
AREXPORT void enforceType(ArServerCommands::Type type);
|
|
||||||
/// Adds a callback for when a new forwarder is added
|
|
||||||
AREXPORT void addForwarderAddedCallback(
|
|
||||||
ArFunctor1<ArCentralForwarder *> *functor, int priority = 0);
|
|
||||||
/// Removes a callback for when a new forwarder is added
|
|
||||||
AREXPORT void remForwarderAddedCallback(
|
|
||||||
ArFunctor1<ArCentralForwarder *> *functor);
|
|
||||||
/// Adds a callback for when a new forwarder is destroyed
|
|
||||||
AREXPORT void addForwarderRemovedCallback(
|
|
||||||
ArFunctor1<ArCentralForwarder *> *functor, int priority = 0);
|
|
||||||
/// Removes a callback for when a new forwarder is destroyed
|
|
||||||
AREXPORT void remForwarderRemovedCallback(
|
|
||||||
ArFunctor1<ArCentralForwarder *> *functor);
|
|
||||||
/// Networking command to get the list of clients
|
|
||||||
AREXPORT void netClientList(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// A callback so we can tell the main connection happened when a
|
|
||||||
/// client is removed
|
|
||||||
AREXPORT void forwarderServerClientRemovedCallback(
|
|
||||||
ArCentralForwarder *forwarder, ArServerClient *client);
|
|
||||||
/// A callback so we can close down other connetions when a main
|
|
||||||
/// client loses connection
|
|
||||||
AREXPORT void mainServerClientRemovedCallback(ArServerClient *client);
|
|
||||||
/// Networking command to switch the direction of a connection
|
|
||||||
AREXPORT void netServerSwitch(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
AREXPORT virtual void *runThread(void *arg);
|
|
||||||
protected:
|
|
||||||
void close(void);
|
|
||||||
bool processFile(void);
|
|
||||||
|
|
||||||
bool removePendingDuplicateConnections(const char *robotName);
|
|
||||||
|
|
||||||
ArServerBase *myRobotServer;
|
|
||||||
ArServerBase *myClientServer;
|
|
||||||
double myHeartbeatTimeout;
|
|
||||||
double myUdpHeartbeatTimeout;
|
|
||||||
double myRobotBackupTimeout;
|
|
||||||
double myClientBackupTimeout;
|
|
||||||
|
|
||||||
std::string myEnforceProtocolVersion;
|
|
||||||
ArServerCommands::Type myEnforceType;
|
|
||||||
|
|
||||||
int myMostForwarders;
|
|
||||||
int myMostClients;
|
|
||||||
|
|
||||||
ArTypes::UByte4 myClosingConnectionID;
|
|
||||||
std::list<ArSocket *> myClientSockets;
|
|
||||||
std::list<std::string> myClientNames;
|
|
||||||
std::list<ArCentralForwarder *> myForwarders;
|
|
||||||
std::map<int, ArTime *> myUsedPorts;
|
|
||||||
ArMutex myCallbackMutex;
|
|
||||||
std::multimap<int,
|
|
||||||
ArFunctor1<ArCentralForwarder *> *> myForwarderAddedCBList;
|
|
||||||
std::multimap<int,
|
|
||||||
ArFunctor1<ArCentralForwarder *> *> myForwarderRemovedCBList;
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
int myOnSocket;
|
|
||||||
ArFunctor2C<ArCentralManager, ArServerClient *,
|
|
||||||
ArNetPacket *> myNetSwitchCB;
|
|
||||||
ArFunctor2C<ArCentralManager, ArServerClient *,
|
|
||||||
ArNetPacket *> myNetClientListCB;
|
|
||||||
ArFunctorC<ArCentralManager> myAriaExitCB;
|
|
||||||
ArRetFunctorC<bool, ArCentralManager> myProcessFileCB;
|
|
||||||
ArFunctor2C<ArCentralManager, ArCentralForwarder *,
|
|
||||||
ArServerClient *> myForwarderServerClientRemovedCB;
|
|
||||||
ArFunctor1C<ArCentralManager, ArServerClient *> myMainServerClientRemovedCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ARSERVERSWITCHMANAGER
|
|
@ -1,170 +0,0 @@
|
|||||||
/*!
|
|
||||||
* \brief Defines the ArClientArg class.
|
|
||||||
* \date 05/01/05
|
|
||||||
* \author K. Cunningham
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
#ifndef ARCLIENTARGUTILS_H
|
|
||||||
#define ARCLIENTARGUTILS_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
|
|
||||||
class ArNetPacket;
|
|
||||||
class ArConfigArg;
|
|
||||||
|
|
||||||
/// Small helper class for sending/receiving an ArConfigArg in an ArNetPacket.
|
|
||||||
/**
|
|
||||||
* ArClientArg defines methods for packing/unpacking an ArConfigArg into/from
|
|
||||||
* an ArNetPacket. (The name of the class is a slight misnomer since it may
|
|
||||||
* be used both on the server and client sides.)
|
|
||||||
* <p>
|
|
||||||
* The structure of the network packet information is as follows:
|
|
||||||
* <pre>
|
|
||||||
* string: arg.getName()
|
|
||||||
* string: arg.getDescription()
|
|
||||||
* byte: arg.getConfigPriority()
|
|
||||||
* byte: arg type ('B' == BOOL | 'I' == INT | 'D' == DOUBLE | 'S' == STRING | 'L' == LIST)
|
|
||||||
* <arg values>
|
|
||||||
* string: arg.getDisplayHint() -- only if isDisplayHintParsed is set to true
|
|
||||||
* string: arg.getExtraExplanation() -- only if version >= 2
|
|
||||||
* byte: arg.getRestartLevel() -- only if version >= 2
|
|
||||||
*
|
|
||||||
* <arg values> varies by arg type:
|
|
||||||
*
|
|
||||||
* if BOOL, then:
|
|
||||||
* byte: arg.getBool()
|
|
||||||
* if INT, then:
|
|
||||||
* byte4: arg.getInt()
|
|
||||||
* byte4: arg.getMinInt()
|
|
||||||
* byte4: arg.getMaxInt()
|
|
||||||
* if DOUBLE, then:
|
|
||||||
* byte4: arg.getDouble()
|
|
||||||
* byte4: arg.getMinDouble()
|
|
||||||
* byte4: arg.getMaxDouble()
|
|
||||||
* byte4: arg.getDoublePrecision() -- only if version >= 2
|
|
||||||
* if STRING, then:
|
|
||||||
* string: arg.getString()
|
|
||||||
* if LIST, then:
|
|
||||||
* byte4: arg.getArgCount()
|
|
||||||
* <list contents>
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
* <p>
|
|
||||||
* ArClientArg also defines methods to send an "abbreviated" ArConfigArg
|
|
||||||
* (i.e. just value). The short packet structure is as follows:
|
|
||||||
* <pre>
|
|
||||||
* <arg value> varies by arg type:
|
|
||||||
* if BOOL, then:
|
|
||||||
* byte: arg.getBool()
|
|
||||||
* if INT, then:
|
|
||||||
* byte4: arg.getInt()
|
|
||||||
* if DOUBLE, then:
|
|
||||||
* byte4: arg.getDouble()
|
|
||||||
* if STRING, then:
|
|
||||||
* string: arg.getString()
|
|
||||||
* if LIST, then:
|
|
||||||
* <TODO>
|
|
||||||
* <list contents>
|
|
||||||
* </pre>
|
|
||||||
* Lastly, it defines a method to send an "abbreviated" ArConfigArg in a
|
|
||||||
* text format.
|
|
||||||
**/
|
|
||||||
class ArClientArg
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArClientArg(bool isDisplayHintParsed = false,
|
|
||||||
ArPriority::Priority lastPriority = ArPriority::LAST_PRIORITY,
|
|
||||||
int version = 1);
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArClientArg();
|
|
||||||
|
|
||||||
/// Returns whether the given parameter can be sent in a network packet.
|
|
||||||
/**
|
|
||||||
* Currently, a parameter can only be sent if it is of type INT, DOUBLE,
|
|
||||||
* STRING, BOOL, LIST, or a SEPARATOR.
|
|
||||||
**/
|
|
||||||
AREXPORT virtual bool isSendableParamType(const ArConfigArg &arg);
|
|
||||||
|
|
||||||
/// Unpacks the given network packet and stores the data in the config arg.
|
|
||||||
/**
|
|
||||||
* @param packet the ArNetPacket * from which data is extracted
|
|
||||||
* @param argOut the ArConfigArg in which to set the data
|
|
||||||
* @return bool set to true if the data was successfully extracted from
|
|
||||||
* the packet; false if an error occurred and argOut is invalid
|
|
||||||
**/
|
|
||||||
AREXPORT virtual bool createArg(ArNetPacket *packet,
|
|
||||||
ArConfigArg &argOut);
|
|
||||||
|
|
||||||
|
|
||||||
/// Stores the given config arg into the network packet.
|
|
||||||
/**
|
|
||||||
* @param arg the ArConfigArg from which to retrieve the data
|
|
||||||
* @param packet the ArNetPacket * to which data is added
|
|
||||||
* @return bool set to true if the data was successfully stored in
|
|
||||||
* the packet; false if an error occurred and the packet is invalid
|
|
||||||
**/
|
|
||||||
AREXPORT virtual bool createPacket(const ArConfigArg &arg,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Unpacks the abbreviated arg value and stores the data in the config arg.
|
|
||||||
/**
|
|
||||||
* @param packet the ArNetPacket * from which data is extracted
|
|
||||||
* @param arg the ArConfigArg in which to set the value
|
|
||||||
* @return bool set to true if the data was successfully extracted from
|
|
||||||
* the packet; false if an error occurred and arg is invalid
|
|
||||||
**/
|
|
||||||
AREXPORT virtual bool bufToArgValue(ArNetPacket *packet,
|
|
||||||
ArConfigArg &arg);
|
|
||||||
|
|
||||||
/// Stores the abbreviated arg value into the network packet.
|
|
||||||
/**
|
|
||||||
* @param arg the ArConfigArg from which to retrieve the data
|
|
||||||
* @param packet the ArNetPacket * to which data is added
|
|
||||||
* @return bool set to true if the data was successfully stored in
|
|
||||||
* the packet; false if an error occurred and the packet is invalid
|
|
||||||
**/
|
|
||||||
AREXPORT virtual bool argValueToBuf(const ArConfigArg &arg,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Stores the arg value into the network packet as a text string.
|
|
||||||
/**
|
|
||||||
* The stored text string is suitable for parsing by an ArArgumentBuilder.
|
|
||||||
*
|
|
||||||
* @param arg the ArConfigArg from which to retrieve the data
|
|
||||||
* @param packet the ArNetPacket * to which data is added
|
|
||||||
* @return bool set to true if the data was successfully stored in
|
|
||||||
* the packet; false if an error occurred and the packet is invalid
|
|
||||||
**/
|
|
||||||
AREXPORT virtual bool argTextToBuf(const ArConfigArg &arg,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
|
|
||||||
AREXPORT virtual bool addArgTextToPacket(const ArConfigArg &arg,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
enum {
|
|
||||||
BUFFER_LENGTH = 1024
|
|
||||||
};
|
|
||||||
|
|
||||||
bool myIsDisplayHintParsed;
|
|
||||||
ArPriority::Priority myLastPriority;
|
|
||||||
int myVersion;
|
|
||||||
|
|
||||||
char myBuffer[BUFFER_LENGTH];
|
|
||||||
char myDisplayBuffer[BUFFER_LENGTH];
|
|
||||||
char myExtraBuffer[BUFFER_LENGTH];
|
|
||||||
|
|
||||||
}; // end class ArClientArgUtils
|
|
||||||
|
|
||||||
#endif //ARCLIENTARGUTILS_H
|
|
@ -1,424 +0,0 @@
|
|||||||
#ifndef NLCLIENTBASE_H
|
|
||||||
#define NLCLIENTBASE_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArClientCommands.h"
|
|
||||||
#include "ArServerCommands.h"
|
|
||||||
#include "ArNetPacket.h"
|
|
||||||
#include "ArNetPacketSenderTcp.h"
|
|
||||||
#include "ArNetPacketReceiverTcp.h"
|
|
||||||
#include "ArNetPacketReceiverUdp.h"
|
|
||||||
#include "ArClientData.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief The base client class
|
|
||||||
|
|
||||||
You need to connect a client to a server using blockingConnect() with
|
|
||||||
the address for the server. Then you should add handlers to
|
|
||||||
the client to receive information from the server (with addHandler(),
|
|
||||||
request(), and requestOnce()). Then call run() or runAsync()
|
|
||||||
(or loopOnce() if you really know what you're doing).
|
|
||||||
You can also add a callback that will get called every cycle of the
|
|
||||||
client.
|
|
||||||
|
|
||||||
User and password information may be required by the server.
|
|
||||||
For details on that see ArServerBase. The most important thing is
|
|
||||||
the modification to blockingConnect(), it can now take a user and
|
|
||||||
password argument and upon failure you'll want to check wasRejected()
|
|
||||||
to determine whether the client couldn't find the server or if the user and
|
|
||||||
password were rejected. Another relevant function is setServerKey()
|
|
||||||
to set the key (string of text) we need to connect to the server.
|
|
||||||
|
|
||||||
This class should be thread safe... The only thing you cannot do is
|
|
||||||
call 'addHandler' or 'remHandler' from within a handler for that
|
|
||||||
specific piece of data.
|
|
||||||
**/
|
|
||||||
|
|
||||||
class ArClientBase : public ArASyncTask
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// The state of the connection
|
|
||||||
enum ClientState {
|
|
||||||
STATE_NO_CONNECTION, ///< The client has not connected
|
|
||||||
STATE_FAILED_CONNECTION, ///< The client tried to connect and failed
|
|
||||||
STATE_OPENED_SOCKET, ///< Client opened socket, waiting for intro from srvr
|
|
||||||
STATE_EXCHANGED_INTROS, ///< Client and server have exchanged introductions
|
|
||||||
STATE_REJECTED, ///< Client was rejected by server
|
|
||||||
STATE_WAITING_LIST, ///< Client was connected to server, waiting for list
|
|
||||||
STATE_CONNECTED, ///< Client is connected to server
|
|
||||||
STATE_LOST_CONNECTION ///< Client lost connection to server
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
CLIENT_KEY_LENGTH = 16
|
|
||||||
};
|
|
||||||
|
|
||||||
enum NonBlockingConnectReturn
|
|
||||||
{
|
|
||||||
NON_BLOCKING_CONTINUE, ///< Client didn't connect or fail to connect yet
|
|
||||||
NON_BLOCKING_CONNECTED, ///< Client connected
|
|
||||||
NON_BLOCKING_FAILED ///< Client couldn't connect
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArClientBase();
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArClientBase();
|
|
||||||
|
|
||||||
/// Sets the optional name of the connected robot for debugging purposes.
|
|
||||||
AREXPORT virtual void setRobotName(const char *name,
|
|
||||||
bool debugLogging = false,
|
|
||||||
int robotId = 0);
|
|
||||||
|
|
||||||
/// Returns the optional name of the connected robot for debugging purposes.
|
|
||||||
AREXPORT virtual const char *getRobotName() const;
|
|
||||||
|
|
||||||
/// Returns the entire string used to prefix log entries for this client base.
|
|
||||||
AREXPORT virtual const char *getLogPrefix() const;
|
|
||||||
|
|
||||||
/// Returns if we're doing debug logging or not
|
|
||||||
AREXPORT bool getDebugLogging(void);
|
|
||||||
|
|
||||||
/// Connect to a server
|
|
||||||
AREXPORT bool blockingConnect(const char *host, int port, bool log = true,
|
|
||||||
const char *user = NULL,
|
|
||||||
const char *password = NULL,
|
|
||||||
const char *openOnIP = NULL);
|
|
||||||
|
|
||||||
/// Disconnect from a server
|
|
||||||
/**
|
|
||||||
* This method blocks while the connection is being shutdown.
|
|
||||||
**/
|
|
||||||
AREXPORT bool disconnect(void);
|
|
||||||
|
|
||||||
/// Disconnect from a server next time through the loop
|
|
||||||
/**
|
|
||||||
* This method does not block while the connection is being
|
|
||||||
* shutdown, and the disconnect only happens the next time the
|
|
||||||
* client base is in its loop
|
|
||||||
**/
|
|
||||||
AREXPORT void disconnectSoon(void);
|
|
||||||
|
|
||||||
/** @return true if we're connected to a server */
|
|
||||||
AREXPORT bool isConnected(void) { return myState == STATE_CONNECTED;}
|
|
||||||
|
|
||||||
/** @return true if a server connection attempt failed because the server rejected the username or password, false if the connection failed for another reason, or the username/password were accepted. */
|
|
||||||
AREXPORT bool wasRejected(void) { return myState == STATE_REJECTED; }
|
|
||||||
|
|
||||||
/// Gets the state of the client
|
|
||||||
AREXPORT ClientState getState(void) { return myState; }
|
|
||||||
|
|
||||||
/// Adds a functor for some particular data
|
|
||||||
AREXPORT bool addHandler(const char *name,
|
|
||||||
ArFunctor1 <ArNetPacket *> *functor);
|
|
||||||
|
|
||||||
/// Removes a functor for some particular data by name
|
|
||||||
AREXPORT bool remHandler(const char *name, ArFunctor1<ArNetPacket *> *functor);
|
|
||||||
|
|
||||||
/// Request some data every @a mSec milliseconds
|
|
||||||
AREXPORT bool request(const char *name, long mSec,
|
|
||||||
ArNetPacket *packet = NULL);
|
|
||||||
|
|
||||||
/// Don't want this data anymore
|
|
||||||
AREXPORT bool requestStop(const char *name);
|
|
||||||
|
|
||||||
/// Request some data (or send a command) just once
|
|
||||||
AREXPORT bool requestOnce(const char *name,
|
|
||||||
ArNetPacket *packet = NULL,
|
|
||||||
bool quiet = false);
|
|
||||||
|
|
||||||
/// Request some data (or send a command) just once by UDP
|
|
||||||
AREXPORT bool requestOnceUdp(const char *name,
|
|
||||||
ArNetPacket *packet = NULL,
|
|
||||||
bool quiet = false);
|
|
||||||
|
|
||||||
/// Request some data (or send a command) just once with a string as argument
|
|
||||||
AREXPORT bool requestOnceWithString(const char *name, const char *str);
|
|
||||||
|
|
||||||
/// Sees if this data exists
|
|
||||||
AREXPORT bool dataExists(const char *name);
|
|
||||||
|
|
||||||
/// Gets the name of the host we tried to connect to
|
|
||||||
AREXPORT const char *getHost(void);
|
|
||||||
|
|
||||||
|
|
||||||
/// Sets the 'key' needed to connect to the server
|
|
||||||
AREXPORT void setServerKey(const char *serverKey, bool log = true);
|
|
||||||
|
|
||||||
/// Enforces the that the server is using this protocol version
|
|
||||||
AREXPORT void enforceProtocolVersion(const char *protocolVersion,
|
|
||||||
bool log = true);
|
|
||||||
|
|
||||||
/// Enforces that the robots that connect are this type
|
|
||||||
AREXPORT void enforceType(ArServerCommands::Type type, bool log = true);
|
|
||||||
|
|
||||||
/// Gets the last time a packet was received
|
|
||||||
AREXPORT ArTime getLastPacketReceived(void);
|
|
||||||
|
|
||||||
/// Sets the backup timeout
|
|
||||||
AREXPORT void setBackupTimeout(double timeoutInMins);
|
|
||||||
|
|
||||||
/// Runs the client in this thread
|
|
||||||
AREXPORT virtual void run(void);
|
|
||||||
|
|
||||||
/// Runs the client in its own thread
|
|
||||||
AREXPORT virtual void runAsync(void);
|
|
||||||
|
|
||||||
/// Stops the thread and sets the stopped flag
|
|
||||||
AREXPORT virtual void stopRunning(void);
|
|
||||||
|
|
||||||
/// Returns whether the client has been stopped (regardless of whether its in its own thread)
|
|
||||||
AREXPORT virtual bool isStopped();
|
|
||||||
|
|
||||||
/// Print out or data with descriptions
|
|
||||||
AREXPORT void logDataList(void);
|
|
||||||
|
|
||||||
/// Adds a functor to call every cycle
|
|
||||||
AREXPORT void addCycleCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Removes a functor called every cycle
|
|
||||||
AREXPORT void remCycleCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Send a packet over TCP
|
|
||||||
AREXPORT bool sendPacketTcp(ArNetPacket *packet);
|
|
||||||
/// Send a packet over UDP (unless client only wants tcp then sends over tcp)
|
|
||||||
AREXPORT bool sendPacketUdp(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Sets the time to allow for connection (default 3)
|
|
||||||
AREXPORT void setConnectTimeoutTime(int sec);
|
|
||||||
|
|
||||||
/// Gets the time allowed for connection
|
|
||||||
AREXPORT int getConnectTimeoutTime(void);
|
|
||||||
|
|
||||||
/// Logs the tracking information (packet and byte counts)
|
|
||||||
AREXPORT void logTracking(bool terse);
|
|
||||||
|
|
||||||
/// Clears the tracking information (resets counters)
|
|
||||||
AREXPORT void resetTracking(void);
|
|
||||||
|
|
||||||
/// Adds a call for when the server shuts down
|
|
||||||
AREXPORT void addServerShutdownCB(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
|
|
||||||
/// Removes a call for when the server shuts down
|
|
||||||
AREXPORT void remServerShutdownCB(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Adds a call for when a disconnection has occured because of error
|
|
||||||
AREXPORT void addDisconnectOnErrorCB(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
|
|
||||||
/// Removes a call for when a disconnection has occured because of error
|
|
||||||
AREXPORT void remDisconnectOnErrorCB(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Run the loop once
|
|
||||||
AREXPORT void loopOnce(void);
|
|
||||||
|
|
||||||
/// Process the packet wherever it came from
|
|
||||||
AREXPORT void processPacket(ArNetPacket *packet, bool tcp);
|
|
||||||
|
|
||||||
/// Process a packet from udp (just hands off to processPacket)
|
|
||||||
AREXPORT void processPacketUdp(ArNetPacket *packet,
|
|
||||||
struct sockaddr_in *sin);
|
|
||||||
|
|
||||||
/// Sets it so we only get TCP data from the server not UDP
|
|
||||||
AREXPORT void setTcpOnlyFromServer(void);
|
|
||||||
/// Sets it so we only send TCP data to the server
|
|
||||||
AREXPORT void setTcpOnlyToServer(void);
|
|
||||||
|
|
||||||
/// Returns whether we only get TCP data from the server not UDP
|
|
||||||
AREXPORT bool isTcpOnlyFromServer(void);
|
|
||||||
/// Returns whether we only send TCP data to the server
|
|
||||||
AREXPORT bool isTcpOnlyToServer(void);
|
|
||||||
/// Gets a (probably) unique key that can be used to identify the client (after connection)
|
|
||||||
AREXPORT void getClientKey(unsigned char key[CLIENT_KEY_LENGTH]);
|
|
||||||
|
|
||||||
|
|
||||||
/// Starts the process of disconnecting from the server.
|
|
||||||
/**
|
|
||||||
* This method should be called in threads that should not block
|
|
||||||
* (such as the main GUI thread). The call should be followed by
|
|
||||||
* a delay of one second, followed by a call to
|
|
||||||
* finishNonBlockingDisconnect().
|
|
||||||
**/
|
|
||||||
AREXPORT bool startNonBlockingDisconnect();
|
|
||||||
|
|
||||||
/// Finishes the process of disconnecting from the server.
|
|
||||||
/**
|
|
||||||
* This method should be used in conjunction with
|
|
||||||
* startNonBlockingDisconnect in threads that should not block
|
|
||||||
* (such as the main GUI thread).
|
|
||||||
**/
|
|
||||||
AREXPORT void finishNonBlockingDisconnect();
|
|
||||||
|
|
||||||
/// Gets the name of the data a packet is for
|
|
||||||
AREXPORT const char *getName(ArNetPacket *packet, bool internalCall = false);
|
|
||||||
/// Gets the name of the data a command is
|
|
||||||
AREXPORT const char *getName(unsigned int command, bool internalCall = false);
|
|
||||||
// the function for the thread
|
|
||||||
AREXPORT virtual void * runThread(void *arg);
|
|
||||||
/// Internal function to get the socket (no one should need this)
|
|
||||||
AREXPORT struct in_addr *getTcpAddr(void) { return myTcpSocket.inAddr(); }
|
|
||||||
/// Internal function that'll do the connection (mainly for switch connections)
|
|
||||||
AREXPORT bool internalBlockingConnect(
|
|
||||||
const char *host, int port, bool log, const char *user,
|
|
||||||
const char *password, ArSocket *tcpSocket,
|
|
||||||
const char *openOnIP = NULL);
|
|
||||||
/// Internal function that'll start the non blocking connection (mainly for switch connections)
|
|
||||||
AREXPORT NonBlockingConnectReturn internalNonBlockingConnectStart(
|
|
||||||
const char *host, int port, bool log, const char *user,
|
|
||||||
const char *password, ArSocket *tcpSocket,
|
|
||||||
const char *openOnIP = NULL);
|
|
||||||
/// Internal function that'll start the non blocking connection (mainly for switch connections)
|
|
||||||
AREXPORT NonBlockingConnectReturn internalNonBlockingConnectContinue(void);
|
|
||||||
/// Internal function to get the tcp socket
|
|
||||||
AREXPORT ArSocket *getTcpSocket(void) { return &myTcpSocket; }
|
|
||||||
/// Internal function to get the udp socket
|
|
||||||
AREXPORT ArSocket *getUdpSocket(void) { return &myUdpSocket; }
|
|
||||||
/// Internal function get get the data map
|
|
||||||
AREXPORT const std::map<unsigned int, ArClientData *> *getDataMap(void)
|
|
||||||
{ return &myIntDataMap; }
|
|
||||||
/// Returns the command number from the name
|
|
||||||
AREXPORT unsigned int findCommandFromName(const char *name);
|
|
||||||
/// Request some data every mSec milliseconds by command not name
|
|
||||||
AREXPORT bool requestByCommand(unsigned int command, long mSec,
|
|
||||||
ArNetPacket *packet = NULL);
|
|
||||||
/// Don't want this data anymore, by command not name
|
|
||||||
AREXPORT bool requestStopByCommand(unsigned int command);
|
|
||||||
|
|
||||||
/// Request some data (or send a command) just once by command not name
|
|
||||||
AREXPORT bool requestOnceByCommand(unsigned int command,
|
|
||||||
ArNetPacket *packet = NULL);
|
|
||||||
/// Request some data (or send a command) just once by command not name
|
|
||||||
AREXPORT bool requestOnceByCommandUdp(unsigned int command,
|
|
||||||
ArNetPacket *packet = NULL);
|
|
||||||
/// Gets if we received the list of commands
|
|
||||||
bool getReceivedDataList(void) { return myReceivedDataList; }
|
|
||||||
/// Gets if we received the list of arguments and
|
|
||||||
bool getReceivedArgRetList(void) { return myReceivedArgRetList; }
|
|
||||||
/// Gets if we received the list of commands
|
|
||||||
bool getReceivedGroupAndFlagsList(void) { return myReceivedGroupAndFlagsList; }
|
|
||||||
/// Tells us the reason the connection was rejected (see ArServerCommands for details)
|
|
||||||
int getRejected(void) { return myRejected; }
|
|
||||||
/// Tells us the reason the connection was rejected (see ArServerCommands for details)
|
|
||||||
const char *getRejectedString(void) { return myRejectedString; }
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// Optional robot name for logging
|
|
||||||
std::string myRobotName;
|
|
||||||
/// Optional prefix to be inserted at the start of log messages
|
|
||||||
std::string myLogPrefix;
|
|
||||||
/// If we're enforcing the version of the protocol or not
|
|
||||||
std::string myEnforceProtocolVersion;
|
|
||||||
/// if we're a particular type
|
|
||||||
ArServerCommands::Type myEnforceType;
|
|
||||||
|
|
||||||
AREXPORT bool setupPacket(ArNetPacket *packet);
|
|
||||||
ArTime myLastPacketReceived;
|
|
||||||
std::list<ArFunctor *> myServerShutdownCBList;
|
|
||||||
std::list<ArFunctor *> myDisconnectOnErrorCBList;
|
|
||||||
std::list<ArFunctor *> myCycleCallbacks;
|
|
||||||
void clear(void);
|
|
||||||
// does the first part of connection
|
|
||||||
bool internalConnect(const char *host, int port, bool obsolete,
|
|
||||||
const char *openOnIP);
|
|
||||||
void internalStartUdp(void);
|
|
||||||
void buildList(ArNetPacket *packet);
|
|
||||||
void internalSwitchState(ClientState state);
|
|
||||||
bool myReceivedDataList;
|
|
||||||
bool myReceivedArgRetList;
|
|
||||||
bool myReceivedGroupAndFlagsList;
|
|
||||||
ClientState myState;
|
|
||||||
ArTime myStateStarted;
|
|
||||||
bool myUdpConfirmedFrom;
|
|
||||||
bool myUdpConfirmedTo;
|
|
||||||
// if we only send tcp
|
|
||||||
bool myTcpOnlyTo;
|
|
||||||
// if we only receive tcp from the server
|
|
||||||
bool myTcpOnlyFrom;
|
|
||||||
|
|
||||||
bool myIsRunningAsync;
|
|
||||||
bool myDisconnectSoon;
|
|
||||||
bool myIsStartedDisconnect;
|
|
||||||
bool myIsStopped;
|
|
||||||
|
|
||||||
bool myQuiet;
|
|
||||||
bool myDebugLogging;
|
|
||||||
ArLog::LogLevel myVerboseLogLevel;
|
|
||||||
std::string myHost;
|
|
||||||
std::string myUser;
|
|
||||||
std::string myPassword;
|
|
||||||
// the time we allow for connections
|
|
||||||
int myTimeoutTime;
|
|
||||||
// the time we started our connection
|
|
||||||
ArTime myStartedConnection;
|
|
||||||
ArTime myStartedUdpConnection;
|
|
||||||
ArTime myStartedShutdown;
|
|
||||||
|
|
||||||
enum NonBlockingConnectState
|
|
||||||
{
|
|
||||||
NON_BLOCKING_STATE_NONE,
|
|
||||||
NON_BLOCKING_STATE_TCP,
|
|
||||||
NON_BLOCKING_STATE_UDP
|
|
||||||
};
|
|
||||||
|
|
||||||
NonBlockingConnectState myNonBlockingConnectState;
|
|
||||||
|
|
||||||
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
ArMutex myClientMutex;
|
|
||||||
ArMutex myMapsMutex;
|
|
||||||
ArMutex myStateMutex;
|
|
||||||
ArMutex myCallbackMutex;
|
|
||||||
ArMutex myCycleCallbackMutex;
|
|
||||||
ArMutex myPacketTrackingMutex;
|
|
||||||
// our map of names to ints
|
|
||||||
std::map<std::string, unsigned int> myNameIntMap;
|
|
||||||
// our map of ints to functors
|
|
||||||
std::map<unsigned int, ArClientData *> myIntDataMap;
|
|
||||||
|
|
||||||
struct sockaddr_in myUdpSin;
|
|
||||||
bool myUdpSinValid;
|
|
||||||
// the port the server said it was using
|
|
||||||
unsigned int myServerReportedUdpPort;
|
|
||||||
// the port the server actually is using
|
|
||||||
unsigned int myServerSentUdpPort;
|
|
||||||
unsigned int myUdpPort;
|
|
||||||
long myAuthKey;
|
|
||||||
long myIntroKey;
|
|
||||||
std::string myServerKey;
|
|
||||||
double myBackupTimeout;
|
|
||||||
// this is a key we have for identifying ourselves moderately uniquely
|
|
||||||
unsigned char myClientKey[16];
|
|
||||||
ArNetPacketSenderTcp myTcpSender;
|
|
||||||
ArNetPacketReceiverTcp myTcpReceiver;
|
|
||||||
ArNetPacketReceiverUdp myUdpReceiver;
|
|
||||||
ArSocket myTcpSocket;
|
|
||||||
ArSocket myUdpSocket;
|
|
||||||
ArFunctor2C<ArClientBase, ArNetPacket *, bool> myProcessPacketCB;
|
|
||||||
ArFunctor2C<ArClientBase, ArNetPacket *, struct sockaddr_in *> myProcessPacketUdpCB;
|
|
||||||
|
|
||||||
int myRejected;
|
|
||||||
char myRejectedString[32000];
|
|
||||||
|
|
||||||
ArTime myTrackingStarted;
|
|
||||||
class Tracker
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Tracker() { reset(); }
|
|
||||||
virtual ~Tracker() {}
|
|
||||||
void reset(void)
|
|
||||||
{ myPacketsTcp = 0; myBytesTcp = 0; myPacketsUdp = 0; myBytesUdp = 0; }
|
|
||||||
long myPacketsTcp;
|
|
||||||
long myBytesTcp;
|
|
||||||
long myPacketsUdp;
|
|
||||||
long myBytesUdp;
|
|
||||||
};
|
|
||||||
AREXPORT void trackPacketSent(ArNetPacket *packet, bool tcp);
|
|
||||||
AREXPORT void trackPacketReceived(ArNetPacket *packet, bool tcp);
|
|
||||||
std::map<unsigned int, Tracker *> myTrackingSentMap;
|
|
||||||
std::map<unsigned int, Tracker *> myTrackingReceivedMap;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // NLCLIENTBASE_H
|
|
@ -1,24 +0,0 @@
|
|||||||
#ifndef NLCLIENTCOMMANDS_H
|
|
||||||
#define NLCLIENTCOMMANDS_H
|
|
||||||
|
|
||||||
/**
|
|
||||||
The commands from the client to the server
|
|
||||||
**/
|
|
||||||
|
|
||||||
class ArClientCommands
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum ClientCommands {
|
|
||||||
SHUTDOWN = 1, ///< Closes the connection
|
|
||||||
INTRODUCTION = 2, ///< Introduces the client to the server
|
|
||||||
UDP_INTRODUCTION = 3, ///< Udp introduction of the client to the server
|
|
||||||
UDP_CONFIRMATION = 4, ///< Confirmation Udp was received from server
|
|
||||||
TCP_ONLY = 5, ///< Client tells server to only send TCP
|
|
||||||
LIST = 128, ///< Lists the types that can be handled
|
|
||||||
REQUEST = 129, ///< Requests packet of a certain type
|
|
||||||
REQUESTSTOP = 130 ///< Requests that the server stop sending the given type
|
|
||||||
/// You can request any other command once if you know its number just by sending that number
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // NLCLIENTCOMMANDS_H
|
|
@ -1,86 +0,0 @@
|
|||||||
#ifndef ARCLIENTDATA_H
|
|
||||||
#define ARCLIENTDATA_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
class ArNetPacket;
|
|
||||||
|
|
||||||
/// class to hold information about the different data the client has
|
|
||||||
/**
|
|
||||||
This class is mostly just for holding all the information about one
|
|
||||||
of the client data entires in one convenient spot
|
|
||||||
|
|
||||||
Information about the data flags held here... The recognized ones
|
|
||||||
right now are just for return values so some forwarding can be done
|
|
||||||
intelligently, you should only have one return value, they are:
|
|
||||||
RETURN_NONE (There are no return packets), RETURN_SINGLE (There is
|
|
||||||
exactly one return packet), RETURN_UNTIL_EMPTY (There return goes
|
|
||||||
until an empty packet), RETURN_VIDEO (this is the special case for
|
|
||||||
video where basically its something thats always requested at an
|
|
||||||
interval and everyone'll want it after we've transfered it),
|
|
||||||
RETURN_COMPLEX (The return is more complex (so you'll need a helper
|
|
||||||
class))
|
|
||||||
**/
|
|
||||||
|
|
||||||
class ArClientData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArClientData(const char *name, const char *description,
|
|
||||||
unsigned int command,
|
|
||||||
ArFunctor1<ArNetPacket *> *functor);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArClientData();
|
|
||||||
/// Gets the name
|
|
||||||
const char *getName(void) { return myName.c_str(); }
|
|
||||||
/// Gets the description
|
|
||||||
const char *getDescription(void) { return myDescription.c_str(); }
|
|
||||||
unsigned int getCommand(void) { return myCommand; }
|
|
||||||
/// Gets the argument description
|
|
||||||
const char *getArgumentDescription(void)
|
|
||||||
{ return myArgumentDescription.c_str(); }
|
|
||||||
/// Gets the return description
|
|
||||||
const char *getReturnDescription(void)
|
|
||||||
{ return myReturnDescription.c_str(); }
|
|
||||||
/// Gets the command group
|
|
||||||
const char *getCommandGroup(void) { return myCommandGroup.c_str(); }
|
|
||||||
AREXPORT bool hasDataFlag(const char *dataFlag);
|
|
||||||
const char *getDataFlagsString(void)
|
|
||||||
{ return myDataFlagsBuilder.getFullString(); }
|
|
||||||
/// Gets the list of functors
|
|
||||||
const std::list<ArFunctor1<ArNetPacket *> *> *getFunctorList(void) const
|
|
||||||
{ return &myFunctorList; };
|
|
||||||
/// Locks the functor list so we can walk it without it changing
|
|
||||||
AREXPORT int lockFunctorList(void) { return myMutex.lock(); }
|
|
||||||
/// Tries to lock the functor list so we can walk it without it changing
|
|
||||||
AREXPORT int tryLockFunctorList(void) { return myMutex.tryLock(); }
|
|
||||||
/// Unlocks the functor list so we can walk it without it changing
|
|
||||||
AREXPORT int unlockFunctorList(void) { return myMutex.unlock(); }
|
|
||||||
|
|
||||||
/// Adds a new functor the end of the list
|
|
||||||
void addFunctor(ArFunctor1<ArNetPacket *> *functor)
|
|
||||||
{ myFunctorList.push_back(functor); }
|
|
||||||
/// Removes a functor from the list all together
|
|
||||||
void remFunctor(ArFunctor1<ArNetPacket *> *functor)
|
|
||||||
{ myFunctorList.remove(functor); }
|
|
||||||
/// Sets the argument and return descriptions
|
|
||||||
void setArgRetDescs(const char *argDesc, const char *retDesc)
|
|
||||||
{ myArgumentDescription = argDesc; myReturnDescription = retDesc; }
|
|
||||||
/// Sets the command group
|
|
||||||
void setCommandGroup(const char *commandGroup)
|
|
||||||
{ myCommandGroup = commandGroup; }
|
|
||||||
/// Sets the data flags
|
|
||||||
AREXPORT void addDataFlags(const char *dataFlags);
|
|
||||||
protected:
|
|
||||||
std::string myName;
|
|
||||||
std::string myDescription;
|
|
||||||
unsigned int myCommand;
|
|
||||||
std::string myArgumentDescription;
|
|
||||||
std::string myReturnDescription;
|
|
||||||
std::string myCommandGroup;
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
ArArgumentBuilder myDataFlagsBuilder;
|
|
||||||
ArMutex myMutex;
|
|
||||||
std::list<ArFunctor1<ArNetPacket *> *> myFunctorList;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARCLIENTDATA_H
|
|
@ -1,367 +0,0 @@
|
|||||||
#ifndef ARCLIENTFILEUTILS_H
|
|
||||||
#define ARCLIENTFILEUTILS_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArClientBase.h"
|
|
||||||
|
|
||||||
/// The item type that the ArCLientFileLister gets back
|
|
||||||
class ArClientFileListerItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
ArClientFileListerItem(const char *name, time_t atime, time_t mtime,
|
|
||||||
ArTypes::UByte4 size)
|
|
||||||
{ myName = name; myATime = atime; myMTime = mtime; mySize = size; }
|
|
||||||
/// Copy Constructor
|
|
||||||
ArClientFileListerItem(const ArClientFileListerItem &item)
|
|
||||||
{ myName = item.myName; myATime = item.myATime; myMTime = item.myMTime;
|
|
||||||
mySize = item.mySize; }
|
|
||||||
/// Assignment operator
|
|
||||||
AREXPORT ArClientFileListerItem &operator=(const
|
|
||||||
ArClientFileListerItem &item)
|
|
||||||
{
|
|
||||||
if (this != &item)
|
|
||||||
{
|
|
||||||
myName = item.myName; myATime = item.myATime; myMTime = item.myMTime;
|
|
||||||
mySize = item.mySize;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
/// Destructor
|
|
||||||
virtual ~ArClientFileListerItem() {}
|
|
||||||
/// Gets the name of the list item
|
|
||||||
const char *getName(void) const { return myName.c_str(); }
|
|
||||||
/// Gets the time this list item was last accessed in seconds from 1970
|
|
||||||
time_t getLastAccessedTime(void) const { return myATime; }
|
|
||||||
/// Gets the time this list item was last modified in seconds from 1970
|
|
||||||
time_t getLastModifiedTime(void) const { return myMTime; }
|
|
||||||
/// Gets the size of this list item in bytes
|
|
||||||
ArTypes::UByte4 getSize(void) const { return mySize; }
|
|
||||||
protected:
|
|
||||||
std::string myName;
|
|
||||||
time_t myATime;
|
|
||||||
time_t myMTime;
|
|
||||||
ArTypes::UByte4 mySize;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Class for getting file list information from the server
|
|
||||||
/**
|
|
||||||
This class will interact with the ArServerFileLister and find out
|
|
||||||
whats in directories and change directories and such. This class
|
|
||||||
is all that should be used to get the information from
|
|
||||||
ArServerFileLister, the API between the two is fairly volatile and
|
|
||||||
will remain so. If you need more functionality let us know and
|
|
||||||
we'll add it if its reasonable.
|
|
||||||
|
|
||||||
When you change directories or change to the top dir it doesn't
|
|
||||||
happen right away, but when it happens the update callbacks will be
|
|
||||||
called, 0 as the int for the callback means everything is good,
|
|
||||||
positive error messages are from the server (1 == tried to go
|
|
||||||
outside allowed area, 2 == no such directory), negative are from
|
|
||||||
this class (-1 == got directory but it wasn't what we wanted (if
|
|
||||||
you wait the right one might come in, like if someone selects one
|
|
||||||
dir then the other)).
|
|
||||||
**/
|
|
||||||
class ArClientFileLister
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArClientFileLister(ArClientBase *client);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArClientFileLister();
|
|
||||||
/// Sees if the server supports what this class needs
|
|
||||||
AREXPORT bool isAvailable(void);
|
|
||||||
/// Goes to the top directory
|
|
||||||
AREXPORT void changeToTopDir(void);
|
|
||||||
/// Goes to this directory in the current directory
|
|
||||||
AREXPORT void changeToDir(const char *dir);
|
|
||||||
/// Goes up one directory from current directory
|
|
||||||
AREXPORT void upOneDir(void);
|
|
||||||
/// Goes to this absolute directory
|
|
||||||
AREXPORT void changeToAbsDir(const char *dir);
|
|
||||||
/// Gets the name of the directory we're in
|
|
||||||
AREXPORT const char *getCurrentDir(void) const;
|
|
||||||
/// Gets the name of the directory that we're currently waiting for
|
|
||||||
AREXPORT const char *getWaitingForDir(void) const;
|
|
||||||
|
|
||||||
/// Gets the directories in the current directory
|
|
||||||
AREXPORT std::list<ArClientFileListerItem> getDirectories(void) const;
|
|
||||||
/// Gets the files in the current directory
|
|
||||||
AREXPORT std::list<ArClientFileListerItem> getFiles(void) const;
|
|
||||||
/// Adds a callback for when we get the desired directory info
|
|
||||||
AREXPORT void addUpdatedCallback(ArFunctor1<int> *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback for when we get the desired directory info
|
|
||||||
AREXPORT void remUpdatedCallback(ArFunctor1<int> *functor);
|
|
||||||
/// Gets the last time we were updated
|
|
||||||
AREXPORT ArTime getLastUpdated(void);
|
|
||||||
/// Gets the last time we requested an update
|
|
||||||
AREXPORT ArTime getLastRequested(void);
|
|
||||||
/// Logs the current directory
|
|
||||||
AREXPORT void log(bool withTimes);
|
|
||||||
protected:
|
|
||||||
AREXPORT void netGetDirListing(ArNetPacket *packet);
|
|
||||||
AREXPORT void netGetDirListingMultiplePackets(ArNetPacket *packet);
|
|
||||||
AREXPORT void callUpdatedCallbacks(int val);
|
|
||||||
AREXPORT void logList(
|
|
||||||
std::list<ArClientFileListerItem> *logThis,
|
|
||||||
bool withTimes);
|
|
||||||
void getDirListing(const char *dir);
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
ArMutex myCallbackMutex;
|
|
||||||
ArClientBase *myClient;
|
|
||||||
char myCurrentDir[2048];
|
|
||||||
char myWaitingForDir[2048];
|
|
||||||
bool myLastDirMatched;
|
|
||||||
bool myNewDirListing;
|
|
||||||
ArTime myLastRequested;
|
|
||||||
ArTime myLastUpdated;
|
|
||||||
std::list<ArClientFileListerItem> myDirectories;
|
|
||||||
std::list<ArClientFileListerItem> myFiles;
|
|
||||||
std::list<ArFunctor1<int> *> myUpdatedCallbacks;
|
|
||||||
ArFunctor1C<ArClientFileLister, ArNetPacket *> myGetDirListingCB;
|
|
||||||
ArFunctor1C<ArClientFileLister,
|
|
||||||
ArNetPacket *> myGetDirListingMultiplePacketsCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/// Class for getting files from the server
|
|
||||||
/**
|
|
||||||
This class will interact with the ArServerFileToClient and get a
|
|
||||||
file on the server. If you want to find out what files are on the
|
|
||||||
server use ArClientFileLister.
|
|
||||||
|
|
||||||
When get a file it doesn't happen right away, but when the file is
|
|
||||||
received (or failes) the fileGotten callbacks will be called, 0 as
|
|
||||||
the int for the callback means everything is good, positive error
|
|
||||||
messages are from the server (1 == tried to go outside allowed
|
|
||||||
area, 2 == no such directory, 3 == empty file name, 4 == problem
|
|
||||||
reading file), negative are from this class (-1 == got directory
|
|
||||||
but it wasn't what we wanted (if you wait the right one might come
|
|
||||||
in, like if someone selects one dir then the other), -2 == can't
|
|
||||||
open file to put result into).
|
|
||||||
**/
|
|
||||||
class ArClientFileToClient
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArClientFileToClient(ArClientBase *client);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArClientFileToClient();
|
|
||||||
/// Sees if the server supports what this class needs
|
|
||||||
AREXPORT bool isAvailable(void);
|
|
||||||
|
|
||||||
AREXPORT bool isAvailableSetTimestamp(void);
|
|
||||||
|
|
||||||
/// Get the file from a directory
|
|
||||||
AREXPORT bool getFileFromDirectory(const char *directory,
|
|
||||||
const char *fileName,
|
|
||||||
const char *clientFileName,
|
|
||||||
bool isSetTimestamp = false);
|
|
||||||
/// Cancels getting a file
|
|
||||||
AREXPORT void cancelGet(void);
|
|
||||||
/// If we're getting a file now
|
|
||||||
AREXPORT bool isWaitingForFile(void);
|
|
||||||
/// Gets the directory we're getting from
|
|
||||||
AREXPORT const char *getDirectory(void);
|
|
||||||
/// Gets the filename we're getting
|
|
||||||
AREXPORT const char *getFileName(void);
|
|
||||||
/// Gets the filename we'll save the gotten file in
|
|
||||||
AREXPORT const char *getClientFileName(void);
|
|
||||||
/// Adds a callback for when we get the desired file (or fail)
|
|
||||||
AREXPORT void addFileReceivedCallback(ArFunctor1<int> *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback for when we get the desired file (or fail)
|
|
||||||
AREXPORT void remFileReceivedCallback(ArFunctor1<int> *functor);
|
|
||||||
|
|
||||||
|
|
||||||
/// Gets the last time we finished getting a file
|
|
||||||
AREXPORT ArTime getLastReceived(void);
|
|
||||||
/// Gets the last time we asked for a file
|
|
||||||
AREXPORT ArTime getLastRequested(void);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
AREXPORT void netGetFile(ArNetPacket *packet);
|
|
||||||
AREXPORT void netGetFileWithTimestamp(ArNetPacket *packet);
|
|
||||||
AREXPORT void doGetFile(ArNetPacket *packet,
|
|
||||||
bool isSetTimestamp);
|
|
||||||
AREXPORT void callFileReceivedCallbacks(int val);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
ArMutex myCallbackMutex;
|
|
||||||
ArClientBase *myClient;
|
|
||||||
bool myIsWaitingForFile;
|
|
||||||
std::string myDirectory;
|
|
||||||
std::string myFileName;
|
|
||||||
std::string myWholeFileName;
|
|
||||||
std::string myClientFileName;
|
|
||||||
FILE *myFile;
|
|
||||||
|
|
||||||
ArTime myLastRequested;
|
|
||||||
ArTime myLastReceived;
|
|
||||||
|
|
||||||
std::list<ArFunctor1<int> *> myFileReceivedCallbacks;
|
|
||||||
|
|
||||||
ArFunctor1C<ArClientFileToClient, ArNetPacket *> myGetFileCB;
|
|
||||||
ArFunctor1C<ArClientFileToClient, ArNetPacket *> myGetFileWithTimestampCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Class for putting files to the server
|
|
||||||
/**
|
|
||||||
This class will interact with the ArServerFileFromClient and put a
|
|
||||||
file on to the server. If you want to find out what files are on
|
|
||||||
the server use ArClientFileLister.
|
|
||||||
|
|
||||||
When get a file it doesn't happen right away, but when the file is
|
|
||||||
received (or failes) the fileGotten callbacks will be called, 0 as
|
|
||||||
the int for the callback means everything is good, positive error
|
|
||||||
messages are from the server (0 = good (got file), 1 = getting
|
|
||||||
file, 2 = tried to go outside allowed area, 3 = bad directory, 4 =
|
|
||||||
empty file name (or other problem with fileName), 5 = can't write
|
|
||||||
temp file, 6 = error moving file from temp to perm, 7 = another
|
|
||||||
client putting file, 8 = timeout (no activity for 15 seconds) and
|
|
||||||
another client wanted to put the file, 9 = client adding to,
|
|
||||||
finishing, or canceling a file the server doesn't have), negative
|
|
||||||
would be from this class but there aren't any of those yet
|
|
||||||
**/
|
|
||||||
class ArClientFileFromClient
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArClientFileFromClient(ArClientBase *client);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArClientFileFromClient();
|
|
||||||
/// Sees if the server supports what this class needs
|
|
||||||
AREXPORT bool isAvailable(void);
|
|
||||||
/// Sees if the server supports what this class needs to send slowly
|
|
||||||
AREXPORT bool isAvailableSlow(void);
|
|
||||||
/// Sees if the server supports what this class needs to send fast
|
|
||||||
AREXPORT bool isAvailableFast(void);
|
|
||||||
/// Sees if the server supports the ability to set the file timestamp
|
|
||||||
AREXPORT bool isAvailableSetTimestamp(void);
|
|
||||||
|
|
||||||
/// Enum that describes the speed to send at
|
|
||||||
enum SendSpeed
|
|
||||||
{
|
|
||||||
SPEED_AUTO, ///< Send it fast if available, if not then send it slow
|
|
||||||
SPEED_FAST, ///< Send it fast
|
|
||||||
SPEED_SLOW ///< Send it slow
|
|
||||||
};
|
|
||||||
/// Puts the specified client file on the server in the given directory and file
|
|
||||||
AREXPORT bool putFileToDirectory(const char *directory,
|
|
||||||
const char *fileName,
|
|
||||||
const char *clientFileName,
|
|
||||||
SendSpeed sendSpeed = SPEED_AUTO,
|
|
||||||
bool isSetTimestamp = false);
|
|
||||||
/// Cancels putting a file
|
|
||||||
AREXPORT void cancelPut(void);
|
|
||||||
|
|
||||||
/// If we're waiting for completion now
|
|
||||||
AREXPORT bool isWaitingForReturn(void);
|
|
||||||
/// Gets the directory we're putting to
|
|
||||||
AREXPORT const char *getDirectory(void);
|
|
||||||
/// Gets the filename we're putting
|
|
||||||
AREXPORT const char *getFileName(void);
|
|
||||||
/// Gets the filename we're taking from the client
|
|
||||||
AREXPORT const char *getClientFileName(void);
|
|
||||||
/// Adds a callback for when we get the desired file (or fail)
|
|
||||||
AREXPORT void addFileSentCallback(ArFunctor1<int> *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback for when we get the desired file (or fail)
|
|
||||||
AREXPORT void remFileSentCallback(ArFunctor1<int> *functor);
|
|
||||||
/// Gets the last time we finished putting a file
|
|
||||||
AREXPORT ArTime getLastCompletedSend(void);
|
|
||||||
/// Gets the last time we started putting a file
|
|
||||||
AREXPORT ArTime getLastStartedSend(void);
|
|
||||||
protected:
|
|
||||||
AREXPORT void netPutFile(ArNetPacket *packet);
|
|
||||||
AREXPORT void callFileSentCallbacks(int val);
|
|
||||||
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
ArMutex myCallbackMutex;
|
|
||||||
ArClientBase *myClient;
|
|
||||||
bool myIsWaitingForReturn;
|
|
||||||
bool myInterleaved;
|
|
||||||
bool myTimestamp;
|
|
||||||
std::string myCommandName;
|
|
||||||
std::string myDirectory;
|
|
||||||
std::string myFileName;
|
|
||||||
std::string myWholeFileName;
|
|
||||||
std::string myClientFileName;
|
|
||||||
|
|
||||||
bool myReadyForNextPacket;
|
|
||||||
FILE *myFile;
|
|
||||||
ArTime myLastStartedSend;
|
|
||||||
ArTime myLastCompletedSend;
|
|
||||||
std::list<ArFunctor1<int> *> myFileSentCallbacks;
|
|
||||||
ArFunctor1C<ArClientFileFromClient, ArNetPacket *> myPutFileCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/// Class for deleting a file on the server
|
|
||||||
/**
|
|
||||||
This class will interact with the ArServerFileFromClient and put a
|
|
||||||
file on to the server. If you want to find out what files are on
|
|
||||||
the server use ArClientFileLister.
|
|
||||||
|
|
||||||
When get a file it doesn't happen right away, but when the file is
|
|
||||||
received (or failes) the fileGotten callbacks will be called, 0 as
|
|
||||||
the int for the callback means everything is good, positive error
|
|
||||||
messages are from the server (0 = good (got file), 1 = getting
|
|
||||||
file, 2 = tried to go outside allowed area, 3 = bad directory, 4 =
|
|
||||||
empty file name (or other problem with fileName), 5 = can't write
|
|
||||||
temp file, 6 = error moving file from temp to perm, 7 = another
|
|
||||||
client putting file, 8 = timeout (no activity for 15 seconds) and
|
|
||||||
another client wanted to put the file, 9 = client adding to,
|
|
||||||
finishing, or canceling a file the server doesn't have), negative
|
|
||||||
would be from this class but there aren't any of those yet
|
|
||||||
**/
|
|
||||||
class ArClientDeleteFileOnServer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArClientDeleteFileOnServer(ArClientBase *client);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArClientDeleteFileOnServer();
|
|
||||||
/// Sees if the server supports what this class needs
|
|
||||||
AREXPORT bool isAvailable(void);
|
|
||||||
/// Get the file from a directory
|
|
||||||
AREXPORT bool deleteFileFromDirectory(const char *directory,
|
|
||||||
const char *fileName);
|
|
||||||
/// If we're waiting for completion now
|
|
||||||
AREXPORT bool isWaitingForReturn(void);
|
|
||||||
/// Gets the directory we're putting to
|
|
||||||
AREXPORT const char *getDirectory(void);
|
|
||||||
/// Gets the filename we're putting
|
|
||||||
AREXPORT const char *getFileName(void);
|
|
||||||
/// Adds a callback for when we get the desired file (or fail)
|
|
||||||
AREXPORT void addFileDeletedCallback(ArFunctor1<int> *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback for when we get the desired file (or fail)
|
|
||||||
AREXPORT void remFileDeletedCallback(ArFunctor1<int> *functor);
|
|
||||||
/// Gets the last time we finished putting a file
|
|
||||||
AREXPORT ArTime getLastCompletedSend(void);
|
|
||||||
/// Gets the last time we started putting a file
|
|
||||||
AREXPORT ArTime getLastStartedSend(void);
|
|
||||||
protected:
|
|
||||||
AREXPORT void netDeleteFile(ArNetPacket *packet);
|
|
||||||
AREXPORT void callFileDeletedCallbacks(int val);
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
ArMutex myCallbackMutex;
|
|
||||||
ArClientBase *myClient;
|
|
||||||
bool myIsWaitingForReturn;
|
|
||||||
std::string myDirectory;
|
|
||||||
std::string myFileName;
|
|
||||||
std::string myWholeFileName;
|
|
||||||
FILE *myFile;
|
|
||||||
ArTime myLastStartedSend;
|
|
||||||
ArTime myLastCompletedSend;
|
|
||||||
std::list<ArFunctor1<int> *> myFileDeletedCallbacks;
|
|
||||||
ArFunctor1C<ArClientDeleteFileOnServer, ArNetPacket *> myDeleteFileCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //ARCLIENTFILEUTILS_H
|
|
@ -1,223 +0,0 @@
|
|||||||
#ifndef ARCLIENTCONFIGHANDLER_H
|
|
||||||
#define ARCLIENTCONFIGHANDLER_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArClientBase.h"
|
|
||||||
|
|
||||||
/// Client handler for receiving and updating ArConfig data via ArNetworking.
|
|
||||||
/**
|
|
||||||
* ArClientHandlerConfig processes the network packets that describe a
|
|
||||||
* robot's ArConfig. It also provides a means to save the modified
|
|
||||||
* configuration data to the robot server. This class is designed to
|
|
||||||
* work in conjunction with the ArServerHandlerConfig. See the server
|
|
||||||
* handler documentation for a complete description of the networking
|
|
||||||
* interface.
|
|
||||||
*
|
|
||||||
* This class should be thread safe, with the exception of
|
|
||||||
* unThreadSafeGetConfig. (If you want to use this method, surround it
|
|
||||||
* with calls to lock() and unlock().)
|
|
||||||
*
|
|
||||||
* Note that you can't add callbacks or remove callbacks from within a
|
|
||||||
* callback function.
|
|
||||||
**/
|
|
||||||
class ArClientHandlerConfig
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArClientHandlerConfig(ArClientBase *client,
|
|
||||||
bool ignoreBounds = false,
|
|
||||||
const char *robotName = NULL,
|
|
||||||
const char *logPrefix = NULL);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArClientHandlerConfig(void);
|
|
||||||
|
|
||||||
/// Requests the config from the server
|
|
||||||
AREXPORT void requestConfigFromServer(void);
|
|
||||||
/// Tells the server to reload the configuration
|
|
||||||
AREXPORT void reloadConfigOnServer(void);
|
|
||||||
|
|
||||||
/// Threadsafe way to get the config to play with
|
|
||||||
AREXPORT ArConfig getConfigCopy(void);
|
|
||||||
|
|
||||||
/// Adds a gotConfig callback
|
|
||||||
AREXPORT void addGotConfigCB(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a gotConfig callback
|
|
||||||
AREXPORT void remGotConfigCB(ArFunctor *functor);
|
|
||||||
/// Adds a save config to server succeeded callback
|
|
||||||
AREXPORT void addSaveConfigSucceededCB(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a save config to server succeeded callback
|
|
||||||
AREXPORT void remSaveConfigSucceededCB(ArFunctor *functor);
|
|
||||||
/// Adds a save config to server failed callback
|
|
||||||
AREXPORT void addSaveConfigFailedCB(ArFunctor1<const char *> *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a save config to server failed callback
|
|
||||||
AREXPORT void remSaveConfigFailedCB(ArFunctor1<const char *> *functor);
|
|
||||||
|
|
||||||
/// Returns true if config gotten
|
|
||||||
AREXPORT bool haveGottenConfig(void);
|
|
||||||
/// Sends the config back to the server
|
|
||||||
AREXPORT void saveConfigToServer(void);
|
|
||||||
/// Sends the config back to the server
|
|
||||||
AREXPORT void saveConfigToServer(
|
|
||||||
ArConfig *config,
|
|
||||||
const std::set<std::string,
|
|
||||||
ArStrCaseCmpOp> *ignoreTheseSections = NULL);
|
|
||||||
|
|
||||||
/// Returns if we've requested some defaults
|
|
||||||
AREXPORT bool haveRequestedDefaults(void);
|
|
||||||
/// Returns if we've gotten our requested defaults
|
|
||||||
AREXPORT bool haveGottenDefaults(void);
|
|
||||||
|
|
||||||
/// Sees if we can request defaults (both types)
|
|
||||||
AREXPORT bool canRequestDefaults(void);
|
|
||||||
|
|
||||||
AREXPORT bool requestDefaultConfigFromServer(void);
|
|
||||||
AREXPORT ArConfig *getDefaultConfig();
|
|
||||||
|
|
||||||
/// Requests defaults for all sections from the server; modifies the config
|
|
||||||
AREXPORT bool requestConfigDefaults(void);
|
|
||||||
/// Requests defaults for one section from the server; modifies the config
|
|
||||||
AREXPORT bool requestSectionDefaults(const char *section);
|
|
||||||
|
|
||||||
|
|
||||||
/// Adds a got config defaults callback
|
|
||||||
AREXPORT void addGotConfigDefaultsCB(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a got config defaults callback
|
|
||||||
AREXPORT void remGotConfigDefaultsCB(ArFunctor *functor);
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
// Last Editable Priority
|
|
||||||
//
|
|
||||||
// This value designates the last priority (highest numerical value) for
|
|
||||||
// which parameters may be edited. For example, when this value is set to
|
|
||||||
// EXPERT, then the user may not edit FACTORY parameters.
|
|
||||||
//
|
|
||||||
// If editable priority levels are supported and the client wishes to
|
|
||||||
// receive parameters of ineditable priorities, then the method
|
|
||||||
// requestLastEditablePriority should be called (and completed) before
|
|
||||||
// requestConfigFromServer is called.
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/// Returns whether the server supports the last editable priority request.
|
|
||||||
AREXPORT bool isLastEditablePriorityAvailable();
|
|
||||||
|
|
||||||
/// Requests the last editable priority from the server
|
|
||||||
AREXPORT bool requestLastEditablePriorityFromServer();
|
|
||||||
|
|
||||||
/// Returns whether the last editable priority has been received from the server
|
|
||||||
AREXPORT bool haveGottenLastEditablePriority();
|
|
||||||
/// Returns the last editable priority of the config
|
|
||||||
AREXPORT ArPriority::Priority getLastEditablePriority();
|
|
||||||
|
|
||||||
/// Adds callback invoked when the last editable priority packet is received
|
|
||||||
AREXPORT void addGotLastEditablePriorityCB
|
|
||||||
(ArFunctor *functor,
|
|
||||||
int position = 50);
|
|
||||||
/// Removes the specified callback from the list of last editable priority callbacks
|
|
||||||
AREXPORT void remGotLastEditablePriorityCB(ArFunctor *functor);
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/// Unthreadsafe way to get the config to play with (see long docs)
|
|
||||||
AREXPORT ArConfig *getConfig(void);
|
|
||||||
/// Locks the config for if you're using the unthreadsafe getConfig
|
|
||||||
AREXPORT int lock(void);
|
|
||||||
/// Try to lock for the config for if you're using the unthreadsafe getConfig
|
|
||||||
AREXPORT int tryLock(void);
|
|
||||||
/// Unlocks the config for if you're using the unthreadsafe getConfig
|
|
||||||
AREXPORT int unlock(void);
|
|
||||||
|
|
||||||
/// Turn on this flag to reduce the number of verbose log messages.
|
|
||||||
AREXPORT void setQuiet(bool isQuiet);
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
// Packet Handlers
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
/// Handles the packet from the GetConfigBySectionsV3
|
|
||||||
AREXPORT void handleGetConfigBySectionsV3(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the packet from the GetConfigBySectionsV2
|
|
||||||
AREXPORT void handleGetConfigBySectionsV2(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the packet from the GetConfigBySections
|
|
||||||
AREXPORT void handleGetConfigBySections(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the packet from the GetConfigSectionFlags
|
|
||||||
AREXPORT void handleGetConfigSectionFlags(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the packet from the getConfig
|
|
||||||
AREXPORT void handleGetConfig(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the return packet from the setConfig (saveConfigToServer)
|
|
||||||
AREXPORT void handleSetConfig(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the return packet from the setConfigBySections (saveConfigToServer)
|
|
||||||
AREXPORT void handleSetConfigBySections(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the return packet from the setConfigBySectionsV2 (saveConfigToServer)
|
|
||||||
AREXPORT void handleSetConfigBySectionsV2(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the return packet from getConfigDefaults
|
|
||||||
AREXPORT void handleGetConfigDefaults(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the return packet from getLastEditablePriority
|
|
||||||
AREXPORT void handleGetLastEditablePriority(ArNetPacket *packet);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
AREXPORT void handleGetConfigData(ArNetPacket *packet,
|
|
||||||
bool isMultiplePackets,
|
|
||||||
int version);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
std::string myRobotName;
|
|
||||||
std::string myLogPrefix;
|
|
||||||
|
|
||||||
std::list<ArFunctor *> myGotConfigCBList;
|
|
||||||
std::list<ArFunctor *> mySaveConfigSucceededCBList;
|
|
||||||
std::list<ArFunctor1<const char *> *> mySaveConfigFailedCBList;
|
|
||||||
std::list<ArFunctor *> myGotConfigDefaultsCBList;
|
|
||||||
ArCallbackList myGotLastEditablePriorityCBList;
|
|
||||||
|
|
||||||
ArClientBase *myClient;
|
|
||||||
|
|
||||||
ArConfig myConfig;
|
|
||||||
ArConfig *myDefaultConfig;
|
|
||||||
ArPriority::Priority myLastEditablePriority;
|
|
||||||
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
ArMutex myCallbackMutex;
|
|
||||||
|
|
||||||
bool myHaveRequestedLastEditablePriority;
|
|
||||||
bool myHaveGottenLastEditablePriority;
|
|
||||||
bool myHaveRequestedConfig;
|
|
||||||
bool myHaveGottenConfig;
|
|
||||||
bool myHaveRequestedDefaults;
|
|
||||||
bool myHaveGottenDefaults;
|
|
||||||
bool myHaveRequestedDefaultCopy;
|
|
||||||
|
|
||||||
bool myIsQuiet;
|
|
||||||
|
|
||||||
ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> myHandleGetConfigBySectionsV3CB;
|
|
||||||
ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> myHandleGetConfigBySectionsV2CB;
|
|
||||||
ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> myHandleGetConfigBySectionsCB;
|
|
||||||
ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> myHandleGetConfigCB;
|
|
||||||
ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> myHandleSetConfigCB;
|
|
||||||
ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> myHandleSetConfigBySectionsCB;
|
|
||||||
ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> myHandleSetConfigBySectionsV2CB;
|
|
||||||
ArFunctor1C<ArClientHandlerConfig,
|
|
||||||
ArNetPacket *> myHandleGetConfigDefaultsCB;
|
|
||||||
ArFunctor1C<ArClientHandlerConfig,
|
|
||||||
ArNetPacket *> myHandleGetDefaultConfigCB;
|
|
||||||
ArFunctor1C<ArClientHandlerConfig,
|
|
||||||
ArNetPacket *> myHandleGetConfigSectionFlagsCB;
|
|
||||||
ArFunctor1C<ArClientHandlerConfig,
|
|
||||||
ArNetPacket *> myHandleGetLastEditablePriorityCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,71 +0,0 @@
|
|||||||
#ifndef ARCLIENTSIMPLECONNECTOR_H
|
|
||||||
#define ARCLIENTSIMPLECONNECTOR_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArClientBase.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
This will let you connect to different hosts, ports, and with
|
|
||||||
different users and passwords more easily.
|
|
||||||
|
|
||||||
Some program command line options affect behavior:
|
|
||||||
@verbinclude ArClientSimpleConnector_options
|
|
||||||
|
|
||||||
To set the host the client will connect to use '<code>-host</code> <i>hostName</i>'
|
|
||||||
in the command line parameters
|
|
||||||
(no abbreviation for this since <code>-h</code> is for help and it's only 4
|
|
||||||
letters). To set the port the client will connect to use '<code>-port</code>
|
|
||||||
<i>portNumber</i>' or '<code>-p</code> <i>portNumber</i>'.
|
|
||||||
To set the user to connect with
|
|
||||||
use '<code>-user</code> <i>userName</i>' or '<code>-u</code> <i>userName</i>'.
|
|
||||||
To set the password to
|
|
||||||
connect with use '<code>-password</code> <i>password</i>' or
|
|
||||||
'<code>-pwd</code> <i>password</i>'. To
|
|
||||||
use no password use '<code>-nopassword</code>' or '<code>-np</code>'.
|
|
||||||
Note that for using
|
|
||||||
passwords you should NOT use that option on the command line since
|
|
||||||
that can show everyone what the password is (especially in Linux),
|
|
||||||
it's there only for testing. If you give it a username without a
|
|
||||||
password it'll ask you for a password, if you don't have a password
|
|
||||||
just use the -nopassword or let it ask you for a password and hit
|
|
||||||
enter. To set the server key (string we need to connect to the
|
|
||||||
server) use '<code>-setServerKey</code> <i>serverKey</i>' or
|
|
||||||
'<code>-ssk</code> <i>serverKey</i>'.
|
|
||||||
**/
|
|
||||||
class ArClientSimpleConnector
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor that takes argument parser (prefered)
|
|
||||||
AREXPORT ArClientSimpleConnector(ArArgumentParser *parser);
|
|
||||||
/// Constructor that takes args from main (not prefered)
|
|
||||||
AREXPORT ArClientSimpleConnector(int *argc, char **argv);
|
|
||||||
/// Constructor that takes argument builder (not prefered)
|
|
||||||
AREXPORT ArClientSimpleConnector(ArArgumentBuilder *arguments);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT ~ArClientSimpleConnector(void);
|
|
||||||
/// Connects the client with the options given
|
|
||||||
AREXPORT bool connectClient(ArClientBase *client, bool log = true);
|
|
||||||
/// Parses the arguments
|
|
||||||
AREXPORT bool parseArgs(void);
|
|
||||||
/// Parses the arguments
|
|
||||||
AREXPORT bool parseArgs(ArArgumentParser *parser);
|
|
||||||
/// Logs the options the connector has
|
|
||||||
AREXPORT void logOptions(void) const;
|
|
||||||
protected:
|
|
||||||
void reset(void);
|
|
||||||
const char *myHost;
|
|
||||||
const char *myUser;
|
|
||||||
const char *myPassword;
|
|
||||||
const char *myServerKey;
|
|
||||||
int myPort;
|
|
||||||
bool myNoPassword;
|
|
||||||
bool myLogDataList;
|
|
||||||
// our parser
|
|
||||||
ArArgumentParser *myParser;
|
|
||||||
bool myOwnParser;
|
|
||||||
|
|
||||||
ArRetFunctorC<bool, ArClientSimpleConnector> myParseArgsCB;
|
|
||||||
ArConstFunctorC<ArClientSimpleConnector> myLogOptionsCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARCLIENTSIMPLECONNECTOR_H
|
|
@ -1,187 +0,0 @@
|
|||||||
#ifndef ARCLIENTSWITCH_H
|
|
||||||
#define ARCLIENTSWITCH_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
#include "ArClientBase.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
The serverInfoFile takes the form of a config file roughly, there
|
|
||||||
are 3 things you can put in it now. 'user <i>user</i>', 'password
|
|
||||||
<i>password</i>' and 'serverKey <i>serverKey</i>'. Note that it loads these
|
|
||||||
files sequentially so if you pass it 5 files it'll read them in the
|
|
||||||
order they were passed in. If you give it just the keyword but not
|
|
||||||
the value (ie 'user') then it'll clear out that value.
|
|
||||||
|
|
||||||
Some program command line options can be used to configure this class:
|
|
||||||
@verbinclude ArClientSwitchManager_options
|
|
||||||
**/
|
|
||||||
class ArClientSwitchManager : public ArASyncTask
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AREXPORT ArClientSwitchManager(
|
|
||||||
ArServerBase *serverBase,
|
|
||||||
ArArgumentParser *parser,
|
|
||||||
const char *serverDescription = "Central Server",
|
|
||||||
const char *clientSoftwareDescription = "Software");
|
|
||||||
AREXPORT virtual ~ArClientSwitchManager();
|
|
||||||
/// Returns if we're connected or not
|
|
||||||
AREXPORT bool isConnected(void);
|
|
||||||
/// Function to parse the arguments given in the constructor
|
|
||||||
AREXPORT bool parseArgs(void);
|
|
||||||
/// Log the options the simple connector has
|
|
||||||
AREXPORT void logOptions(void) const;
|
|
||||||
/// Gets the hostname we're using for the central server (NULL means we're not trying to sue the central server)
|
|
||||||
AREXPORT const char *getCentralServerHostName(void);
|
|
||||||
/// Gets the identifier we're using
|
|
||||||
AREXPORT const char *getIdentifier(void);
|
|
||||||
/// Sets the identifier we're using
|
|
||||||
AREXPORT void setIdentifier(const char *identifier)
|
|
||||||
{ myIdentifier = identifier; }
|
|
||||||
|
|
||||||
/// Enforces the that the server is using this protocol version
|
|
||||||
AREXPORT void enforceProtocolVersion(const char *protocolVersion);
|
|
||||||
/// Enforces that the robots that connect are this type
|
|
||||||
AREXPORT void enforceType(ArServerCommands::Type type);
|
|
||||||
|
|
||||||
/// Gets the config display hint items dependent on the central
|
|
||||||
/// server should use (still check getCentralServerHostName to see
|
|
||||||
/// if it's being used)
|
|
||||||
const char *getConfigDisplayHint(void)
|
|
||||||
{ return myConfigDisplayHint.c_str(); }
|
|
||||||
|
|
||||||
/// The handler for the response to the switch command
|
|
||||||
AREXPORT void clientSwitch(ArNetPacket *packet);
|
|
||||||
/// The handler for the packet to let the server know we're still talking to it
|
|
||||||
AREXPORT void netCentralHeartbeat(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// The handler for the packet that comes from the server so we know
|
|
||||||
/// we're getting these
|
|
||||||
AREXPORT void netCentralServerHeartbeat(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Parses the file for holding the user, password, and server key
|
|
||||||
AREXPORT bool parseFile(const char *fileName);
|
|
||||||
AREXPORT virtual void *runThread(void *arg);
|
|
||||||
|
|
||||||
/// Sets debug logging
|
|
||||||
AREXPORT void setDebugLogging(bool debugLogging = false)
|
|
||||||
{ myDebugLogging = debugLogging; }
|
|
||||||
/// Gets if this is using debug logging
|
|
||||||
AREXPORT bool getDebugLogging(void) { return myDebugLogging; }
|
|
||||||
|
|
||||||
/// Gets the server client the forwarder is using (internal)
|
|
||||||
/**
|
|
||||||
@internal
|
|
||||||
**/
|
|
||||||
AREXPORT ArServerClient* getServerClient(void)
|
|
||||||
{ return myServerClient; }
|
|
||||||
|
|
||||||
/// Adds central server or identifier not passed into the config
|
|
||||||
AREXPORT void addToConfig(const char *configSection,
|
|
||||||
const char *connectName, const char *connectDesc,
|
|
||||||
const char *addressName, const char *addressDesc);
|
|
||||||
|
|
||||||
/// Adds a callback when we switch states while starting
|
|
||||||
AREXPORT void addFailedConnectCB(
|
|
||||||
ArFunctor1<const char *> *functor, int position = 50)
|
|
||||||
{ myFailedConnectCBList.addCallback(functor, position); }
|
|
||||||
/// Removes a callback when we switch to running
|
|
||||||
AREXPORT void remFailedConnectCB(ArFunctor1<const char *> *functor)
|
|
||||||
{ myFailedConnectCBList.remCallback(functor); }
|
|
||||||
|
|
||||||
/// Adds a callback when we switch states while starting
|
|
||||||
AREXPORT void addConnectedCB(
|
|
||||||
ArFunctor1<const char *> *functor, int position = 50)
|
|
||||||
{ myConnectedCBList.addCallback(functor, position); }
|
|
||||||
/// Removes a callback when we switch to running
|
|
||||||
AREXPORT void remConnectedCB(ArFunctor1<const char *> *functor)
|
|
||||||
{ myConnectedCBList.remCallback(functor); }
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
AREXPORT void socketClosed(void);
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArArgumentParser *myParser;
|
|
||||||
std::string myServerDesc;
|
|
||||||
std::string myClientSoftwareDesc;
|
|
||||||
|
|
||||||
ArServerClient *myServerClient;
|
|
||||||
ArTime myLastTcpHeartbeat;
|
|
||||||
ArTime myLastUdpHeartbeat;
|
|
||||||
|
|
||||||
ArFileParser myFileParser;
|
|
||||||
|
|
||||||
bool myServerHasHeartbeat;
|
|
||||||
double myServerHeartbeatTimeout;
|
|
||||||
double myServerUdpHeartbeatTimeout;
|
|
||||||
double myServerBackupTimeout;
|
|
||||||
|
|
||||||
bool fileUserCallback(ArArgumentBuilder *arg);
|
|
||||||
bool filePasswordCallback(ArArgumentBuilder *arg);
|
|
||||||
bool fileServerKeyCallback(ArArgumentBuilder *arg);
|
|
||||||
|
|
||||||
enum State
|
|
||||||
{
|
|
||||||
IDLE, ///< Don't want to connect
|
|
||||||
TRYING_CONNECTION, ///< If we're trying to connect
|
|
||||||
CONNECTING, ///< If we're waiting for the response from the server
|
|
||||||
CONNECTED, ///< If we're connected
|
|
||||||
LOST_CONNECTION ///< If we lost a connection... wait a bit and try again
|
|
||||||
};
|
|
||||||
State myState;
|
|
||||||
ArTime myStartedState;
|
|
||||||
ArTime myLastConnectionAttempt;
|
|
||||||
//bool myGaveTimeWarning;
|
|
||||||
|
|
||||||
bool processFile(void);
|
|
||||||
AREXPORT void switchState(State state);
|
|
||||||
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
|
|
||||||
bool myTryConnection;
|
|
||||||
ArClientBase *myClient;
|
|
||||||
|
|
||||||
std::string myUser;
|
|
||||||
std::string myPassword;
|
|
||||||
std::string myServerKey;
|
|
||||||
|
|
||||||
std::string myCentralServer;
|
|
||||||
int myCentralServerPort;
|
|
||||||
std::string myIdentifier;
|
|
||||||
|
|
||||||
std::string myEnforceProtocolVersion;
|
|
||||||
ArServerCommands::Type myEnforceType;
|
|
||||||
|
|
||||||
bool myConfigFirstProcess;
|
|
||||||
bool myConfigConnectToCentralServer;
|
|
||||||
char myConfigCentralServer[1024];
|
|
||||||
char myConfigIdentifier[1024];
|
|
||||||
std::string myConfigDisplayHint;
|
|
||||||
|
|
||||||
ArCallbackList1<const char *> myFailedConnectCBList;
|
|
||||||
ArCallbackList1<const char *> myConnectedCBList;
|
|
||||||
|
|
||||||
bool myDebugLogging;
|
|
||||||
|
|
||||||
ArRetFunctorC<bool, ArClientSwitchManager> myParseArgsCB;
|
|
||||||
ArConstFunctorC<ArClientSwitchManager> myLogOptionsCB;
|
|
||||||
ArFunctorC<ArClientSwitchManager> mySocketClosedCB;
|
|
||||||
ArFunctor1C<ArClientSwitchManager, ArNetPacket *> mySwitchCB;
|
|
||||||
ArFunctor2C<ArClientSwitchManager, ArServerClient *,
|
|
||||||
ArNetPacket *> myNetCentralHeartbeatCB;
|
|
||||||
ArFunctor2C<ArClientSwitchManager, ArServerClient *,
|
|
||||||
ArNetPacket *> myNetCentralServerHeartbeatCB;
|
|
||||||
ArRetFunctor1C<bool, ArClientSwitchManager,
|
|
||||||
ArArgumentBuilder *> myFileUserCB;
|
|
||||||
ArRetFunctor1C<bool, ArClientSwitchManager,
|
|
||||||
ArArgumentBuilder *> myFilePasswordCB;
|
|
||||||
ArRetFunctor1C<bool, ArClientSwitchManager,
|
|
||||||
ArArgumentBuilder *> myFileServerKeyCB;
|
|
||||||
ArRetFunctorC<bool, ArClientSwitchManager> myProcessFileCB;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ARCLIENTSWITCH_H
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
|||||||
#ifndef ARHYBRIDFORWARDERVIDEO_H
|
|
||||||
#define ARHYBRIDFORWARDERVIDEO_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
#include "ArClientBase.h"
|
|
||||||
|
|
||||||
/// This class takes video another source and serves it back up
|
|
||||||
class ArHybridForwarderVideo : public ArCameraCollectionItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor that takes a client
|
|
||||||
AREXPORT ArHybridForwarderVideo(ArServerBase *server, ArClientBase *client);
|
|
||||||
/// Constructor that just takes a host and port and makes its own client
|
|
||||||
AREXPORT ArHybridForwarderVideo(ArServerBase *server,
|
|
||||||
const char *hostname = "localhost",
|
|
||||||
int port = 7070);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArHybridForwarderVideo();
|
|
||||||
|
|
||||||
/// Returns if we're forwarding video or not
|
|
||||||
AREXPORT bool isForwardingVideo(void) const;
|
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
// ArCameraCollectionItem methods
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/// Returns the name of the camera handled by this item.
|
|
||||||
AREXPORT virtual const char *getCameraName();
|
|
||||||
|
|
||||||
/// Sets the name of the camera handled by this item.
|
|
||||||
/**
|
|
||||||
* This method must be called before addToCameraCollection().
|
|
||||||
**/
|
|
||||||
AREXPORT virtual void setCameraName(const char *cameraName);
|
|
||||||
|
|
||||||
/// Adds this item to the given camera collection.
|
|
||||||
AREXPORT virtual void addToCameraCollection(ArCameraCollection &collection);
|
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
// Packet methods
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/// Sends the last received video size (just gets this once)
|
|
||||||
AREXPORT void sendVideoSize(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// Sends the last received video
|
|
||||||
AREXPORT void sendVideo(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// Receives the video size (just gets this once)
|
|
||||||
AREXPORT void receiveVideoSize(ArNetPacket *packet);
|
|
||||||
/// Receives the video (and sets a timer to wait a bit and get it again)
|
|
||||||
AREXPORT void receiveVideo(ArNetPacket *packet);
|
|
||||||
/// Our callback that requests more video
|
|
||||||
AREXPORT void clientCycleCallback(void);
|
|
||||||
/// Sets how often after getting video we ask for it again
|
|
||||||
void setVideoRequestTime(int ms) { myVideoRequestTime = ms; }
|
|
||||||
/// Gets how often after getting video we ask for it again
|
|
||||||
int setVideoRequestTime(void) const { return myVideoRequestTime; }
|
|
||||||
protected:
|
|
||||||
AREXPORT void finishConstructor(void);
|
|
||||||
|
|
||||||
std::string myCameraName;
|
|
||||||
|
|
||||||
ArMutex myMutex;
|
|
||||||
bool myForwardingVideo;
|
|
||||||
ArNetPacket myReceivedVideoSize;
|
|
||||||
ArNetPacket myReceivedVideo;
|
|
||||||
ArNetPacket mySendVideoArgument;
|
|
||||||
ArTime myLastReceivedVideo;
|
|
||||||
ArTime myLastReqSent;
|
|
||||||
bool myReqSent;
|
|
||||||
int myVideoRequestTime;
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArClientBase *myClient;
|
|
||||||
ArFunctor2C<ArHybridForwarderVideo, ArServerClient*,
|
|
||||||
ArNetPacket *> *mySendVideoSizeCB;
|
|
||||||
ArFunctor2C<ArHybridForwarderVideo, ArServerClient*,
|
|
||||||
ArNetPacket *> *mySendVideoCB;
|
|
||||||
ArFunctor1C<ArHybridForwarderVideo, ArNetPacket *> *myReceiveVideoSizeCB;
|
|
||||||
ArFunctor1C<ArHybridForwarderVideo, ArNetPacket *> *myReceiveVideoCB;
|
|
||||||
ArFunctorC<ArHybridForwarderVideo> *myClientCycleCB;
|
|
||||||
|
|
||||||
bool myIsSendVideoAvailable;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,557 +0,0 @@
|
|||||||
#ifndef ARMAPCHANGER_H
|
|
||||||
#define ARMAPCHANGER_H
|
|
||||||
|
|
||||||
#include "ariaTypedefs.h"
|
|
||||||
#include "ariaUtil.h"
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include <ArMapInterface.h>
|
|
||||||
#include <ArMapUtils.h>
|
|
||||||
#include <ArMutex.h>
|
|
||||||
|
|
||||||
#include "ArNetPacket.h"
|
|
||||||
#include "ArCentralForwarder.h"
|
|
||||||
#include "ArClientBase.h"
|
|
||||||
#include "ArClientSwitchManager.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
#include "ArServerClient.h"
|
|
||||||
#include "ArMapChanger.h"
|
|
||||||
|
|
||||||
/// Utility class used to apply incremental changes to an Aria map.
|
|
||||||
/**
|
|
||||||
* ArMapChanger is a helper class that can send and receive ArMapChangeDetails
|
|
||||||
* over the network and apply them to an associated Aria map. An instance of
|
|
||||||
* ArMapChanger must be instantiated on both the client and the server side.
|
|
||||||
* (Note that there are two different versions of the constructors for this.)
|
|
||||||
*
|
|
||||||
* TODO: Possibly subclass this into ArClientMapChanger and ArServerMapChanger?
|
|
||||||
*
|
|
||||||
* @see ArMapChangeDetails
|
|
||||||
**/
|
|
||||||
class ArMapChanger
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Reply status for a map change request
|
|
||||||
enum MapChangeReplyType {
|
|
||||||
CHANGE_FAILED = 0,
|
|
||||||
CHANGE_SUCCESS = 10
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Name of the network packet that contains the incremental map changes.
|
|
||||||
static const char *PROCESS_CHANGES_PACKET_NAME;
|
|
||||||
|
|
||||||
/// Name of the network packet that contains incremental map changes originated by the robot.
|
|
||||||
static const char *PROCESS_ROBOT_CHANGES_PACKET_NAME;
|
|
||||||
|
|
||||||
/// Name of a network packet that is broadcast when the map is being changed.
|
|
||||||
static const char *CHANGES_IN_PROGRESS_PACKET_NAME;
|
|
||||||
|
|
||||||
/// Name of the network packet that is broadcast when map changes originated by the robot are complete.
|
|
||||||
static const char *ROBOT_CHANGES_COMPLETE_PACKET_NAME;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Constructors, Destructor
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Constructs a server map changer.
|
|
||||||
/**
|
|
||||||
* The map changer will automatically apply the received map change details
|
|
||||||
* to the given map.
|
|
||||||
*
|
|
||||||
* @param server the ArServerBase * that receives the network packets
|
|
||||||
* @param map the ArMapInterface * to which to apply the map changes
|
|
||||||
**/
|
|
||||||
AREXPORT ArMapChanger(ArServerBase *server,
|
|
||||||
ArMapInterface *map);
|
|
||||||
|
|
||||||
/// Constructs a server map changer that can also originate changes (to the EM).
|
|
||||||
/**
|
|
||||||
* The map changer will automatically apply the received map change details
|
|
||||||
* to the given map.
|
|
||||||
*
|
|
||||||
* @param clientSwitch the ArClientSwitchManager * that communicates to the EM
|
|
||||||
* @param server the ArServerBase * that receives the network packets
|
|
||||||
* @param map the ArMapInterface * to which to apply the map changes
|
|
||||||
**/
|
|
||||||
AREXPORT ArMapChanger(ArClientSwitchManager *clientSwitch,
|
|
||||||
ArServerBase *server,
|
|
||||||
ArMapInterface *map);
|
|
||||||
|
|
||||||
|
|
||||||
/// Constructs a client map changer.
|
|
||||||
/**
|
|
||||||
* The map changer will send map change details to the server. The application
|
|
||||||
* must request this by calling sendMapChanges.
|
|
||||||
*
|
|
||||||
* @param client the ArClientBase * which is used to send the map change details
|
|
||||||
* @param infoNames the list of info names included in the map
|
|
||||||
**/
|
|
||||||
AREXPORT ArMapChanger(ArClientBase *client,
|
|
||||||
const std::list<std::string> &infoNames);
|
|
||||||
|
|
||||||
/// Constructs a stand-alone map changer that will apply changes to the given map.
|
|
||||||
/**
|
|
||||||
* This method is primarily used for debugging.
|
|
||||||
*
|
|
||||||
* @param map the ArMapInterface * to which to apply the map changes
|
|
||||||
**/
|
|
||||||
AREXPORT ArMapChanger(ArMapInterface *map);
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArMapChanger();
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Main Methods
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Sends the given map changes from the client to the server.
|
|
||||||
AREXPORT virtual bool sendMapChanges(ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Sends the given map changes from the robot to the central server.
|
|
||||||
AREXPORT virtual bool sendRobotMapChanges(ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Applies the given map changes received from the client to the associated Aria map.
|
|
||||||
AREXPORT virtual bool applyMapChanges(ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Transmits the given map change packet list from the client to the server.
|
|
||||||
AREXPORT virtual bool sendPacketList(const std::list<ArNetPacket *> &packetList);
|
|
||||||
|
|
||||||
/// Transmit the given map change packet list from the robot to the central server.
|
|
||||||
AREXPORT virtual bool sendRobotPacketList(const std::list<ArNetPacket *> &packetList);
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Callback Methods
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Adds a callback to be invoked after the map has been changed on the server.
|
|
||||||
/**
|
|
||||||
* This method is primarily used on the central server. After the map changes
|
|
||||||
* are successfully applied to its map, they are propagated to all of the
|
|
||||||
* connected robots.
|
|
||||||
**/
|
|
||||||
AREXPORT virtual bool addChangeCB
|
|
||||||
(ArFunctor2<ArServerClient *,
|
|
||||||
std::list<ArNetPacket *> *> *functor);
|
|
||||||
|
|
||||||
/// Removes a callback from the map change list.
|
|
||||||
AREXPORT virtual bool remChangeCB
|
|
||||||
(ArFunctor2<ArServerClient *,
|
|
||||||
std::list<ArNetPacket *> *> *functor);
|
|
||||||
|
|
||||||
/// Adds a callback to be invoked after the remote reply has been received.
|
|
||||||
/**
|
|
||||||
* This method is primarily used on the robot. After the ARCL originated
|
|
||||||
* changes have been applied by the Enterprise Manager, this callback list
|
|
||||||
* is invoked for other interested parties.
|
|
||||||
**/
|
|
||||||
AREXPORT virtual bool addRobotChangeReplyCB
|
|
||||||
(ArFunctor2<ArServerClient *, ArNetPacket *> *functor);
|
|
||||||
|
|
||||||
/// Removes a callback from the remote reply list.
|
|
||||||
AREXPORT virtual bool remRobotChangeReplyCB
|
|
||||||
(ArFunctor2<ArServerClient *, ArNetPacket *> *functor);
|
|
||||||
|
|
||||||
/// Adds a callback to be invoked before the map file is written.
|
|
||||||
/**
|
|
||||||
* This method is primarily used to temporarily make the server's directory
|
|
||||||
* writeable, if necessary.
|
|
||||||
**/
|
|
||||||
AREXPORT virtual void addPreWriteFileCB(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
|
|
||||||
/// Removes a callback from the pre-write file list.
|
|
||||||
AREXPORT virtual void remPreWriteFileCB(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Adds a callback to be invoked after the map file has been written.
|
|
||||||
/**
|
|
||||||
* This method is primarily used to restore the server's directory write status,
|
|
||||||
* if necessary.
|
|
||||||
**/
|
|
||||||
AREXPORT virtual void addPostWriteFileCB(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
|
|
||||||
/// Removes a callback from the post-write file list.
|
|
||||||
AREXPORT virtual void remPostWriteFileCB(ArFunctor *functor);
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// Indicates the current stage of the map change network packets.
|
|
||||||
enum MapChangeCommand {
|
|
||||||
START_CHANGES = 0, ///< First packet that contains changes to be applied to the map
|
|
||||||
CONTINUE_CHANGES = 1, ///< Request to continue applying changes to the map
|
|
||||||
FINISH_CHANGES = 2, ///< Last packet that contains changes to be applied to the map
|
|
||||||
CANCEL_CHANGES = 3, ///< Cancel the request to change the map
|
|
||||||
LAST_CHANGE_COMMAND = CANCEL_CHANGES ///< Last value in the enumeration
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Type of data contained in the map change network packet
|
|
||||||
enum MapChangeDataType {
|
|
||||||
NO_CHANGE = 0, ///< No change data
|
|
||||||
SUMMARY_DATA = 1, ///< Summary data, e.g. min/max pos, number of points
|
|
||||||
INFO_DATA = 2, ///< Any of the info data, e.g. MapInfo, RouteInfo
|
|
||||||
SUPPLEMENT_DATA = 3, ///< Miscellaneous supplemental data such as origin lat/long/alt
|
|
||||||
OBJECTS_DATA = 4, ///< Map objects, i.e. Cairn lines
|
|
||||||
POINTS_DATA = 5, ///< Map data points
|
|
||||||
LINES_DATA = 6, ///< Map data lines
|
|
||||||
LAST_CHANGE_DATA_TYPE = LINES_DATA ///< Last value in the enumeration
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Miscellaneous constants
|
|
||||||
enum {
|
|
||||||
CHANGE_DATA_TYPE_COUNT = LAST_CHANGE_DATA_TYPE + 1,
|
|
||||||
CHANGE_COMMAND_COUNT = LAST_CHANGE_COMMAND + 1,
|
|
||||||
MAX_POINTS_IN_PACKET = 1000,
|
|
||||||
MAX_LINES_IN_PACKET = 500
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Packet Handlers
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Server handler for packets that contain map change details.
|
|
||||||
AREXPORT virtual void handleChangePacket(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
AREXPORT virtual void handleRobotChangeReplyPacket(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Client handler for the results of applying the map changes on the server.
|
|
||||||
AREXPORT virtual void handleChangeReplyPacket(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Client handler for the map-changes-in-progress broadcast packet
|
|
||||||
AREXPORT virtual void handleChangesInProgressPacket(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Client handler for the server's idle-processing-pending broadcast packet
|
|
||||||
AREXPORT virtual void handleIdleProcessingPacket(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Client handler for when the robot disconnects or is shutdown.
|
|
||||||
AREXPORT virtual void handleClientShutdown();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Helper Methods
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// bool applyMapChanges(std::list<ArNetPacket*> &packetList);
|
|
||||||
|
|
||||||
/// Applies all scan data changes that are contained in the given change details.
|
|
||||||
/**
|
|
||||||
* Scan data include summary data, map data points, and map data lines.
|
|
||||||
* If the map contains scan data for multiple sources, then this method
|
|
||||||
* applies all of the applicable changes.
|
|
||||||
*
|
|
||||||
* An Aria map must have been previously associated with the map changer.
|
|
||||||
**/
|
|
||||||
bool applyScanChanges(ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Applies scan data changes for the specified scan type.
|
|
||||||
/**
|
|
||||||
* @param changeDetails the ArMapChangeDetails * that describes how the map should
|
|
||||||
* be modified; must be non-NULL
|
|
||||||
* @param scanType the char * identifier of the scan type to be updated
|
|
||||||
* @param parser the ArFileParser used to parse the changeDetails
|
|
||||||
**/
|
|
||||||
bool applyScanChanges(ArMapChangeDetails *changeDetails,
|
|
||||||
const char *scanType,
|
|
||||||
ArFileParser &parser);
|
|
||||||
|
|
||||||
/// Applies the given map changes to the supplemental data in the map.
|
|
||||||
/**
|
|
||||||
* @param changeDetails the ArMapChangeDetails * that describes how the map should
|
|
||||||
* be modified; must be non-NULL
|
|
||||||
**/
|
|
||||||
bool applySupplementChanges(ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Applies the given map changes to the object data in the map.
|
|
||||||
/**
|
|
||||||
* @param changeDetails the ArMapChangeDetails * that describes how the map should
|
|
||||||
* be modified; must be non-NULL
|
|
||||||
**/
|
|
||||||
bool applyObjectChanges(ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Applies the given map changes to the info data in the map.
|
|
||||||
/**
|
|
||||||
* @param changeDetails the ArMapChangeDetails * that describes how the map should
|
|
||||||
* be modified; must be non-NULL
|
|
||||||
**/
|
|
||||||
bool applyInfoChanges(ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Determines whether the two given map objects are the same object.
|
|
||||||
/**
|
|
||||||
* If the objects have a name, then the name must be identical. Otherwise, the type
|
|
||||||
* and position must be the same.
|
|
||||||
**/
|
|
||||||
bool isMatchingObjects(ArMapObject *obj1,
|
|
||||||
ArMapObject *obj2);
|
|
||||||
//ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Creates a list of network packets for the given map change details.
|
|
||||||
bool convertChangeDetailsToPacketList(ArMapChangeDetails *changeDetails,
|
|
||||||
std::list<ArNetPacket *> *packetListOut,
|
|
||||||
bool isRelay = false);
|
|
||||||
|
|
||||||
/// Unpacks the given network packet list and populates the given map change details.
|
|
||||||
bool convertPacketListToChangeDetails(std::list<ArNetPacket *> &packetList,
|
|
||||||
ArMapChangeDetails *changeDetailsOut);
|
|
||||||
|
|
||||||
/// Creates network packets for the specified map change data and adds them to the given list.
|
|
||||||
/**
|
|
||||||
* @param dataType the MapChangeDataType that specifies which map data is to be added
|
|
||||||
* @param changeType the MapLineChangeType that specifies the type of map change (lines
|
|
||||||
* added or deleted)
|
|
||||||
* @param scanType the char * identifier of the scan source to add; valid only when
|
|
||||||
* dataType is SUMMARY_DATA
|
|
||||||
* @param extra an optional const char * identifier that clarifies which data to add;
|
|
||||||
* when dataType is INFO_DATA, this is the info name; otherwise, ignored
|
|
||||||
* @param fileLineSet the ArMapFileLineSet * component of the map change details that
|
|
||||||
* is to be converted to network packets
|
|
||||||
* @param packetListOut the list of ArNetPackets to which new packets are added
|
|
||||||
**/
|
|
||||||
bool addFileLineSetPackets(MapChangeDataType dataType,
|
|
||||||
ArMapChangeDetails::MapLineChangeType changeType,
|
|
||||||
const char *scanType,
|
|
||||||
const char *extra,
|
|
||||||
ArMapFileLineSet *fileLineSet,
|
|
||||||
std::list<ArNetPacket *> *packetListOut);
|
|
||||||
|
|
||||||
/// Inserts header information into the given network packet.
|
|
||||||
/**
|
|
||||||
* @param command the MapChangeCommand that specifies which command identifier to add to this packet
|
|
||||||
* @param dataType the MapChangeDataType that specifies which map data is to be added
|
|
||||||
* @param changeType the MapLineChangeType that specifies the type of map change (lines
|
|
||||||
* added or deleted)
|
|
||||||
* @param scanType the char * identifier of the scan source to add; valid only when
|
|
||||||
* dataType is SUMMARY_DATA
|
|
||||||
* @param packet the ArNetPacket * to be modified; must be non-NULL
|
|
||||||
**/
|
|
||||||
void addHeaderToPacket(MapChangeCommand command,
|
|
||||||
MapChangeDataType dataType,
|
|
||||||
ArMapChangeDetails::MapLineChangeType changeType,
|
|
||||||
const char *scanType,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Creates network packets for the specified file line group and adds them to the given list.
|
|
||||||
bool addGroupToPacketList(MapChangeDataType dataType,
|
|
||||||
ArMapChangeDetails::MapLineChangeType changeType,
|
|
||||||
const char *scanType,
|
|
||||||
ArMapFileLineGroup &group,
|
|
||||||
std::list<ArNetPacket *> *packetListOut);
|
|
||||||
|
|
||||||
/// Creates network packets for the specified file line and adds them to the given list.
|
|
||||||
bool addFileLineToPacketList(MapChangeDataType dataType,
|
|
||||||
ArMapChangeDetails::MapLineChangeType changeType,
|
|
||||||
const char *scanType,
|
|
||||||
const ArMapFileLine &fileLine,
|
|
||||||
std::list<ArNetPacket *> *packetListOut);
|
|
||||||
|
|
||||||
/// Creates network packets for the given map data points and adds them to the given list.
|
|
||||||
bool addPointsPackets(ArMapChangeDetails::MapLineChangeType changeType,
|
|
||||||
const char *scanType,
|
|
||||||
std::vector<ArPose> *pointList,
|
|
||||||
std::list<ArNetPacket *> *packetListOut);
|
|
||||||
|
|
||||||
/// Creates network packets for the given map data lines and adds them to the given list.
|
|
||||||
bool addLinesPackets(ArMapChangeDetails::MapLineChangeType changeType,
|
|
||||||
const char *scanType,
|
|
||||||
std::vector<ArLineSegment> *lineSegmentList,
|
|
||||||
std::list<ArNetPacket *> *packetListOut);
|
|
||||||
|
|
||||||
/// Unpacks the header data from the given network packet.
|
|
||||||
/**
|
|
||||||
* @param packet the ArNetPacket * from which to extract the header information;
|
|
||||||
* must be non-NULL
|
|
||||||
* @param commandOut the MapChangeCommand * extracted from the packet
|
|
||||||
* @param origMapIdOut the original ArMapId * extracted from the packet
|
|
||||||
* @param newMapIdOut the optional new ArMapId * extracted from the packet
|
|
||||||
* @param dataTypeOut the optional MapChangeDataType * extracted from the packet
|
|
||||||
* @param changeTypeOut the optional MapLineChangeType * extracted from the packet
|
|
||||||
* @param scanTypeOut the optional std::string * extracted from the packet
|
|
||||||
* @return bool true if all of the header information was succesfully extracted;
|
|
||||||
* false, otherwise
|
|
||||||
**/
|
|
||||||
bool unpackHeader(ArNetPacket *packet,
|
|
||||||
MapChangeCommand *commandOut,
|
|
||||||
ArMapId *origMapIdOut,
|
|
||||||
ArMapId *newMapIdOut = NULL,
|
|
||||||
MapChangeDataType *dataTypeOut = NULL,
|
|
||||||
ArMapChangeDetails::MapLineChangeType *changeTypeOut = NULL,
|
|
||||||
std::string *scanTypeOut = NULL);
|
|
||||||
|
|
||||||
/// Unpacks the specified file line set from the given network packet.
|
|
||||||
/**
|
|
||||||
* The file line set is added to the given change details.
|
|
||||||
**/
|
|
||||||
bool unpackFileLineSet(ArNetPacket *packet,
|
|
||||||
MapChangeDataType dataType,
|
|
||||||
ArMapChangeDetails::MapLineChangeType changeType,
|
|
||||||
const char *scanType,
|
|
||||||
int *numGroups,
|
|
||||||
int *numChildren,
|
|
||||||
ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Unpacks the map data points for the specified scan from the given network packet.
|
|
||||||
/**
|
|
||||||
* The data points are added to the given change details.
|
|
||||||
**/
|
|
||||||
bool unpackPoints(ArNetPacket *packet,
|
|
||||||
ArMapChangeDetails::MapLineChangeType changeType,
|
|
||||||
const char *scanType,
|
|
||||||
int *numPoints,
|
|
||||||
ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Unpacks the map data lines for the specified scan from the given network packet.
|
|
||||||
/**
|
|
||||||
* The data lines are added to the given change details.
|
|
||||||
**/
|
|
||||||
bool unpackLines(ArNetPacket *packet,
|
|
||||||
ArMapChangeDetails::MapLineChangeType changeType,
|
|
||||||
const char *scanType,
|
|
||||||
int *numLines,
|
|
||||||
ArMapChangeDetails *changeDetails);
|
|
||||||
|
|
||||||
/// Resets all of the network packets in the given list so that they can be read again.
|
|
||||||
void resetPacketList(std::list<ArNetPacket*> *packetList);
|
|
||||||
|
|
||||||
/// Waits for a reply from the server.
|
|
||||||
/**
|
|
||||||
* If a reply is not received within 30 seconds, this method will timeout and return
|
|
||||||
* false.
|
|
||||||
*
|
|
||||||
* @return bool true if the reply was received; false otherwise
|
|
||||||
**/
|
|
||||||
bool waitForReply(ArTime &started);
|
|
||||||
|
|
||||||
bool waitForCentralServerReply(ArTime &started);
|
|
||||||
|
|
||||||
/// Determines whether idle processing is pending on the server.
|
|
||||||
bool isIdleProcessingPending();
|
|
||||||
|
|
||||||
/// Adds the given functor to the given callback list.
|
|
||||||
AREXPORT void addToCallbackList(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position,
|
|
||||||
std::list<ArFunctor*> *cbList);
|
|
||||||
|
|
||||||
/// Removes the given functor from the given callback list.
|
|
||||||
AREXPORT void remFromCallbackList(ArFunctor *functor,
|
|
||||||
std::list<ArFunctor*> *cbList);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Disabled copy constructor
|
|
||||||
ArMapChanger(const ArMapChanger &other);
|
|
||||||
|
|
||||||
/// Disabled assignment operator
|
|
||||||
ArMapChanger &operator=(const ArMapChanger &other);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// Accumulates the packet list that describes map changes received from a specified client.
|
|
||||||
struct ClientChangeInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor for changes received from a client
|
|
||||||
ClientChangeInfo(ArServerClient *client);
|
|
||||||
|
|
||||||
/// Constructor for changes received from a robot on the CS
|
|
||||||
ClientChangeInfo(ArCentralForwarder *forwarder);
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
~ClientChangeInfo();
|
|
||||||
|
|
||||||
/// Adds the given packet to the list
|
|
||||||
void addPacket(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Server client which sent the map changes...
|
|
||||||
ArServerClient *myClient;
|
|
||||||
|
|
||||||
/// Or the forwarder that sent the map changes
|
|
||||||
ArCentralForwarder *myForwarder;
|
|
||||||
|
|
||||||
/// Time at which the first packet in this list was received
|
|
||||||
ArTime myStartTime;
|
|
||||||
/// Time at which the most recent packet in this list was received
|
|
||||||
ArTime myLastActivityTime;
|
|
||||||
/// List of network packets received from the client for these map changes
|
|
||||||
std::list<ArNetPacket *> myPacketList;
|
|
||||||
}; // end struct ClientChangeInfo
|
|
||||||
|
|
||||||
|
|
||||||
/// Aria map currently in use
|
|
||||||
ArMapInterface *myMap;
|
|
||||||
/// Copy of the current Aria map, used to make sure the changes can be successfully made
|
|
||||||
ArMapInterface *myWorkingMap;
|
|
||||||
|
|
||||||
/// Change details to apply to the Aria map
|
|
||||||
ArMapChangeDetails *myChangeDetails;
|
|
||||||
/// Number of info types in the associated Aria map
|
|
||||||
//int myInfoCount;
|
|
||||||
|
|
||||||
/// List of info types in the associated info map
|
|
||||||
std::list<std::string> myInfoNames;
|
|
||||||
|
|
||||||
/// Associated server base; non-NULL only when changer instantiated on the server
|
|
||||||
ArServerBase *myServer;
|
|
||||||
|
|
||||||
/// Associated client switch manager; non-NULL when changer instantiated on robot with EM
|
|
||||||
ArClientSwitchManager *myClientSwitch;
|
|
||||||
|
|
||||||
/// Whether the client switch manager's serverClient has been initialized with a handler (for EM)
|
|
||||||
bool myIsServerClientInit;
|
|
||||||
|
|
||||||
|
|
||||||
/// Mutex that protects access to the myClient member
|
|
||||||
ArMutex myClientMutex;
|
|
||||||
/// Associated client base; non-NULL only when changer instantiated on the client
|
|
||||||
ArClientBase *myClient;
|
|
||||||
|
|
||||||
/// Mutex that protects access to the myClientInfo member
|
|
||||||
ArMutex myClientInfoMutex;
|
|
||||||
/// Information regarding the server client that is currently sending map changes
|
|
||||||
ClientChangeInfo *myClientInfo;
|
|
||||||
|
|
||||||
/// Mutex that protects access to the interleave data
|
|
||||||
ArMutex myInterleaveMutex;
|
|
||||||
/// Whether the client is ready to send another packet
|
|
||||||
bool myReadyForNextPacket;
|
|
||||||
/// Whether the client is waiting for a reply from the server
|
|
||||||
bool myIsWaitingForReturn;
|
|
||||||
|
|
||||||
/// Mutex that protects access to the myIsIdleProcessingPending member
|
|
||||||
ArMutex myIdleProcessingMutex;
|
|
||||||
/// Whether the server has data to process once it becomes idle
|
|
||||||
bool myIsIdleProcessingPending;
|
|
||||||
|
|
||||||
/// List of callbacks to be invoked before the changed map file is written
|
|
||||||
std::list<ArFunctor*> myPreWriteCBList;
|
|
||||||
/// List of callbacks to be invoked after the changed map file is written
|
|
||||||
std::list<ArFunctor*> myPostWriteCBList;
|
|
||||||
|
|
||||||
/// List of server client callbacks to be invoked after the map has been changed
|
|
||||||
std::list< ArFunctor2<ArServerClient *, std::list<ArNetPacket *> *> *>
|
|
||||||
myChangeCBList;
|
|
||||||
|
|
||||||
/// List of server client callbacks to be invoked after the map has been changed
|
|
||||||
std::list< ArFunctor2<ArServerClient *, ArNetPacket *> *> myRobotChangeReplyCBList;
|
|
||||||
|
|
||||||
/// Server handler for the network packets that describe map changes.
|
|
||||||
ArFunctor2C<ArMapChanger, ArServerClient *, ArNetPacket *> myHandleChangePacketCB;
|
|
||||||
|
|
||||||
ArFunctor2C<ArMapChanger, ArServerClient *, ArNetPacket *> myHandleRobotReplyPacketCB;
|
|
||||||
|
|
||||||
/// Client handler for the map-changes-in-progress packet
|
|
||||||
ArFunctor1C<ArMapChanger, ArNetPacket *> myHandleChangesInProgressPacketCB;
|
|
||||||
/// Client handler for the reply packet
|
|
||||||
ArFunctor1C<ArMapChanger, ArNetPacket *> myHandleReplyPacketCB;
|
|
||||||
/// Client handler for the idle-processing-in-progress packet
|
|
||||||
ArFunctor1C<ArMapChanger, ArNetPacket *> myHandleIdleProcessingPacketCB;
|
|
||||||
/// Handler invoked when the client shuts down
|
|
||||||
ArFunctorC<ArMapChanger> myClientShutdownCB;
|
|
||||||
|
|
||||||
}; // end class ArMapChanger
|
|
||||||
|
|
||||||
#endif // ARMAPCHANGER
|
|
@ -1,84 +0,0 @@
|
|||||||
#ifndef NLNETPACKET_H
|
|
||||||
#define NLNETPACKET_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
|
|
||||||
/// our packet for the network stuff
|
|
||||||
class ArNetPacket : public ArBasePacket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArNetPacket(
|
|
||||||
ArTypes::UByte2 bufferSize = ArNetPacket::MAX_LENGTH + 5);
|
|
||||||
|
|
||||||
/// Copy constructor
|
|
||||||
AREXPORT ArNetPacket(const ArNetPacket &other);
|
|
||||||
|
|
||||||
/// Assignment operator
|
|
||||||
AREXPORT ArNetPacket &operator=(const ArNetPacket &other);
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArNetPacket();
|
|
||||||
|
|
||||||
|
|
||||||
/// Sets the command this packet is
|
|
||||||
AREXPORT void setCommand(ArTypes::UByte2 command);
|
|
||||||
/// Gets the command this packet is
|
|
||||||
AREXPORT ArTypes::UByte2 getCommand(void);
|
|
||||||
enum {
|
|
||||||
SIZE_OF_LENGTH = 2, ///< Number of bytes needed to store packet length value
|
|
||||||
MAX_LENGTH = 32000, ///< Suggested maximum total size of a packet (bytes)
|
|
||||||
HEADER_LENGTH = 6, ///< Bytes of packet data used for header
|
|
||||||
FOOTER_LENGTH = 2, ///< Byset of packet data used for footer
|
|
||||||
|
|
||||||
/** Suggested maximum size for data payload (this is the total suggested
|
|
||||||
packet size minus headers and footers)
|
|
||||||
*/
|
|
||||||
MAX_DATA_LENGTH = MAX_LENGTH - HEADER_LENGTH - FOOTER_LENGTH - SIZE_OF_LENGTH
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Puts a double into the packet buffer
|
|
||||||
AREXPORT virtual void doubleToBuf(double val);
|
|
||||||
/// Gets a double from the packet buffer
|
|
||||||
AREXPORT virtual double bufToDouble(void);
|
|
||||||
AREXPORT virtual void empty(void);
|
|
||||||
AREXPORT virtual void finalizePacket(void);
|
|
||||||
AREXPORT virtual void resetRead(void);
|
|
||||||
AREXPORT virtual void duplicatePacket(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// returns true if the checksum matches what it should be
|
|
||||||
AREXPORT bool verifyCheckSum(void);
|
|
||||||
/// returns the checksum, probably used only internally
|
|
||||||
AREXPORT ArTypes::Byte2 calcCheckSum(void);
|
|
||||||
|
|
||||||
/// Iternal function that sets if we already added the footer(for forwarding)
|
|
||||||
bool getAddedFooter(void) { return myAddedFooter; }
|
|
||||||
/// Iternal function that sets if we already added the footer(for forwarding)
|
|
||||||
void setAddedFooter(bool addedFooter) { myAddedFooter = addedFooter; }
|
|
||||||
|
|
||||||
/// an enum for where the packet came from
|
|
||||||
enum PacketSource
|
|
||||||
{
|
|
||||||
TCP, ///< Came in over tcp
|
|
||||||
UDP ///< Came in over udp
|
|
||||||
};
|
|
||||||
PacketSource getPacketSource(void) { return myPacketSource; }
|
|
||||||
void setPacketSource(PacketSource source) { myPacketSource = source; }
|
|
||||||
void setArbitraryString(const char *string) { myArbitraryString = string; }
|
|
||||||
const char *getArbitraryString(void) { return myArbitraryString.c_str(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/// Inserts the header information (command, length, etc.) into the buffer.
|
|
||||||
void insertHeader();
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
PacketSource myPacketSource;
|
|
||||||
bool myAddedFooter;
|
|
||||||
std::string myArbitraryString;
|
|
||||||
ArTypes::UByte2 myCommand;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,79 +0,0 @@
|
|||||||
#ifndef NLNETPACKETRECEIVERTCP_H
|
|
||||||
#define NLNETPACKETRECEIVERTCP_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArNetPacket.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
This class receives TCP packets from a socket, you need to have an
|
|
||||||
open socket and give it to the socket with setSocket, then you need
|
|
||||||
to set up a callback to process packets with setProcessPacketCB,
|
|
||||||
finally call readData which will read in all the data and call the
|
|
||||||
processPacketCB.
|
|
||||||
**/
|
|
||||||
class ArNetPacketReceiverTcp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArNetPacketReceiverTcp();
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT ~ArNetPacketReceiverTcp();
|
|
||||||
|
|
||||||
/// Sets the socket this receiver uses
|
|
||||||
AREXPORT void setSocket(ArSocket *socket);
|
|
||||||
/// Gets the socket this receiver uses
|
|
||||||
AREXPORT ArSocket *getSocket(void);
|
|
||||||
|
|
||||||
/// Sets the callback for use when a packet is received
|
|
||||||
AREXPORT void setProcessPacketCB(ArFunctor1<ArNetPacket *> *functor);
|
|
||||||
|
|
||||||
/// Gets the callback used when a packet is received
|
|
||||||
AREXPORT ArFunctor1<ArNetPacket *> *getProcessPacketCB(void);
|
|
||||||
|
|
||||||
/// Sets the logging prefix
|
|
||||||
AREXPORT void setLoggingPrefix(const char *loggingPrefix);
|
|
||||||
|
|
||||||
/// Reads in all the data available calling the processPacketCB
|
|
||||||
AREXPORT bool readData(void);
|
|
||||||
|
|
||||||
/// Sets whether we're quiet about errors or not
|
|
||||||
void setQuiet(bool quiet) { myQuiet = quiet; }
|
|
||||||
/// Gets whether we're quiet about errors or not
|
|
||||||
bool getQuiet(void) { return myQuiet; }
|
|
||||||
protected:
|
|
||||||
enum Ret {
|
|
||||||
RET_CONN_CLOSED, // the connection was closed (in a good manner)
|
|
||||||
RET_CONN_ERROR, // the connection was has an error (so close it)
|
|
||||||
RET_GOT_PACKET, // we got a good packet
|
|
||||||
RET_BAD_PACKET, // we got a bad packet (checksum wrong)
|
|
||||||
RET_FAILED_READ, // our read failed (no data)
|
|
||||||
RET_TIMED_OUT}; // we were reading and timed out
|
|
||||||
/// Reads in a single packet, returns NULL if not one
|
|
||||||
AREXPORT Ret readPacket(int msWait);
|
|
||||||
|
|
||||||
|
|
||||||
enum State { STATE_SYNC1, STATE_SYNC2, STATE_LENGTH1,
|
|
||||||
STATE_LENGTH2, STATE_ACQUIRE_DATA };
|
|
||||||
|
|
||||||
enum {
|
|
||||||
TOTAL_PACKET_LENGTH = ArNetPacket::MAX_LENGTH+ArNetPacket::HEADER_LENGTH+ArNetPacket::FOOTER_LENGTH
|
|
||||||
};
|
|
||||||
|
|
||||||
State myState;
|
|
||||||
ArFunctor1<ArNetPacket *> *myProcessPacketCB;
|
|
||||||
bool myQuiet;
|
|
||||||
ArSocket *mySocket;
|
|
||||||
ArTime myLastPacket;
|
|
||||||
ArNetPacket myPacket;
|
|
||||||
|
|
||||||
|
|
||||||
char myReadBuff[TOTAL_PACKET_LENGTH];
|
|
||||||
int myReadCount;
|
|
||||||
int myReadLength;
|
|
||||||
int myReadCommand;
|
|
||||||
unsigned char mySync1;
|
|
||||||
unsigned char mySync2;
|
|
||||||
std::string myLoggingPrefix;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // NLNETPACKETRECEIVERTCP
|
|
@ -1,41 +0,0 @@
|
|||||||
#ifndef NLNETPACKETRECEIVERUDP_H
|
|
||||||
#define NLNETPACKETRECEIVERUDP_H
|
|
||||||
|
|
||||||
#include "ArNetPacket.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
This is the receiver for UDP packets.
|
|
||||||
**/
|
|
||||||
|
|
||||||
class ArNetPacketReceiverUdp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AREXPORT ArNetPacketReceiverUdp();
|
|
||||||
AREXPORT ~ArNetPacketReceiverUdp();
|
|
||||||
|
|
||||||
/// Sets the socket this receiver uses
|
|
||||||
AREXPORT void setSocket(ArSocket *socket);
|
|
||||||
/// Gets the socket this receiver uses
|
|
||||||
AREXPORT ArSocket *getSocket(void);
|
|
||||||
|
|
||||||
/// Sets the callback for use when a packet is received
|
|
||||||
AREXPORT void setProcessPacketCB(ArFunctor2<ArNetPacket *,
|
|
||||||
struct sockaddr_in *> *functor);
|
|
||||||
|
|
||||||
/// Gets the callback used when a packet is received
|
|
||||||
AREXPORT ArFunctor2<ArNetPacket *, struct sockaddr_in *> *
|
|
||||||
getProcessPacketCB(void);
|
|
||||||
|
|
||||||
/// Reads in all the data available calling the processPacketCB
|
|
||||||
AREXPORT bool readData(void);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ArFunctor2<ArNetPacket *, struct sockaddr_in *> *myProcessPacketCB;
|
|
||||||
ArSocket *mySocket;
|
|
||||||
ArTime myLastPacket;
|
|
||||||
ArNetPacket myPacket;
|
|
||||||
char myBuff[ArNetPacket::MAX_LENGTH+20];
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // NLNETPACKETRECEIVERUDP_H
|
|
@ -1,51 +0,0 @@
|
|||||||
#ifndef ARNETPACKETSENDERTCP_H
|
|
||||||
#define ARNETPACKETSENDERTCP_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArNetPacket.h"
|
|
||||||
|
|
||||||
class ArNetPacketSenderTcp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArNetPacketSenderTcp();
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT ~ArNetPacketSenderTcp();
|
|
||||||
|
|
||||||
/// Sets the socket this sender uses
|
|
||||||
AREXPORT void setSocket(ArSocket *socket);
|
|
||||||
/// Gets the socket this sender uses
|
|
||||||
AREXPORT ArSocket *getSocket(void);
|
|
||||||
|
|
||||||
/// Sets the connection timeout
|
|
||||||
AREXPORT void setBackupTimeout(double connectionTimeoutInMins);
|
|
||||||
|
|
||||||
/// Sets debug logging
|
|
||||||
AREXPORT void setDebugLogging(bool debugLogging);
|
|
||||||
|
|
||||||
/// Sets the logging prefix
|
|
||||||
AREXPORT void setLoggingPrefix(const char *prefix);
|
|
||||||
|
|
||||||
/// Sends a packet
|
|
||||||
AREXPORT void sendPacket(ArNetPacket *packet,
|
|
||||||
const char *loggingString = "");
|
|
||||||
|
|
||||||
/// Tries to send the data there is to be sent
|
|
||||||
AREXPORT bool sendData(void);
|
|
||||||
protected:
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
bool myDebugLogging;
|
|
||||||
std::string myLoggingPrefix;
|
|
||||||
ArLog::LogLevel myVerboseLogLevel;
|
|
||||||
ArSocket *mySocket;
|
|
||||||
std::list<ArNetPacket *> myPacketList;
|
|
||||||
ArNetPacket *myPacket;
|
|
||||||
int myAlreadySent;
|
|
||||||
const char *myBuf;
|
|
||||||
int myLength;
|
|
||||||
double myBackupTimeout;
|
|
||||||
ArTime myLastGoodSend;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,188 +0,0 @@
|
|||||||
#ifndef ARNETWORKING_H
|
|
||||||
#define ARNETWORKING_H
|
|
||||||
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
#include "ArServerClient.h"
|
|
||||||
#include "ArServerCommands.h"
|
|
||||||
#include "ArClientBase.h"
|
|
||||||
#include "ArClientCommands.h"
|
|
||||||
#include "ArMapChanger.h"
|
|
||||||
#include "ArServerHandlerCamera.h"
|
|
||||||
#include "ArServerHandlerCameraCollection.h"
|
|
||||||
#include "ArServerHandlerCommMonitor.h"
|
|
||||||
#include "ArServerHandlerCommands.h"
|
|
||||||
#include "ArServerHandlerPopup.h"
|
|
||||||
#include "ArServerInfoDrawings.h"
|
|
||||||
#include "ArServerInfoRobot.h"
|
|
||||||
#include "ArServerInfoSensor.h"
|
|
||||||
#include "ArServerHandlerMap.h"
|
|
||||||
#include "ArServerMode.h"
|
|
||||||
#include "ArServerModeDrive.h"
|
|
||||||
#include "ArServerModeRatioDrive.h"
|
|
||||||
#include "ArServerModeStop.h"
|
|
||||||
#include "ArServerModeWander.h"
|
|
||||||
#include "ArServerHandlerConfig.h"
|
|
||||||
#include "ArClientHandlerConfig.h"
|
|
||||||
#include "ArHybridForwarderVideo.h"
|
|
||||||
#include "ArServerSimpleCommands.h"
|
|
||||||
#ifndef WIN32
|
|
||||||
#include "ArServerFileUtils.h"
|
|
||||||
#endif
|
|
||||||
#include "ArClientFileUtils.h"
|
|
||||||
#include "ArServerUserInfo.h"
|
|
||||||
#include "ArClientSimpleConnector.h"
|
|
||||||
#include "ArServerHandlerMapping.h"
|
|
||||||
#include "ArServerSimpleOpener.h"
|
|
||||||
#include "ArServerInfoStrings.h"
|
|
||||||
#include "ArClientArgUtils.h"
|
|
||||||
#include "ArServerHandlerPopup.h"
|
|
||||||
#include "ArCentralManager.h"
|
|
||||||
#include "ArCentralForwarder.h"
|
|
||||||
#include "ArClientSwitchManager.h"
|
|
||||||
#include "ArServerModeIdle.h"
|
|
||||||
#include "ArTempDirectoryHelper.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
\mainpage ArNetworking
|
|
||||||
|
|
||||||
MobileRobots <b>Advanced Robotics Networking Infrastructure (ArNetworking)</b>
|
|
||||||
Developer's API Reference Manual<br>
|
|
||||||
Copyright 2005 ActivMedia Robotics, LLC. All rights reserved.<br>
|
|
||||||
Copyright 2006, 2007, 2008, 2009, 2010 MobileRobots Inc. All rights reserved.
|
|
||||||
|
|
||||||
|
|
||||||
ArNetworking is an extensible networking protocol and infrastructure. It
|
|
||||||
is used to add networking services to a robot control program, integrated
|
|
||||||
with ARIA and other MobileRobots software libraries.
|
|
||||||
|
|
||||||
ArNetworking is used to set up a client-server architecture. A client
|
|
||||||
issues <i>requests</i> to a server to issue a single command the server,
|
|
||||||
or to start retrieving data from the server at a specified time interval.
|
|
||||||
A request type is identified by a short string.
|
|
||||||
|
|
||||||
A client may be an operator's graphical interface, or a component requiring
|
|
||||||
off-board resources (such as a multi-robot planning system, for example).
|
|
||||||
However, a program onboard the robot could also implement a client, and issue
|
|
||||||
requests to an offboard server (e.g. to retrieve data from a central database).
|
|
||||||
|
|
||||||
In a typical application, however, a program acting as the server runs on the robot's
|
|
||||||
computer, and uses ARIA (and possibly ARNL or SONARNL) to control the robot.
|
|
||||||
This creates a three-tier system: the robot itself is the first tier, and acts as a
|
|
||||||
"robot server" to a program on its onboard computer which is simultaneously a
|
|
||||||
"robot client" and an "ArNetworking server". Offboard ArNetworking clients are the final
|
|
||||||
tier. This three-tier architecture allows a tight, reliable control loop between the robot
|
|
||||||
control program on the onboard computer, and removes higher level user-interface clients
|
|
||||||
accross the potentially unreliable network, protecting the more critical robot control program,
|
|
||||||
and providing a more immediate and flexible user interface.
|
|
||||||
|
|
||||||
ArNetworking can use both TCP and UDP.
|
|
||||||
|
|
||||||
\image html ArNetworking_overview.png Abstract overview of ArNetworking in a typical client-server configuration with one client issuing requests to a server
|
|
||||||
|
|
||||||
\section Servers Servers
|
|
||||||
|
|
||||||
An ArNetworking server program is comprised of an ArServerBase object, to which
|
|
||||||
callback functors are added for each request type you wish to handle (keyed
|
|
||||||
by a request identifier string, though this string is internally converted
|
|
||||||
into a more efficient integer value) using ArServerBase::addData().
|
|
||||||
These callbacks are often encapsulated in "ServerHandler" or "ServerInfo"
|
|
||||||
classes. The ArNetworking library provides a variety of prewritten classes for
|
|
||||||
providing current state information about the robot, and for teleoperation
|
|
||||||
control. A callback functor for a request, when invoked, receives an ArNetPacket
|
|
||||||
object containing the request's payload data, and a pointer
|
|
||||||
to an object used to send a reply packet to the client.
|
|
||||||
ArServerBase creates a background thread to asyncronously accept client connections
|
|
||||||
and receive clients' requests, while your main program thread executes simultaneously.
|
|
||||||
This thread runs in a loop, and you may add general-purpose callback functors
|
|
||||||
to be invoked each cycle of this loop using ArServerBase::addCycleCallback().
|
|
||||||
|
|
||||||
To simplify server program setup, a helper class ArServerSimpleOpener is available.
|
|
||||||
|
|
||||||
The default port number for an ArServerBase object to open is 7272, though
|
|
||||||
an alternate port number may be used via a command line argument to the program,
|
|
||||||
or specified in the ArServerBase constructor.
|
|
||||||
|
|
||||||
\subsection ServerModes Server Modes
|
|
||||||
|
|
||||||
ArNetworking also provides a system of server mode classes (see ArServerMode
|
|
||||||
base class). The server may only be in one mode at a time, each of which
|
|
||||||
enables and disables ARIA ArAction objects.
|
|
||||||
|
|
||||||
\subsection SimpleServerCommands Simple Server Commands
|
|
||||||
|
|
||||||
ArNetworking includes the ArServerHandlerCommands class that provides a very
|
|
||||||
simple API for simple "command" requests: requests, perhaps with a few
|
|
||||||
parameters, that simply perform some action or change some state, and have
|
|
||||||
no data to reply with. Callback functors added for requests via
|
|
||||||
an ArServerHandlerCommands object do not receive the request packet data, so they
|
|
||||||
do not need to do any decoding of that data. Additionally, ArServerHandlerCommands
|
|
||||||
keeps a list of requests that it manages, which is available to clients.
|
|
||||||
ArNetworking includes some prewritten classes (ArServerSimpleCom*) which
|
|
||||||
simply add new commands to an ArServerHandlerCommands object and encapsulate their
|
|
||||||
request callbacks.
|
|
||||||
|
|
||||||
For example, MobileEyes queries this list on
|
|
||||||
connection, and if some of these simple
|
|
||||||
commands are available, it makes a menu in the toolbar called Custom Commands
|
|
||||||
accessible. This is a way to make special features of your custom robot server
|
|
||||||
application controllable from MobileEyes.
|
|
||||||
|
|
||||||
\subsection ARNLServerClasses Networking in ARNL and SONARNL
|
|
||||||
|
|
||||||
The ARNL and SONARNL libraries contain some ServerHandler/ServerInfo classes
|
|
||||||
that implement useful server requests, as well as server Mode classes.
|
|
||||||
|
|
||||||
\subsection PreMadeServices Standard Services Available in ArNetworking
|
|
||||||
|
|
||||||
These are some of the pre-written services which are available in the ArNetworking
|
|
||||||
library for you to use in your server programs. To use these services, your
|
|
||||||
server program typically only needs to create and retain an instance of the class,
|
|
||||||
though some require some additional setup.
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>ArServerInfoRobot - Supplies clients with basic robot state information (current position and velocity, active server mode and status, battery voltage)</li>
|
|
||||||
<li>ArServerInfoSensor - Supplies clients with current sensor readings (Sonar or Laser)</li>
|
|
||||||
<li>ArServerHandlerMap - Supplies clients with data from an ArMap</li>
|
|
||||||
<li>ArServerInfoDrawings - Supplies clients with a set of graphical figures to be displayed with the map (e.g. point sets, lines, circles)</li>
|
|
||||||
<li>ArServerHandlerCamera - Allows clients to control a pan-tilt camera and provides information about its current position</li>
|
|
||||||
<li>ArServerInfoStrings - A set of general purpose key,value string pairs obtained from a global table (See Aria::getInfoGroup())</li>
|
|
||||||
<li>ArServerHandlerMapping - Allows clients to trigger collection of laser scan data for use in making a map later (with the Mapper3 application)</li>
|
|
||||||
<li>ArServerFileToClient, ArServerFileFromClient, ArServerFileLister - Allows clients to upload and download files from the server filesystem</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
\section Clients Clients
|
|
||||||
|
|
||||||
A client program is comprised of an ArClientBase object which must be connected
|
|
||||||
to a server via a network socket (either TCP or the default, UDP). The server is
|
|
||||||
identified by network hostname and port number, which may be given
|
|
||||||
through ArClientBase API or in the program command line arguments. Requests
|
|
||||||
are made to the server via ArClientBase::request() or ArClientBase::requestOnce().
|
|
||||||
Callback functors may be added to the ArClientBase object to receive reply packets.
|
|
||||||
ArClientBase creates a background thread to asyncronously communicate with the server.
|
|
||||||
|
|
||||||
A client may query a server to discover if a data request type is available using
|
|
||||||
ArClientBase::dataExists().
|
|
||||||
|
|
||||||
To simplify client program setup and connection to a server, a helper class
|
|
||||||
ArClientSimpleConnector is available.
|
|
||||||
|
|
||||||
|
|
||||||
\section Auth Authenticated Connections
|
|
||||||
|
|
||||||
A simple scheme for authenticated connections is available in ArNetworking.
|
|
||||||
When connecting to a server, a client may supply a username and password.
|
|
||||||
If the server has loaded a <i>user info file</i>, it may reject a connection
|
|
||||||
with an incorrect password. Data requests may be categorized into
|
|
||||||
<i>command groups</i>, and which command groups are allowed to which users may
|
|
||||||
be specified in the user info file.
|
|
||||||
|
|
||||||
The login process is not impossible to defeat with some concerted effort and expertise,
|
|
||||||
but is sufficient to prevent basic attempts at unauthorized use of a server, and
|
|
||||||
to present only relevant features for different users' purposes.
|
|
||||||
|
|
||||||
See ArServerBase for more discussion.
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#endif // ARNETWORKING
|
|
@ -1,513 +0,0 @@
|
|||||||
#ifndef NLSERVERBASE_H
|
|
||||||
#define NLSERVERBASE_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerCommands.h"
|
|
||||||
#include "ArServerClient.h"
|
|
||||||
#include "ArServerData.h"
|
|
||||||
#include "ArNetPacket.h"
|
|
||||||
#include "ArNetPacketReceiverUdp.h"
|
|
||||||
#include "ArServerUserInfo.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
Base server for all networking services.
|
|
||||||
|
|
||||||
This class is the "base" server for network services. Start
|
|
||||||
this server by calling open(), and then running the loop with run() or runAsync(),
|
|
||||||
(or loopOnce() if it is absolutely neccesary to use your own loop; see the
|
|
||||||
implementation of run()).
|
|
||||||
You can then pass this object to the various "ArServerInfo", "ArServerHandler", and ArServerMode classes.
|
|
||||||
|
|
||||||
Data request callbacks are added to an ArServerBase object by calling
|
|
||||||
addData().
|
|
||||||
|
|
||||||
This class takes care of locking in its own function calls so you
|
|
||||||
don't need to worry about locking and unlocking the class before
|
|
||||||
you do things.
|
|
||||||
|
|
||||||
The counterpart of this class for clients is ArClientBase.
|
|
||||||
|
|
||||||
You can require user names and passwords for making connections to
|
|
||||||
the server, so each user has a set of permissions for different
|
|
||||||
command groups. To do this, load configuration from a userInfo file
|
|
||||||
with loadUserInfo(). You can log the
|
|
||||||
user info (and what commands users have) with logUserInfo(). You can
|
|
||||||
log the command groups with logCommandGroups() or
|
|
||||||
logCommandGroupsToFile(). For a description of the file see
|
|
||||||
ArServerUserInfo. There is also an example in
|
|
||||||
<code>ArNetworking/examples/serverDemo.userInfo</code>.
|
|
||||||
|
|
||||||
In addition to the user and password requirement you can set a server "key"
|
|
||||||
(a special string of text) required (in addition to user and password)
|
|
||||||
to access the server with setServerKey(), though this is ONLY used if
|
|
||||||
user and password information is requied (so that older clients can
|
|
||||||
connect if there's no user and password information required).
|
|
||||||
|
|
||||||
The way that the passwords are transmitted across the network is this:
|
|
||||||
Upon connection the server sends a randomly generated (for that
|
|
||||||
connection) string of text to the client which we'll call the
|
|
||||||
passwordKey. The client then combines the serverKey (a string which must be
|
|
||||||
known to connect to the server at all), the password, and the
|
|
||||||
passwordKey (that string that is generated uniquely for each
|
|
||||||
connection) and comes up with an md5 of that string and sends that
|
|
||||||
md5 value across the line. The server then compares the md5 from
|
|
||||||
the client with the md5 generated with the correct information on
|
|
||||||
the server... if they match the password is good, otherwise it
|
|
||||||
rejects the connection. This is NOT perfect security but should be
|
|
||||||
much better then plaintext. If you care about perfect security
|
|
||||||
then use an ssh tunnel with something like PUTTY from the machine
|
|
||||||
the client is on to the machine the server is on with an openssh
|
|
||||||
server set up (this'll likely even work in windows with cygwin) and
|
|
||||||
set up a firewall on the machine the server is on that disallows
|
|
||||||
port the server port connection from outside and only allows ssh
|
|
||||||
from outside (and get a book or three and read those).
|
|
||||||
|
|
||||||
This class now handles identifiers for the ArServerClients... all
|
|
||||||
server bases will let a client set a self identifier string, and a
|
|
||||||
here goal... those may be used by any server. Messages can be sent
|
|
||||||
to just server clients that match that message (so that its easier
|
|
||||||
to send messages to people who sent commands).
|
|
||||||
|
|
||||||
Master servers (the main connection server base on the central
|
|
||||||
server) can also give each connection an id number (with
|
|
||||||
identGetConnectionID). Things that then connect to the other
|
|
||||||
server bases on a master server (slave servers) should then set
|
|
||||||
their ConnectionID (with identSetConnectionID) so that things can
|
|
||||||
relate the different connections together.
|
|
||||||
|
|
||||||
@sa ArServerSimpleOpener
|
|
||||||
@sa ArClientBase
|
|
||||||
@sa ArServerMode
|
|
||||||
**/
|
|
||||||
|
|
||||||
class ArServerBase: public ArASyncTask
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerBase(
|
|
||||||
bool addAriaExitCB = true,
|
|
||||||
const char *serverName = "",
|
|
||||||
bool addBackupTimeoutToConfig = true,
|
|
||||||
const char *backupTimeoutName = "RobotToClientTimeoutInMins",
|
|
||||||
const char *backupTimeoutDesc = "The amount of time the central server can go without sending a packet to the robot successfully (when there are packets to send). A number less than 0 means this won't happen. The time is in minutes but takes doubles (ie .5) (5 seconds is used if the value is positive, but less than that amount)",
|
|
||||||
bool masterServer = false, bool slaveServer = false,
|
|
||||||
bool logPasswordFailureVerbosely = false,
|
|
||||||
bool allowSlowPackets = true, bool allowIdlePackets = true,
|
|
||||||
int maxClientsAllowed = -1);
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerBase();
|
|
||||||
|
|
||||||
/// Opens the server to accept new client connections
|
|
||||||
AREXPORT bool open(unsigned int port, const char *openOnIP = NULL,
|
|
||||||
bool tcpOnly = false);
|
|
||||||
/// Closes the server
|
|
||||||
AREXPORT void close(void);
|
|
||||||
/// Runs the server loop once
|
|
||||||
AREXPORT void loopOnce(void);
|
|
||||||
|
|
||||||
/// Adds a callback to be called when requests for some data are recieved.
|
|
||||||
AREXPORT bool addData(const char *name, const char *description,
|
|
||||||
ArFunctor2<ArServerClient *, ArNetPacket *> *functor,
|
|
||||||
const char *argumentDescription,
|
|
||||||
const char *returnDescription,
|
|
||||||
const char *commandGroup = NULL,
|
|
||||||
const char *dataFlags = NULL);
|
|
||||||
|
|
||||||
/// Loads up a set of usernames/passwords/permissions from a file
|
|
||||||
AREXPORT bool loadUserInfo(const char *fileName,
|
|
||||||
const char *baseDirectory = "");
|
|
||||||
|
|
||||||
/// Logs the users and their groups
|
|
||||||
AREXPORT void logUserInfo(void);
|
|
||||||
|
|
||||||
/// Logs the groups and commands in those groups
|
|
||||||
AREXPORT void logCommandGroups(void);
|
|
||||||
|
|
||||||
/// Logs the groups and commands in those groups to a file
|
|
||||||
AREXPORT void logCommandGroupsToFile(const char *fileName);
|
|
||||||
|
|
||||||
/// Logs the command group names and command group descriptions for those names
|
|
||||||
AREXPORT void setGroupDescription(const char *GrpName, const char *GrpDesc);
|
|
||||||
|
|
||||||
/// Logs the command group names and descriptions
|
|
||||||
AREXPORT void logGroupDescriptions(void);
|
|
||||||
|
|
||||||
/// Logs the command group names and descriptions to a file
|
|
||||||
AREXPORT void logGroupDescriptionsToFile(const char *fileName);
|
|
||||||
|
|
||||||
/// Sets a 'key' needed to access the server through any account
|
|
||||||
AREXPORT void setServerKey(const char *serverKey);
|
|
||||||
|
|
||||||
|
|
||||||
/// Tells the server to reject connectings because we're usinga central server
|
|
||||||
AREXPORT void rejectSinceUsingCentralServer(
|
|
||||||
const char *centralServerIPString);
|
|
||||||
|
|
||||||
/// Enforces that the server is using this protocol version
|
|
||||||
AREXPORT void enforceProtocolVersion(const char *protocolVersion);
|
|
||||||
|
|
||||||
/// Enforces that the robots that connect are this type
|
|
||||||
AREXPORT void enforceType(ArServerCommands::Type type);
|
|
||||||
|
|
||||||
/// Sets the backup timeout
|
|
||||||
AREXPORT void setBackupTimeout(double timeoutInMins);
|
|
||||||
|
|
||||||
/// Runs the server in this thread
|
|
||||||
AREXPORT virtual void run(void);
|
|
||||||
|
|
||||||
/// Runs the server in its own thread
|
|
||||||
AREXPORT virtual void runAsync(void);
|
|
||||||
|
|
||||||
/// Logs the connections
|
|
||||||
AREXPORT void logConnections(const char *prefix = "");
|
|
||||||
|
|
||||||
/// Gets the number of clients connected
|
|
||||||
AREXPORT int getNumClients(void);
|
|
||||||
|
|
||||||
/// Gets the number of a command
|
|
||||||
AREXPORT unsigned int findCommandFromName(const char *command);
|
|
||||||
|
|
||||||
/// Broadcasts packets to any client wanting this data
|
|
||||||
AREXPORT bool broadcastPacketTcp(ArNetPacket *packet, const char *name);
|
|
||||||
|
|
||||||
/// Broadcasts packets to any client wanting this data that matches the ID
|
|
||||||
AREXPORT bool broadcastPacketTcpToMatching(
|
|
||||||
ArNetPacket *packet, const char *name,
|
|
||||||
ArServerClientIdentifier identifier, bool matchConnectionID = false);
|
|
||||||
|
|
||||||
/// Broadcasts packets to any client wanting this data
|
|
||||||
AREXPORT bool broadcastPacketTcpWithExclusion(
|
|
||||||
ArNetPacket *packet, const char *name,
|
|
||||||
ArServerClient *excludeClient, bool match = false,
|
|
||||||
ArServerClientIdentifier identifier = ArServerClientIdentifier(),
|
|
||||||
bool matchConnectionID = false);
|
|
||||||
|
|
||||||
/// Broadcasts packets to any client wanting this data
|
|
||||||
AREXPORT bool broadcastPacketUdp(ArNetPacket *packet, const char *name);
|
|
||||||
|
|
||||||
/// Broadcasts packets to any client wanting this data
|
|
||||||
AREXPORT bool broadcastPacketUdpWithExclusion(
|
|
||||||
ArNetPacket *packet, const char *name, ArServerClient *excludeClient,
|
|
||||||
bool match = false,
|
|
||||||
ArServerClientIdentifier identifier = ArServerClientIdentifier(),
|
|
||||||
bool matchConnectionID = false);
|
|
||||||
|
|
||||||
/// Broadcasts packets to any client wanting this data that matches
|
|
||||||
AREXPORT bool broadcastPacketUdpToMatching(
|
|
||||||
ArNetPacket *packet, const char *name,
|
|
||||||
ArServerClientIdentifier identifier, bool matchConnectionID);
|
|
||||||
|
|
||||||
/// Delays the current thread by the specified msecs, for use after packet sent.
|
|
||||||
AREXPORT void sleepAfterSend(int msecDelay);
|
|
||||||
|
|
||||||
/// Sees if we have any idle processing pending (idle packets or callbacks)
|
|
||||||
AREXPORT bool idleProcessingPending(void);
|
|
||||||
|
|
||||||
/// Processes udp packets
|
|
||||||
AREXPORT void processPacket(ArNetPacket *packet,
|
|
||||||
struct sockaddr_in *sin);
|
|
||||||
|
|
||||||
/// Sends Udp packets
|
|
||||||
AREXPORT bool sendUdp(ArNetPacket *packet,
|
|
||||||
struct sockaddr_in *sin);
|
|
||||||
|
|
||||||
/// Logs the tracking on each client (how many packets and bytes were sent)
|
|
||||||
AREXPORT void logTracking(bool terse = true);
|
|
||||||
|
|
||||||
/// Clears the tracking on all the clients (resets counters)
|
|
||||||
AREXPORT void resetTracking(void);
|
|
||||||
|
|
||||||
// the function for the thread
|
|
||||||
AREXPORT virtual void * runThread(void *arg);
|
|
||||||
|
|
||||||
/// Gets the tcp port we're using
|
|
||||||
AREXPORT unsigned int getTcpPort(void);
|
|
||||||
/// Gets the udp port we're using
|
|
||||||
AREXPORT unsigned int getUdpPort(void);
|
|
||||||
/// Gets the IP we're opening on (or NULL if there's none)
|
|
||||||
AREXPORT const char *getOpenOnIP(void);
|
|
||||||
|
|
||||||
/// Add a callback to be called at every cycle
|
|
||||||
AREXPORT void addCycleCallback(ArFunctor* functor);
|
|
||||||
|
|
||||||
/// Remove a callback to be called at every cycle
|
|
||||||
AREXPORT void remCycleCallback(ArFunctor* functor);
|
|
||||||
|
|
||||||
/// Add a callback to be invoked when a client has been removed (but before it is deleted)
|
|
||||||
AREXPORT void addClientRemovedCallback(ArFunctor1<ArServerClient *> *functor);
|
|
||||||
/// Remove the callback invoked when a client has been removed
|
|
||||||
AREXPORT void remClientRemovedCallback(ArFunctor1<ArServerClient *> *functor);
|
|
||||||
/// Makes a new serverclient from this socket (for switching, needs no password since this was an outgoing connection to a trusted server)
|
|
||||||
AREXPORT ArServerClient *makeNewServerClientFromSocket(
|
|
||||||
ArSocket *socket, bool overrideGeneralReject);
|
|
||||||
/// Gets the user info we're using (mostly internal for switching)
|
|
||||||
AREXPORT const ArServerUserInfo *getUserInfo(void) const;
|
|
||||||
/// Sets the user info we'll use (mostly internal for switching)
|
|
||||||
AREXPORT void setUserInfo(const ArServerUserInfo *userInfo);
|
|
||||||
/// Adds a callback for requests in a more advanced manner, for internal use
|
|
||||||
AREXPORT bool addDataAdvanced(
|
|
||||||
const char *name, const char *description,
|
|
||||||
ArFunctor2<ArServerClient *, ArNetPacket *> *functor,
|
|
||||||
const char *argumentDescription, const char *returnDescription,
|
|
||||||
const char *commandGroup = NULL, const char *dataFlags = NULL,
|
|
||||||
unsigned int commandNumber = 0,
|
|
||||||
ArFunctor2<long, unsigned int> *requestChangedFunctor = NULL,
|
|
||||||
ArRetFunctor2<bool, ArServerClient *, ArNetPacket *>
|
|
||||||
*requestOnceFunctor = NULL);
|
|
||||||
/// Sets the data flags to add in addition to those passed in
|
|
||||||
AREXPORT void setAdditionalDataFlags(const char *additionalDataFlags);
|
|
||||||
/// Gets the frequncy a command is requested (mostly internal)
|
|
||||||
AREXPORT long getFrequency(unsigned int command,
|
|
||||||
bool internalCall = false);
|
|
||||||
/// Broadcasts packets to any client wanting this data
|
|
||||||
AREXPORT bool broadcastPacketTcpByCommand(
|
|
||||||
ArNetPacket *packet, unsigned int command);
|
|
||||||
|
|
||||||
/// Broadcasts packets to any client wanting this data
|
|
||||||
AREXPORT bool broadcastPacketTcpByCommandWithExclusion(
|
|
||||||
ArNetPacket *packet, unsigned int command,
|
|
||||||
ArServerClient *excludeClient, bool match = false,
|
|
||||||
ArServerClientIdentifier identifier = ArServerClientIdentifier(),
|
|
||||||
bool matchConnectionID = false);
|
|
||||||
|
|
||||||
/// Broadcasts packets to any client wanting this data
|
|
||||||
AREXPORT bool broadcastPacketUdpByCommand(
|
|
||||||
ArNetPacket *packet, unsigned int command);
|
|
||||||
|
|
||||||
/// Broadcasts packets to any client wanting this data
|
|
||||||
AREXPORT bool broadcastPacketUdpByCommandWithExclusion(
|
|
||||||
ArNetPacket *packet, unsigned int command,
|
|
||||||
ArServerClient *excludeClient, bool match = false,
|
|
||||||
ArServerClientIdentifier identifier = ArServerClientIdentifier(),
|
|
||||||
bool matchConnectionID = false);
|
|
||||||
|
|
||||||
/// Closes connection with a given connection ID
|
|
||||||
AREXPORT void closeConnectionID(ArTypes::UByte4 idNum);
|
|
||||||
/// Returns if a command has a data flag
|
|
||||||
AREXPORT bool dataHasFlag(const char *name, const char *dataFlag);
|
|
||||||
/// Returns if a command has a data flag by command number
|
|
||||||
AREXPORT bool dataHasFlagByCommand(unsigned int command,
|
|
||||||
const char *dataFlag);
|
|
||||||
/// Sets debug logging
|
|
||||||
AREXPORT void setDebugLogging(bool debugLogging = false);
|
|
||||||
/// Gets if this is using debug logging
|
|
||||||
AREXPORT bool getDebugLogging(void);
|
|
||||||
/// Gets the most clients we've had connected
|
|
||||||
AREXPORT int getMostClients(void);
|
|
||||||
|
|
||||||
/// Gets if we're allowing idle packets
|
|
||||||
AREXPORT bool allowingIdlePackets(void);
|
|
||||||
|
|
||||||
/// Adds an idle callback to be called once next time the robot is idle
|
|
||||||
AREXPORT bool addIdleSingleShotCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Internal, Sees if we have any slow packets we are waiting to process
|
|
||||||
AREXPORT bool hasSlowPackets(void);
|
|
||||||
|
|
||||||
/// Internal, Sees if we have any idle packets we are waiting to process
|
|
||||||
AREXPORT bool hasIdlePackets(void);
|
|
||||||
|
|
||||||
/// Internal, Sees if we have any idle callbacks we are waiting to process
|
|
||||||
AREXPORT bool hasIdleCallbacks(void);
|
|
||||||
|
|
||||||
/// Internal, sets the maximum number of clients
|
|
||||||
AREXPORT void internalSetNumClients(int numClients);
|
|
||||||
|
|
||||||
/// Adds a callback when we switch states while starting
|
|
||||||
AREXPORT void addTooManyClientsCB(
|
|
||||||
ArFunctor1<const char *> *functor, int position = 50)
|
|
||||||
{ myTooManyClientsCBList.addCallback(functor, position); }
|
|
||||||
/// Removes a callback when we switch to running
|
|
||||||
AREXPORT void remTooManyClientsCB(ArFunctor1<const char *> *functor)
|
|
||||||
{ myTooManyClientsCBList.remCallback(functor); }
|
|
||||||
|
|
||||||
/// Internal call that sets the default frequency as a helper for forwarding (if it's faster than the current default)
|
|
||||||
AREXPORT bool internalSetDefaultFrequency(const char *command, int frequency);
|
|
||||||
|
|
||||||
/// Internal call to lockup the server (for testing)
|
|
||||||
AREXPORT void internalLockup(void);
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// The command get the ConnectionID of this server client connection
|
|
||||||
AREXPORT void identGetConnectionID(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// The command set the ConnectionID of this server client connection
|
|
||||||
AREXPORT void identSetConnectionID(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// The command set the self identifier of this server client connection
|
|
||||||
AREXPORT void identSetSelfIdentifier(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// The command set the here goal of this server client connection
|
|
||||||
AREXPORT void identSetHereGoal(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
|
|
||||||
/// Handles the "startRequestTransaction" packet, and updates the state of the client.
|
|
||||||
/**
|
|
||||||
* "Request transactions" are used to indicate that a sequence of request /
|
|
||||||
* reply packets must be completed before idle processing can proceed.
|
|
||||||
* Any "startRequestTransaction" MUST be followed by an "endRequestTransaction".
|
|
||||||
*
|
|
||||||
* The packets are meant to be used sparingly. They are currently only used
|
|
||||||
* when the Central Server is determining whether the map file needs to
|
|
||||||
* be downloaded to the client robot.
|
|
||||||
*
|
|
||||||
* @param client the ArServerClient* that sent the request; updated to indicate
|
|
||||||
* a new transaction is in progress
|
|
||||||
* @param packet the ArNetPacket* that contains the request (no additional data)
|
|
||||||
**/
|
|
||||||
AREXPORT void handleStartRequestTransaction(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the "endRequestTransaction" packet, and updates the state of the client.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient* that sent the request; updated to indicate
|
|
||||||
* that a transaction has completed
|
|
||||||
* @param packet the ArNetPacket* that contains the request (no additional data)
|
|
||||||
* @see handleStartRequestTransaction
|
|
||||||
**/
|
|
||||||
AREXPORT void handleEndRequestTransaction(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Returns the number of request transactions in progress for all connected clients.
|
|
||||||
/**
|
|
||||||
* @see handleStartRequestTransaction
|
|
||||||
**/
|
|
||||||
AREXPORT int getRequestTransactionCount();
|
|
||||||
|
|
||||||
|
|
||||||
/// accepts new sockets and moves them into the client list
|
|
||||||
void acceptTcpSockets(void);
|
|
||||||
/// Internal function for server/client switching
|
|
||||||
AREXPORT ArServerClient *finishAcceptingSocket(
|
|
||||||
ArSocket *socket, bool skipPassword = false,
|
|
||||||
bool overrideGeneralReject = false);
|
|
||||||
bool processFile(void);
|
|
||||||
|
|
||||||
/// callback for our slow idle thread, which is down below...
|
|
||||||
/// The command that returns if there is idle processing to do
|
|
||||||
AREXPORT void netIdleProcessingPending(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
void slowIdleCallback(void);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string myServerName;
|
|
||||||
std::string myLogPrefix;
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
ArMutex myClientsMutex;
|
|
||||||
ArMutex myCycleCallbacksMutex;
|
|
||||||
bool myTcpOnly;
|
|
||||||
bool myDebugLogging;
|
|
||||||
ArLog::LogLevel myVerboseLogLevel;
|
|
||||||
|
|
||||||
unsigned int myTcpPort;
|
|
||||||
unsigned int myUdpPort;
|
|
||||||
std::string myOpenOnIP;
|
|
||||||
// our mapping of the ints to the serverData
|
|
||||||
std::map<unsigned int, ArServerData *> myDataMap;
|
|
||||||
/// our mapping of the group names
|
|
||||||
std::map<std::string, std::string> myGroupDescription;
|
|
||||||
|
|
||||||
// default frequency (helper for forwarding)
|
|
||||||
std::map<unsigned int, int> myDefaultFrequency;
|
|
||||||
|
|
||||||
int myRejecting;
|
|
||||||
std::string myRejectingString;
|
|
||||||
|
|
||||||
std::string myEnforceProtocolVersion;
|
|
||||||
ArServerCommands::Type myEnforceType;
|
|
||||||
|
|
||||||
double myBackupTimeout;
|
|
||||||
bool myNewBackupTimeout;
|
|
||||||
ArMutex myBackupTimeoutMutex;
|
|
||||||
|
|
||||||
ArCallbackList1<const char *> myTooManyClientsCBList;
|
|
||||||
|
|
||||||
// the number we're on for the current data
|
|
||||||
unsigned int myNextDataNumber;
|
|
||||||
std::string myAdditionalDataFlags;
|
|
||||||
bool myOpened;
|
|
||||||
std::list<ArServerClient *> myClients;
|
|
||||||
ArNetPacketReceiverUdp myUdpReceiver;
|
|
||||||
ArFunctor2C<ArServerBase, ArNetPacket *, struct sockaddr_in *> myProcessPacketCB;
|
|
||||||
ArRetFunctor2C<bool, ArServerBase, ArNetPacket *, struct sockaddr_in *> mySendUdpCB;
|
|
||||||
ArSocket myTcpSocket;
|
|
||||||
ArSocket myUdpSocket;
|
|
||||||
std::list<ArFunctor*> myCycleCallbacks;
|
|
||||||
std::list<ArFunctor1<ArServerClient *> *> myClientRemovedCallbacks;
|
|
||||||
|
|
||||||
ArTypes::UByte4 myConnectionNumber;
|
|
||||||
|
|
||||||
ArSocket myAcceptingSocket;
|
|
||||||
|
|
||||||
int myMostClients;
|
|
||||||
bool myUsingOwnNumClients;
|
|
||||||
int myNumClients;
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int myLoopMSecs;
|
|
||||||
|
|
||||||
ArMutex myAddListMutex;
|
|
||||||
std::list<ArServerClient *> myAddList;
|
|
||||||
ArMutex myRemoveSetMutex;
|
|
||||||
std::set<ArServerClient *> myRemoveSet;
|
|
||||||
|
|
||||||
const ArServerUserInfo *myUserInfo;
|
|
||||||
bool myLogPasswordFailureVerbosely;
|
|
||||||
std::string myServerKey;
|
|
||||||
ArFunctorC<ArServerBase> myAriaExitCB;
|
|
||||||
ArRetFunctor2C<long, ArServerBase, unsigned int, bool> myGetFrequencyCB;
|
|
||||||
ArRetFunctorC<bool, ArServerBase> myProcessFileCB;
|
|
||||||
|
|
||||||
ArFunctor2C<ArServerBase, ArServerClient *,
|
|
||||||
ArNetPacket *> myIdentGetConnectionIDCB;
|
|
||||||
ArFunctor2C<ArServerBase, ArServerClient *,
|
|
||||||
ArNetPacket *> myIdentSetConnectionIDCB;
|
|
||||||
ArFunctor2C<ArServerBase, ArServerClient *,
|
|
||||||
ArNetPacket *> myIdentSetSelfIdentifierCB;
|
|
||||||
ArFunctor2C<ArServerBase, ArServerClient *,
|
|
||||||
ArNetPacket *> myIdentSetHereGoalCB;
|
|
||||||
|
|
||||||
ArFunctor2C<ArServerBase, ArServerClient *,
|
|
||||||
ArNetPacket *> myStartRequestTransactionCB;
|
|
||||||
ArFunctor2C<ArServerBase, ArServerClient *,
|
|
||||||
ArNetPacket *> myEndRequestTransactionCB;
|
|
||||||
|
|
||||||
ArFunctor2C<ArServerBase, ArServerClient *,
|
|
||||||
ArNetPacket *> myIdleProcessingPendingCB;
|
|
||||||
|
|
||||||
bool myAllowSlowPackets;
|
|
||||||
bool myAllowIdlePackets;
|
|
||||||
|
|
||||||
int myMaxClientsAllowed;
|
|
||||||
|
|
||||||
ArMutex myProcessingSlowIdleMutex;
|
|
||||||
|
|
||||||
|
|
||||||
class SlowIdleThread : public ArASyncTask
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
SlowIdleThread(ArServerBase *serverBase);
|
|
||||||
/// Destructor
|
|
||||||
virtual ~SlowIdleThread(void);
|
|
||||||
virtual void *runThread(void *arg);
|
|
||||||
protected:
|
|
||||||
ArServerBase *myServerBase;
|
|
||||||
};
|
|
||||||
friend class ArServerBase::SlowIdleThread;
|
|
||||||
|
|
||||||
SlowIdleThread *mySlowIdleThread;
|
|
||||||
bool myHaveSlowPackets;
|
|
||||||
bool myHaveIdlePackets;
|
|
||||||
|
|
||||||
bool myLastIdleProcessingPending;
|
|
||||||
|
|
||||||
ArMutex myIdleCallbacksMutex;
|
|
||||||
bool myHaveIdleCallbacks;
|
|
||||||
std::list<ArFunctor *> myIdleCallbacks;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,284 +0,0 @@
|
|||||||
#ifndef NLSERVERCLIENT_H
|
|
||||||
#define NLSERVERCLIENT_H
|
|
||||||
|
|
||||||
#include "ArNetPacket.h"
|
|
||||||
#include "ArServerCommands.h"
|
|
||||||
#include "ArNetPacketReceiverTcp.h"
|
|
||||||
#include "ArNetPacketSenderTcp.h"
|
|
||||||
|
|
||||||
class ArServerData;
|
|
||||||
class ArServerUserInfo;
|
|
||||||
|
|
||||||
#include "ArServerClientData.h"
|
|
||||||
#include "ArServerClientIdentifier.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
This class represents the server's connection to the client, and
|
|
||||||
contains the socket that the server uses to talk to the client and
|
|
||||||
the information for sending packets to the client.
|
|
||||||
**/
|
|
||||||
|
|
||||||
class ArServerClient
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// The state of the connection
|
|
||||||
enum ServerState {
|
|
||||||
STATE_SENT_INTRO, ///< opened socket, sent our intro to the server
|
|
||||||
STATE_REJECTED, ///< Client was rejected by server
|
|
||||||
STATE_CONNECTED, ///< Client is connected to server
|
|
||||||
STATE_DISCONNECTED ///< Client has disconnected from server
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerClient(
|
|
||||||
ArSocket *tcpSocket, unsigned int udpPort, long authKey,
|
|
||||||
long introKey, ArRetFunctor2<bool, ArNetPacket *,
|
|
||||||
struct sockaddr_in *> *sendUdpCallback,
|
|
||||||
std::map<unsigned int, ArServerData *> *dataMap,
|
|
||||||
const char *passwordKey, const char *serverKey,
|
|
||||||
const ArServerUserInfo *userInfo = NULL,
|
|
||||||
int rejecting = 0, const char *rejectingString = "",
|
|
||||||
bool debugLogging = false,
|
|
||||||
const char *serverClientName = "ArServerBase_unknown",
|
|
||||||
bool logPasswordFailureVerbosely = false,
|
|
||||||
bool allowSlowPackets = true, bool allowIdlePackets = true,
|
|
||||||
const char *enforceProtocolVersion = "",
|
|
||||||
ArServerCommands::Type enforceType = ArServerCommands::TYPE_UNSPECIFIED);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerClient();
|
|
||||||
|
|
||||||
/// The callback for taking care of the TCP connection
|
|
||||||
AREXPORT bool tcpCallback(void);
|
|
||||||
|
|
||||||
/// The callback for taking care of slow packets
|
|
||||||
AREXPORT bool slowPacketCallback(void);
|
|
||||||
|
|
||||||
/// The callback for taking care of idle packets (logic on idle elsewhere)
|
|
||||||
AREXPORT bool idlePacketCallback(void);
|
|
||||||
|
|
||||||
/// Sets the backup timeout
|
|
||||||
AREXPORT void setBackupTimeout(double timeoutInMins);
|
|
||||||
|
|
||||||
/// Process the packet whever it came from
|
|
||||||
AREXPORT void processPacket(ArNetPacket *packet, bool tcp = true);
|
|
||||||
|
|
||||||
/// Send a packet over TCP.
|
|
||||||
/// The command ID of the outgoing packet will be set to the current command ID
|
|
||||||
/// (from the incoming packet).
|
|
||||||
AREXPORT virtual bool sendPacketTcp(ArNetPacket *packet);
|
|
||||||
/// Send a packet over UDP (unless client only wants TCP; then sends over TCP).
|
|
||||||
/// The command ID of the outgoing packet will be set to the current command ID
|
|
||||||
/// (from the incoming packet).
|
|
||||||
AREXPORT virtual bool sendPacketUdp(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Sees if this client has access to a given group
|
|
||||||
AREXPORT bool hasGroupAccess(const char *group);
|
|
||||||
|
|
||||||
/** Broadcasts a packet over TCP if this client wants this data -- For internal
|
|
||||||
* use only!
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
AREXPORT void broadcastPacketTcp(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/** Broadcasts a packet over UDP if this client wants this data (unless client only wants tcp then sends over tcp) -- For internal ArNetworking use only!
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
AREXPORT void broadcastPacketUdp(ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Logs the tracking information (packet and byte counts)
|
|
||||||
AREXPORT void logTracking(bool terse);
|
|
||||||
|
|
||||||
/// Clears the tracking information (resets counters)
|
|
||||||
AREXPORT void resetTracking(void);
|
|
||||||
|
|
||||||
/// Gets the IP string of the client
|
|
||||||
AREXPORT const char *getIPString(void) const;
|
|
||||||
|
|
||||||
/// Gets the identifier of this server client
|
|
||||||
AREXPORT ArServerClientIdentifier getIdentifier(void) const;
|
|
||||||
|
|
||||||
/// Sets the identifier of this server client
|
|
||||||
AREXPORT void setIdentifier(ArServerClientIdentifier identifier);
|
|
||||||
|
|
||||||
/// Sends a shutdown command to the socket
|
|
||||||
AREXPORT void shutdown(void);
|
|
||||||
|
|
||||||
/// Sets the sin (network address) for the UDP socket
|
|
||||||
AREXPORT void setUdpAddress(struct sockaddr_in *sin);
|
|
||||||
|
|
||||||
/// Gets the sin (network address) for the UDP socket
|
|
||||||
AREXPORT struct sockaddr_in *getUdpAddress(void);
|
|
||||||
|
|
||||||
/// Gets the authKey used for setting up UDP from this client to the server
|
|
||||||
AREXPORT long getAuthKey(void);
|
|
||||||
|
|
||||||
/// Processes the auth packets that came from udp
|
|
||||||
AREXPORT void processAuthPacket(ArNetPacket *packet, struct sockaddr_in *sin);
|
|
||||||
|
|
||||||
/// Handles the requests for packets
|
|
||||||
AREXPORT void handleRequests(void);
|
|
||||||
|
|
||||||
/// Internal function to get the tcp socket
|
|
||||||
AREXPORT ArSocket *getTcpSocket(void) { return &myTcpSocket; }
|
|
||||||
/// Forcibly disconnect a client (for client/server switching)
|
|
||||||
AREXPORT void forceDisconnect(bool quiet);
|
|
||||||
/// Gets how often a command is asked for
|
|
||||||
AREXPORT long getFrequency(ArTypes::UByte2 command);
|
|
||||||
/// Sets the TCP only flag
|
|
||||||
AREXPORT void useTcpOnly(void) { myTcpOnly = true; }
|
|
||||||
/// Gets the tcp only flag
|
|
||||||
AREXPORT bool isTcpOnly(void) { return myTcpOnly; }
|
|
||||||
/// Gets the state
|
|
||||||
AREXPORT ServerState getState(void) { return myState; }
|
|
||||||
/// Gets if we have any slow packets to process
|
|
||||||
AREXPORT bool hasSlowPackets(void) { return myHaveSlowPackets; }
|
|
||||||
/// Gets if we have any idle packets to process
|
|
||||||
AREXPORT bool hasIdlePackets(void) { return myHaveIdlePackets; }
|
|
||||||
|
|
||||||
|
|
||||||
/// Starts a new request transaction, incrementing the count.
|
|
||||||
/**
|
|
||||||
* This method is intended to be called solely by the ArServerBase.
|
|
||||||
* It MUST be followed by a call to endRequestTransaction().
|
|
||||||
*
|
|
||||||
* Request transactions are used under certain circumstances to
|
|
||||||
* indicate that a number of related request/reply packets must
|
|
||||||
* be completely processed before background idle processing can
|
|
||||||
* proceed. See ArServerBase for more information.
|
|
||||||
**/
|
|
||||||
AREXPORT void startRequestTransaction();
|
|
||||||
|
|
||||||
/// Ends the most recent request transaction, decrementing the count.
|
|
||||||
/**
|
|
||||||
* This method is intended to be called solely by the ArServerBase.
|
|
||||||
* @see startRequestTransaction().
|
|
||||||
**/
|
|
||||||
AREXPORT bool endRequestTransaction();
|
|
||||||
|
|
||||||
/// Returns the number of request transactions that are currently in progress.
|
|
||||||
/**
|
|
||||||
* This method is intended to be called solely by the ArServerBase.
|
|
||||||
* @see startRequestTransaction().
|
|
||||||
**/
|
|
||||||
AREXPORT int getRequestTransactionCount();
|
|
||||||
|
|
||||||
|
|
||||||
/// Returns the command ID for the specified name, or 0 if it is not found
|
|
||||||
AREXPORT unsigned int findCommandFromName(const char *commandName) const;
|
|
||||||
|
|
||||||
/// Get creation time
|
|
||||||
AREXPORT ArTime getCreationTime(void) { return myCreationTime; }
|
|
||||||
protected:
|
|
||||||
const char *findCommandName(unsigned int command) const;
|
|
||||||
// Some members so that we don't have to pass the number around
|
|
||||||
std::list<unsigned int> myCommandStack;
|
|
||||||
std::list<bool> myForceTcpStack;
|
|
||||||
std::list<unsigned int> mySlowIdleCommandStack;
|
|
||||||
std::list<bool> mySlowIdleForceTcpStack;
|
|
||||||
|
|
||||||
AREXPORT bool setupPacket(ArNetPacket *packet);
|
|
||||||
// Pushes a new number onto our little stack of numbers
|
|
||||||
void pushCommand(unsigned int num);
|
|
||||||
// Pops the command off the stack
|
|
||||||
void popCommand(void);
|
|
||||||
// Pushes a new number onto our little stack of numbers
|
|
||||||
void pushSlowIdleCommand(unsigned int num);
|
|
||||||
// Pops the command off the stack
|
|
||||||
void popSlowIdleCommand(void);
|
|
||||||
// Gets the command we're on
|
|
||||||
unsigned int getCommand();
|
|
||||||
// Gets the command we're on
|
|
||||||
bool getForceTcpFlag();
|
|
||||||
// Pushes a new forceTcp flag onto our little stack of flags
|
|
||||||
void pushForceTcpFlag(bool forceTcp);
|
|
||||||
// Pops the command off the stack
|
|
||||||
void popForceTcpFlag(void);
|
|
||||||
// Pushes a new forceTcp flag onto our little stack of flags
|
|
||||||
void pushSlowIdleForceTcpFlag(bool forceTcp);
|
|
||||||
// Pops the command off the stack
|
|
||||||
void popSlowIdleForceTcpFlag(void);
|
|
||||||
|
|
||||||
// this sends a list packet to our client
|
|
||||||
void sendListPacket(void);
|
|
||||||
|
|
||||||
// this could just be dealth with by seeing if myUserInfo is NULL,
|
|
||||||
// but that may be confusing
|
|
||||||
const ArServerUserInfo *myUserInfo;
|
|
||||||
std::set<std::string, ArStrCaseCmpOp> myGroups;
|
|
||||||
ArNetPacketSenderTcp myTcpSender;
|
|
||||||
std::map<unsigned int, ArServerData *> *myDataMap;
|
|
||||||
std::list<ArServerClientData *> myRequested;
|
|
||||||
void internalSwitchState(ServerState state);
|
|
||||||
ServerState myState;
|
|
||||||
ArTime myStateStart;
|
|
||||||
bool myUdpConfirmedFrom;
|
|
||||||
bool myUdpConfirmedTo;
|
|
||||||
ArSocket myTcpSocket;
|
|
||||||
ArNetPacketReceiverTcp myTcpReceiver;
|
|
||||||
ArFunctor2C<ArServerClient, ArNetPacket *, bool> myProcessPacketCB;
|
|
||||||
ArRetFunctor2<bool, ArNetPacket *, struct sockaddr_in *> *mySendUdpCB;
|
|
||||||
struct sockaddr_in mySin;
|
|
||||||
long myAuthKey;
|
|
||||||
long myIntroKey;
|
|
||||||
bool myTcpOnly;
|
|
||||||
bool mySentTcpOnly;
|
|
||||||
std::string myPasswordKey;
|
|
||||||
std::string myServerKey;
|
|
||||||
bool myDebugLogging;
|
|
||||||
ArLog::LogLevel myVerboseLogLevel;
|
|
||||||
std::string myLogPrefix;
|
|
||||||
ArServerClientIdentifier myIdentifier;
|
|
||||||
std::string myIPString;
|
|
||||||
|
|
||||||
double myBackupTimeout;
|
|
||||||
|
|
||||||
int myRejecting;
|
|
||||||
std::string myRejectingString;
|
|
||||||
|
|
||||||
std::string myEnforceProtocolVersion;
|
|
||||||
ArServerCommands::Type myEnforceType;
|
|
||||||
|
|
||||||
ArTime myTrackingStarted;
|
|
||||||
class Tracker
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Tracker() { reset(); }
|
|
||||||
virtual ~Tracker() {}
|
|
||||||
void reset(void)
|
|
||||||
{ myPacketsTcp = 0; myBytesTcp = 0; myPacketsUdp = 0; myBytesUdp = 0; }
|
|
||||||
long myPacketsTcp;
|
|
||||||
long myBytesTcp;
|
|
||||||
long myPacketsUdp;
|
|
||||||
long myBytesUdp;
|
|
||||||
};
|
|
||||||
AREXPORT void trackPacketSent(ArNetPacket *packet, bool tcp);
|
|
||||||
AREXPORT void trackPacketReceived(ArNetPacket *packet, ArTypes::UByte2);
|
|
||||||
std::map<ArTypes::UByte2, Tracker *> myTrackingSentMap;
|
|
||||||
std::map<ArTypes::UByte2, Tracker *> myTrackingReceivedMap;
|
|
||||||
bool myLogPasswordFailureVerbosely;
|
|
||||||
|
|
||||||
bool myAllowSlowPackets;
|
|
||||||
bool myAllowIdlePackets;
|
|
||||||
|
|
||||||
ArThread *mySlowIdleThread;
|
|
||||||
|
|
||||||
bool myHaveSlowPackets;
|
|
||||||
bool myHaveIdlePackets;
|
|
||||||
|
|
||||||
ArMutex mySlowPacketsMutex;
|
|
||||||
std::list<ArNetPacket *> mySlowPackets;
|
|
||||||
ArMutex myIdlePacketsMutex;
|
|
||||||
std::list<ArNetPacket *> myIdlePackets;
|
|
||||||
|
|
||||||
/// Number of "request transactions" that are currently in progress for this client.
|
|
||||||
int myRequestTransactionCount;
|
|
||||||
/// Mutex for multi-threaded access to the request transaction count.
|
|
||||||
ArMutex myRequestTransactionMutex;
|
|
||||||
|
|
||||||
ArTime myCreationTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,40 +0,0 @@
|
|||||||
#ifndef ARSERVERCLIENTDATA_H
|
|
||||||
#define ARSERVERCLIENTDATA_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
|
|
||||||
class ArServerClientData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ArServerClientData(ArServerData *serverData, long mSecInterval,
|
|
||||||
ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
myServerData = serverData;
|
|
||||||
myMSecInterval = mSecInterval;
|
|
||||||
myPacket.duplicatePacket(packet);
|
|
||||||
myReadLength = myPacket.getReadLength();
|
|
||||||
myLastSent.setToNow();
|
|
||||||
}
|
|
||||||
virtual ~ArServerClientData() {}
|
|
||||||
ArServerData *getServerData(void) { return myServerData; }
|
|
||||||
long getMSec(void) { return myMSecInterval; }
|
|
||||||
ArNetPacket *getPacket(void)
|
|
||||||
{ myPacket.setReadLength(myReadLength); return &myPacket; }
|
|
||||||
ArTime getLastSent (void) { return myLastSent; }
|
|
||||||
void setLastSentToNow(void) { myLastSent.setToNow(); }
|
|
||||||
void setMSec(long mSec) { myMSecInterval = mSec; }
|
|
||||||
void setPacket(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
myPacket.duplicatePacket(packet);
|
|
||||||
myReadLength = myPacket.getReadLength();
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
ArServerData *myServerData;
|
|
||||||
long myMSecInterval;
|
|
||||||
ArNetPacket myPacket;
|
|
||||||
unsigned int myReadLength;
|
|
||||||
ArTime myLastSent;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARSERVERCLIENTDATA_H
|
|
@ -1,133 +0,0 @@
|
|||||||
#ifndef ARSERVERCLIENTIDENTIFIER_H
|
|
||||||
#define ARSERVERCLIENTIDENTIFIER_H
|
|
||||||
|
|
||||||
|
|
||||||
/// Class that holds an identifier for a particular serverClient
|
|
||||||
class ArServerClientIdentifier
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
ArServerClientIdentifier() { myConnectionID = 0; rebuildIDString(); }
|
|
||||||
/// Destructor
|
|
||||||
virtual ~ArServerClientIdentifier() {}
|
|
||||||
/// Gets an ID string which is just the other information in this combined
|
|
||||||
const char *getIDString(void) { return myIDString.c_str(); }
|
|
||||||
/// set the id num
|
|
||||||
void setConnectionID(ArTypes::UByte4 idNum) { myConnectionID = idNum; rebuildIDString(); }
|
|
||||||
/// Gets the id num
|
|
||||||
ArTypes::UByte4 getConnectionID(void) { return myConnectionID; }
|
|
||||||
/// Sets the self identifier
|
|
||||||
void setSelfIdentifier(const char *selfIdentifier)
|
|
||||||
{
|
|
||||||
if (selfIdentifier != NULL)
|
|
||||||
mySelfIdentifier = selfIdentifier;
|
|
||||||
else
|
|
||||||
mySelfIdentifier = "";
|
|
||||||
rebuildIDString();
|
|
||||||
}
|
|
||||||
/// Gets the self identifier
|
|
||||||
const char *getSelfIdentifier(void) { return mySelfIdentifier.c_str(); }
|
|
||||||
/// Sets the here goal
|
|
||||||
void setHereGoal(const char *selfIdentifier)
|
|
||||||
{
|
|
||||||
if (selfIdentifier != NULL)
|
|
||||||
myHereGoal = selfIdentifier;
|
|
||||||
else
|
|
||||||
myHereGoal = "";
|
|
||||||
rebuildIDString();
|
|
||||||
}
|
|
||||||
/// Gets the here goal
|
|
||||||
const char *getHereGoal(void) { return myHereGoal.c_str(); }
|
|
||||||
/// Sees if an identifier matches
|
|
||||||
/**
|
|
||||||
It can either match id, or the other parameters (for the other
|
|
||||||
parameters if the self id matches its a match, otherwise it
|
|
||||||
checks the here goal, and if that matches its a match)... this
|
|
||||||
is so that if someone's set a self id but changes their here
|
|
||||||
goal they'll still get their messages
|
|
||||||
*/
|
|
||||||
bool matches(ArServerClientIdentifier identifier,
|
|
||||||
bool matchConnectionID)
|
|
||||||
{
|
|
||||||
// if the ID's don't match then they don't match, this doesn't
|
|
||||||
// make sure they've been set like the others because here if it
|
|
||||||
// isn't set it means its an old client, but if its set it means
|
|
||||||
// its a new client... and if its one old client, we want to
|
|
||||||
// send stuff to all the old clients (since we don't know which
|
|
||||||
// one did it)
|
|
||||||
if (matchConnectionID && getConnectionID() != identifier.getConnectionID())
|
|
||||||
return false;
|
|
||||||
else if (matchConnectionID)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// if they both have identifiers see if they match (if they do
|
|
||||||
// then we're good)
|
|
||||||
if (getSelfIdentifier() != NULL && getSelfIdentifier()[0] != '\0' &&
|
|
||||||
identifier.getSelfIdentifier() != NULL &&
|
|
||||||
identifier.getSelfIdentifier()[0] != '\0' &&
|
|
||||||
strcasecmp(getSelfIdentifier(), identifier.getSelfIdentifier()) == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// if they both have here goals see if they match
|
|
||||||
if (getHereGoal() != NULL && getHereGoal()[0] != '\0' &&
|
|
||||||
identifier.getHereGoal() != NULL &&
|
|
||||||
identifier.getHereGoal()[0] != '\0' &&
|
|
||||||
strcasecmp(getHereGoal(), identifier.getHereGoal()) != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
void rebuildIDString(void)
|
|
||||||
{
|
|
||||||
char buf[1024];
|
|
||||||
bool first = true;
|
|
||||||
buf[0] = '\0';
|
|
||||||
sprintf(buf, "connectionID %u", myConnectionID);
|
|
||||||
if (myConnectionID != 0 || !mySelfIdentifier.empty() ||
|
|
||||||
!myHereGoal.empty())
|
|
||||||
{
|
|
||||||
if (myConnectionID != 0)
|
|
||||||
{
|
|
||||||
if (first)
|
|
||||||
myIDString = "(";
|
|
||||||
else
|
|
||||||
myIDString += " ";
|
|
||||||
first = false;
|
|
||||||
myIDString += buf;
|
|
||||||
}
|
|
||||||
if (!mySelfIdentifier.empty())
|
|
||||||
{
|
|
||||||
if (first)
|
|
||||||
myIDString = "(";
|
|
||||||
else
|
|
||||||
myIDString += " ";
|
|
||||||
first = false;
|
|
||||||
myIDString += "selfID ";
|
|
||||||
myIDString += mySelfIdentifier;
|
|
||||||
}
|
|
||||||
if (!myHereGoal.empty())
|
|
||||||
{
|
|
||||||
if (first)
|
|
||||||
myIDString = "(";
|
|
||||||
else
|
|
||||||
myIDString += " ";
|
|
||||||
first = false;
|
|
||||||
myIDString += "hereGoal ";
|
|
||||||
myIDString += myHereGoal;
|
|
||||||
}
|
|
||||||
myIDString += ")";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
myIDString = "";
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
// the identifiers
|
|
||||||
ArTypes::UByte4 myConnectionID;
|
|
||||||
std::string mySelfIdentifier;
|
|
||||||
std::string myHereGoal;
|
|
||||||
|
|
||||||
// the string that describes them just for debugging
|
|
||||||
std::string myIDString;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ArServerClientIdentifier
|
|
@ -1,49 +0,0 @@
|
|||||||
#ifndef NLSERVERCOMMANDS_H
|
|
||||||
#define NLSERVERCOMMANDS_H
|
|
||||||
|
|
||||||
/**
|
|
||||||
The commands from the server to the client
|
|
||||||
**/
|
|
||||||
|
|
||||||
class ArServerCommands
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum ServerCommands {
|
|
||||||
SHUTDOWN = 1, ///< Closes the connection
|
|
||||||
INTRODUCTION = 2, ///< Introduces the server to the client
|
|
||||||
UDP_INTRODUCTION = 3, ///< Udp introduction of the server to the client
|
|
||||||
UDP_CONFIRMATION = 4, ///< Confirmation Udp was received from client
|
|
||||||
CONNECTED = 5, ///< Server accepts clients connection
|
|
||||||
REJECTED = 6, ///< Server rejects clients connection, has a byte2, then a string.... these reasons (1 = bad username password, string then is empty, 2 = rejecting connection because using central server, string then is central server IP, 3 = client rejecting server because server has wrong protocol, 4 = server rejected client because client has wrong protocol, 5 = maxClients exceeded, 6 = type of client is specified, but doesn't match)
|
|
||||||
TCP_ONLY = 7, ///< Server tells client to only send TCP
|
|
||||||
LIST = 129, ///< Map of the string names for a type to a number along with a long description of the data type
|
|
||||||
LISTSINGLE = 130, ///< Map of a single type to a number (for late additions to server) along with its description
|
|
||||||
LISTARGRET = 131, ///< Map of the number to their arguments and returns descriptions
|
|
||||||
LISTARGRETSINGLE = 132, ///< Map of a single type to a number (for late additions to server) along with its argument and return descriptions
|
|
||||||
LISTGROUPANDFLAGS = 133, ///< Map of the number to their command groups and data flags
|
|
||||||
LISTGROUPANDFLAGSSINGLE = 134 ///< Map of a single type to a number (for late additions to server) along with its command group and data flags
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Type
|
|
||||||
{
|
|
||||||
TYPE_UNSPECIFIED = 0, /// Unspecified (anything can connect)
|
|
||||||
TYPE_REAL = 1, ///< Only real robots permitted to connect
|
|
||||||
TYPE_SIMULATED = 2, ///< Only simulated robots permitted to connect
|
|
||||||
TYPE_NONE = 3 ///< Nothing is permitted to connect
|
|
||||||
};
|
|
||||||
static const char *toString(Type type)
|
|
||||||
{
|
|
||||||
if (type == TYPE_UNSPECIFIED)
|
|
||||||
return "unspecified";
|
|
||||||
else if (type == TYPE_REAL)
|
|
||||||
return "real";
|
|
||||||
else if (type == TYPE_SIMULATED)
|
|
||||||
return "simulated";
|
|
||||||
else if (type == TYPE_NONE)
|
|
||||||
return "none";
|
|
||||||
else
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // NLSERVERCOMMANDS_H
|
|
@ -1,70 +0,0 @@
|
|||||||
#ifndef ARSERVERDATA_H
|
|
||||||
#define ARSERVERDATA_H
|
|
||||||
|
|
||||||
/// class to hold information about the different data the server has
|
|
||||||
/**
|
|
||||||
This class is mostly just for holding all the information about one
|
|
||||||
of the server data entires in one convenient spot
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
|
|
||||||
class ArServerClient;
|
|
||||||
class ArNetPacket;
|
|
||||||
|
|
||||||
|
|
||||||
class ArServerData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerData(
|
|
||||||
const char *name, const char *description, unsigned int command,
|
|
||||||
ArFunctor2<ArServerClient *, ArNetPacket *> *functor,
|
|
||||||
const char *argumentDescription, const char *returnDescription,
|
|
||||||
const char *commandGroup = NULL, const char *dataFlags = NULL,
|
|
||||||
ArRetFunctor1<long, unsigned int> *getFrequencyFunctor = NULL,
|
|
||||||
ArFunctor2<long, unsigned int> *requestChangedFunctor = NULL,
|
|
||||||
ArRetFunctor2<bool, ArServerClient *, ArNetPacket *>
|
|
||||||
*requestOnceFunctor = NULL);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerData();
|
|
||||||
const char *getName(void) { return myName.c_str(); }
|
|
||||||
const char *getDescription(void) { return myDescription.c_str(); }
|
|
||||||
unsigned int getCommand(void) { return myCommand; }
|
|
||||||
ArFunctor2<ArServerClient *, ArNetPacket *> *getFunctor(void)
|
|
||||||
{ return myFunctor; };
|
|
||||||
const char *getArgumentDescription(void)
|
|
||||||
{ return myArgumentDescription.c_str(); }
|
|
||||||
const char *getReturnDescription(void)
|
|
||||||
{ return myReturnDescription.c_str(); }
|
|
||||||
const char *getCommandGroup(void)
|
|
||||||
{ return myCommandGroup.c_str(); }
|
|
||||||
ArRetFunctor2<bool, ArServerClient *, ArNetPacket *> *getRequestOnceFunctor(void)
|
|
||||||
{ return myRequestOnceFunctor; }
|
|
||||||
AREXPORT bool hasDataFlag(const char *dataFlag);
|
|
||||||
AREXPORT bool addDataFlags(const char *dataFlags);
|
|
||||||
AREXPORT bool remDataFlag(const char *dataFlag);
|
|
||||||
bool isSlowPacket(void) { return mySlowPacket; }
|
|
||||||
bool isIdlePacket(void) { return myIdlePacket; }
|
|
||||||
const char *getDataFlagsString(void)
|
|
||||||
{ return myDataFlagsBuilder.getFullString(); }
|
|
||||||
AREXPORT void callRequestChangedFunctor(void);
|
|
||||||
protected:
|
|
||||||
std::string myName;
|
|
||||||
std::string myDescription;
|
|
||||||
std::string myArgumentDescription;
|
|
||||||
std::string myReturnDescription;
|
|
||||||
std::string myCommandGroup;
|
|
||||||
std::string myRawDataFlags;
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
ArArgumentBuilder myDataFlagsBuilder;
|
|
||||||
unsigned int myCommand;
|
|
||||||
ArFunctor2<ArServerClient *, ArNetPacket *> *myFunctor;
|
|
||||||
ArRetFunctor1<long, unsigned int> *myGetFrequencyFunctor;
|
|
||||||
ArFunctor2<long, unsigned int> *myRequestChangedFunctor;
|
|
||||||
ArRetFunctor2<bool, ArServerClient *, ArNetPacket *> *myRequestOnceFunctor;
|
|
||||||
bool mySlowPacket;
|
|
||||||
bool myIdlePacket;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARSERVERDATA_H
|
|
@ -1,244 +0,0 @@
|
|||||||
#ifndef ARSERVERFILEUTILS_H
|
|
||||||
#define ARSERVERFILEUTILS_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
|
|
||||||
|
|
||||||
/// Provides a list of files to clients
|
|
||||||
/**
|
|
||||||
* @note Linux only
|
|
||||||
*
|
|
||||||
This class is set up so that a client can get file information from
|
|
||||||
the robot, this class ONLY lists files, and doesn't do any
|
|
||||||
manipulation of them. You should use this class by using
|
|
||||||
ArClientFileLister and NOT by using this classes interface
|
|
||||||
directly, this is because the API is and will remain fairly
|
|
||||||
volatile, just use ArClientFileLister, if you need more
|
|
||||||
functionality let us know and we'll add it if its reasonable.
|
|
||||||
**/
|
|
||||||
class ArServerFileLister
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerFileLister(ArServerBase *server, const char *topDir,
|
|
||||||
const char *defaultUploadDownloadDir = NULL);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerFileLister();
|
|
||||||
/// The function that gets the directory listing
|
|
||||||
AREXPORT void getDirListing(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// The function that gets the directory listing in a better way
|
|
||||||
AREXPORT void getDirListingMultiplePackets(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// The function that gets the default upload/download dir
|
|
||||||
AREXPORT void getDefaultUploadDownloadDir(
|
|
||||||
ArServerClient *client, ArNetPacket *packet);
|
|
||||||
protected:
|
|
||||||
char myBaseDir[2048];
|
|
||||||
std::string myDefaultUploadDownloadDir;
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArFunctor2C<ArServerFileLister, ArServerClient *,
|
|
||||||
ArNetPacket *> myGetDirListingCB;
|
|
||||||
ArFunctor2C<ArServerFileLister, ArServerClient *,
|
|
||||||
ArNetPacket *> myGetDirListingMultiplePacketsCB;
|
|
||||||
ArFunctor2C<ArServerFileLister, ArServerClient *,
|
|
||||||
ArNetPacket *> myGetDefaultUploadDownloadDirCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// ArServerFileToClient
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Gets files from the server
|
|
||||||
/**
|
|
||||||
* @note Linux only
|
|
||||||
*
|
|
||||||
This class is set up so that a client can get files the robot, this
|
|
||||||
class ONLY gets files. You should use this class by using
|
|
||||||
ArClientFileToClient and NOT by using this classes interface
|
|
||||||
directly, this is because the API is and will remain fairly
|
|
||||||
volatile... if you need more functionality let us know and we'll
|
|
||||||
add it if its reasonable.
|
|
||||||
**/
|
|
||||||
class ArServerFileToClient
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerFileToClient(ArServerBase *server, const char *topDir);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerFileToClient();
|
|
||||||
/// Gets the file
|
|
||||||
AREXPORT void getFile(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Gets the file, and sets its timestamp to the original server value
|
|
||||||
AREXPORT void getFileWithTimestamp(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
AREXPORT void doGetFile(ArServerClient *client,
|
|
||||||
ArNetPacket *packet,
|
|
||||||
bool isSetTimestamp);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
char myBaseDir[2048];
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArFunctor2C<ArServerFileToClient,
|
|
||||||
ArServerClient *,
|
|
||||||
ArNetPacket *> myGetFileCB;
|
|
||||||
|
|
||||||
ArFunctor2C<ArServerFileToClient,
|
|
||||||
ArServerClient *,
|
|
||||||
ArNetPacket *> myGetFileWithTimestampCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// ArServerFileToClient
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Puts files onto the server
|
|
||||||
/**
|
|
||||||
* @note Linux only
|
|
||||||
*
|
|
||||||
This class is set up so that a client can put files on the robot,
|
|
||||||
this class ONLY puts files. This class will take a file from a
|
|
||||||
client, writing it into the tempDir given in the constructor, then
|
|
||||||
after receiving the file it'll move it over to the actual location
|
|
||||||
requested. You should use this class by using ArClientFileToClient
|
|
||||||
and NOT by using this classes interface directly, this is because
|
|
||||||
the API is and will remain fairly volatile... if you need more
|
|
||||||
functionality let us know and we'll add it if its reasonable.
|
|
||||||
**/
|
|
||||||
class ArServerFileFromClient
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerFileFromClient(ArServerBase *server, const char *topDir,
|
|
||||||
const char *tempDir);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerFileFromClient();
|
|
||||||
/// Puts the file
|
|
||||||
AREXPORT void putFile(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Puts the file with interleaved responses
|
|
||||||
AREXPORT void putFileInterleaved(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Puts the file
|
|
||||||
AREXPORT void putFileWithTimestamp(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Puts the file with interleaved responses
|
|
||||||
AREXPORT void putFileWithTimestampInterleaved(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Adds a callback to be called before moving from temp dir to final loc
|
|
||||||
AREXPORT void addPreMoveCallback(
|
|
||||||
ArFunctor *functor, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called before moving from temp dir to final loc
|
|
||||||
AREXPORT void remPreMoveCallback(ArFunctor *functor);
|
|
||||||
/// Adds a callback to be called after moving from temp dir to final loc
|
|
||||||
AREXPORT void addPostMoveCallback(
|
|
||||||
ArFunctor *functor, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called after moving from temp dir to final loc
|
|
||||||
AREXPORT void remPostMoveCallback(ArFunctor *functor);
|
|
||||||
/// Internal call for getting the name of the file we're moving
|
|
||||||
const char *getMovingFileName(void) { return myMovingFileName.c_str(); }
|
|
||||||
protected:
|
|
||||||
|
|
||||||
AREXPORT void internalPutFile(ArServerClient *client,
|
|
||||||
ArNetPacket *packet,
|
|
||||||
bool interleaved,
|
|
||||||
bool isSetTimestamp);
|
|
||||||
|
|
||||||
char myBaseDir[2048];
|
|
||||||
char myTempDir[2048];
|
|
||||||
ArServerBase *myServer;
|
|
||||||
std::list<ArFunctor *> myPreMoveCallbacks;
|
|
||||||
std::list<ArFunctor *> myPostMoveCallbacks;
|
|
||||||
|
|
||||||
ArFunctor2C<ArServerFileFromClient, ArServerClient *,
|
|
||||||
ArNetPacket *> myPutFileCB;
|
|
||||||
ArFunctor2C<ArServerFileFromClient, ArServerClient *,
|
|
||||||
ArNetPacket *> myPutFileInterleavedCB;
|
|
||||||
ArFunctor2C<ArServerFileFromClient, ArServerClient *,
|
|
||||||
ArNetPacket *> myPutFileWithTimestampCB;
|
|
||||||
ArFunctor2C<ArServerFileFromClient, ArServerClient *,
|
|
||||||
ArNetPacket *> myPutFileWithTimestampInterleavedCB;
|
|
||||||
|
|
||||||
std::string myMovingFileName;
|
|
||||||
|
|
||||||
int myFileNumber;
|
|
||||||
|
|
||||||
class FileInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FileInfo() { myFile = NULL; }
|
|
||||||
virtual ~FileInfo() {}
|
|
||||||
std::string myRealFileName;
|
|
||||||
std::string myTempFileName;
|
|
||||||
FILE *myFile;
|
|
||||||
ArTime myStartedTransfer;
|
|
||||||
ArTime myLastActivity;
|
|
||||||
time_t myFileTimestamp;
|
|
||||||
// pointer to the client that is sending the file, we can compare
|
|
||||||
// this against other client pointers but WE CANNOT ACCESS THE OLD
|
|
||||||
// ONE since its possible that it disconnected and is an invalid
|
|
||||||
// pointer
|
|
||||||
ArServerClient *myClient;
|
|
||||||
ArTime myClientCreationTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
// map of raw filenames to FileInfo (so we don't have to walk it all the time)
|
|
||||||
std::map<std::string, FileInfo *> myMap;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/// Deletes files from the server
|
|
||||||
/**
|
|
||||||
* @note Linux only
|
|
||||||
*
|
|
||||||
This class is set up so that a client can get delete files on the
|
|
||||||
robot, this class ONLY deletes files. You should use this class by
|
|
||||||
using ArClientDeleteFileOnServer and NOT by using this classes
|
|
||||||
interface directly, this is because the API is and will remain
|
|
||||||
fairly volatile... if you need more functionality let us know and
|
|
||||||
we'll add it if its reasonable.
|
|
||||||
**/
|
|
||||||
class ArServerDeleteFileOnServer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerDeleteFileOnServer(ArServerBase *server,
|
|
||||||
const char *topDir);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerDeleteFileOnServer();
|
|
||||||
/// Deletes the file
|
|
||||||
AREXPORT void deleteFile(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Adds a callback to be called before moving from temp dir to final loc
|
|
||||||
AREXPORT void addPreDeleteCallback(
|
|
||||||
ArFunctor *functor, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called before moving from temp dir to final loc
|
|
||||||
AREXPORT void remPreDeleteCallback(ArFunctor *functor);
|
|
||||||
/// Adds a callback to be called after moving from temp dir to final loc
|
|
||||||
AREXPORT void addPostDeleteCallback(
|
|
||||||
ArFunctor *functor, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called after moving from temp dir to final loc
|
|
||||||
AREXPORT void remPostDeleteCallback(ArFunctor *functor);
|
|
||||||
/// Gets the filename of the file we're deleting
|
|
||||||
const char *getDeletingFileName(void) { return myDeletingFileName.c_str(); }
|
|
||||||
protected:
|
|
||||||
char myBaseDir[2048];
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArFunctor2C<ArServerDeleteFileOnServer, ArServerClient *,
|
|
||||||
ArNetPacket *> myDeleteFileCB;
|
|
||||||
std::string myDeletingFileName;
|
|
||||||
std::list<ArFunctor *> myPreDeleteCallbacks;
|
|
||||||
std::list<ArFunctor *> myPostDeleteCallbacks;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARSERVERFILEUTILS_H
|
|
@ -1,418 +0,0 @@
|
|||||||
#ifndef ARSERVERHANDLERCAMERA_H
|
|
||||||
#define ARSERVERHANDLERCAMERA_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
/** Accepts and processes camera pan/tilt/zoom requests from the client, and
|
|
||||||
provides information about the camera (such as its current position).
|
|
||||||
|
|
||||||
The following requests are accepted. Arguments and return values are stored
|
|
||||||
in the packet as signed 16-bit values. (They are converted to double-precision
|
|
||||||
floating point values when received by dividing by 100; to store floating
|
|
||||||
point values, multiply by 100 first:
|
|
||||||
<code>packet.byte2ToBuf((ArTypes::Byte2)(100.0 * doubleVal));</code> or
|
|
||||||
see also getDoubleFromPacket() and addDoubleToPacket().)
|
|
||||||
|
|
||||||
Each request name is suffixed by the name of the camera to control. If more than one
|
|
||||||
camera is used, each can have a different name (given in the constructor), and commands for the different cameras
|
|
||||||
are differentiated by appending the camera name to the command requests listed below. For example,
|
|
||||||
an ArServerHandlerCamera with camera name of "A" would receive "setCameraRelA". while the
|
|
||||||
handler with camera name of "B" would receive "setCameraAbsB". If no camera name is given
|
|
||||||
(typical if just one ArServerHandlerCamera object is created),
|
|
||||||
just the base requests are used. To provide information to the client about the multiple cameras and their names, use ArCameraCollection and an ArServerHandlerCameraCollection object.
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr><td>setCameraRel</td> <td> Command to pan and tilt the camera from the
|
|
||||||
current position by the values given in the
|
|
||||||
first two arguments. If a third argument is
|
|
||||||
given, zoom from the current position.</td></tr>
|
|
||||||
<tr><td>setCameraAbs</td> <td> Command to pan and tilt the camera to the
|
|
||||||
absolute positions given by the first two
|
|
||||||
arguments. If a third argument is given, set
|
|
||||||
the zoom to that absolute position.</td></tr>
|
|
||||||
<tr><td>setCameraPct</td> <td> Command to pan and tilt the camera to the
|
|
||||||
given positions as percentage of their overall
|
|
||||||
ranges.</td></tr>
|
|
||||||
<tr><td>getCameraData</td> <td>Data request to get current pan and tilt values.
|
|
||||||
Also get zoom value if available.</td></tr>
|
|
||||||
<tr><td>getCameraInfo</td> <td>Data request to get pan and tilt ranges. Also
|
|
||||||
gets the zoom range if available.</td></tr>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
In addition, some older camera requests are accepted for partial backwards
|
|
||||||
compatability with old clients: cameraUpdate, cameraInfo, cameraAbs, camera,
|
|
||||||
and cameraPct. These requests take values as single bytes, rather than multiplied
|
|
||||||
floats as 2-bytes as the above commands do. Note, these cannot be used in a multi-camera
|
|
||||||
configuration.
|
|
||||||
|
|
||||||
These requests are in a user permission group called CameraControl.
|
|
||||||
|
|
||||||
In addition to positioning the camera, ArServerHandlerCamera can support additional "modes" for camera control, if additional code is added to update ArServerHandlerCamera with the state of other systems such as navigation. The additional modes are LookAtGoal and LookAtPoint. An external system such as navigation (e.g. ARNL) must keep the camera handler object updated with its current goal by calling cameraModeLookAtGoalSetGoal() and cameraModeLookAtGoalClearGoal(), and ArServerHandlerCamera will continuously point the camera at that point or goal as the robot moves. The network requests associated with setting modes are:
|
|
||||||
<ul>
|
|
||||||
<li>getCameraModeList<CameraName>: Gets the list of modes that this camera
|
|
||||||
supports </li>
|
|
||||||
<li>getCameraModeUpdated<CameraName>: Sent when the mode is changed </li>
|
|
||||||
<li>setCameraMode<CameraName>: Command to change the camera mode (give mode name) </li>
|
|
||||||
</ul>
|
|
||||||
*/
|
|
||||||
class ArServerHandlerCamera : public ArCameraCollectionItem
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
static const char *CONTROL_COMMAND_GROUP;
|
|
||||||
static const char *INFO_COMMAND_GROUP;
|
|
||||||
static const char *NO_ARGS;
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Constructs a new handler for the specified camera.
|
|
||||||
/**
|
|
||||||
* @param cameraName the unique char * name of the associated camera
|
|
||||||
* @param server the ArServerBase * used to send/receive requests
|
|
||||||
* @param robot the associated ArRobot *
|
|
||||||
* @param camera the ArPTZ * that provides access to the actual camera
|
|
||||||
* @param collection the ArCameraCollection * to which to add the
|
|
||||||
* camera command information; if NULL, then addToCameraCollection()
|
|
||||||
* must be called manually.
|
|
||||||
**/
|
|
||||||
AREXPORT ArServerHandlerCamera(const char *cameraName,
|
|
||||||
ArServerBase *server,
|
|
||||||
ArRobot *robot,
|
|
||||||
ArPTZ *camera,
|
|
||||||
ArCameraCollection *collection);
|
|
||||||
|
|
||||||
/// Constructor
|
|
||||||
/**
|
|
||||||
* This constructor is maintained for backwards compatibility. It will
|
|
||||||
* not work in a multi-camera configuration.
|
|
||||||
* @deprecated
|
|
||||||
* @param server the ArServerBase * used to send/receive requests
|
|
||||||
* @param robot the associated ArRobot *
|
|
||||||
* @param camera the ArPTZ * that provides access to the actual camera
|
|
||||||
**/
|
|
||||||
AREXPORT ArServerHandlerCamera(ArServerBase *server,
|
|
||||||
ArRobot *robot,
|
|
||||||
ArPTZ *camera);
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerHandlerCamera();
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// ArCameraCollectionItem Interface:
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Sends the camera absolute commands to the camera (and puts it in position mode)
|
|
||||||
AREXPORT void setCameraAbs(double pan, double tilt, double zoom,
|
|
||||||
bool lockRobot = true);
|
|
||||||
|
|
||||||
/// Sends the camera relative commands to the camera (and puts it in position mode)
|
|
||||||
AREXPORT void setCameraRel(double pan, double tilt, double zoom,
|
|
||||||
bool lockRobot = true);
|
|
||||||
|
|
||||||
/// Sends the camera percent commands to the camera (and puts it in position mode)
|
|
||||||
AREXPORT void setCameraPct(double panPct, double tiltPct,
|
|
||||||
bool lockRobot = true);
|
|
||||||
|
|
||||||
/// Resets the camera
|
|
||||||
AREXPORT void resetCamera(bool lockRobot = true);
|
|
||||||
|
|
||||||
/// Puts the camera into a mode where it will look at the goal
|
|
||||||
AREXPORT void cameraModeLookAtGoal(void);
|
|
||||||
|
|
||||||
/// Puts the camera into a mode where it will look at a point
|
|
||||||
AREXPORT void cameraModeLookAtPoint(ArPose pose, bool controlZoom = true);
|
|
||||||
|
|
||||||
/// Sets the goal for the camera mode that points at the goal
|
|
||||||
AREXPORT void cameraModeLookAtGoalSetGoal(ArPose pose);
|
|
||||||
/// Clears the goal for the camera mode that points at the goal
|
|
||||||
AREXPORT void cameraModeLookAtGoalClearGoal(void);
|
|
||||||
|
|
||||||
/// Puts the camera in position mode
|
|
||||||
AREXPORT void cameraModePosition(void);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Returns the name of the camera that is controlled by this handler.
|
|
||||||
/**
|
|
||||||
* @return char * the unique name of the associated camera (if specified in
|
|
||||||
* the constructor)
|
|
||||||
**/
|
|
||||||
AREXPORT const char *getCameraName();
|
|
||||||
|
|
||||||
/// Adds the camera commands to the given collection.
|
|
||||||
/**
|
|
||||||
* @param collection the ArCameraCollection to which to add the camera commands
|
|
||||||
**/
|
|
||||||
AREXPORT virtual void addToCameraCollection(ArCameraCollection &collection);
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Packet Handlers:
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// New methods that send/receive "double"s
|
|
||||||
|
|
||||||
/// Handles the getCameraData network packet, returning information in double format.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleGetCameraData(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the getCameraInfo network packet, returning information in double format.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleGetCameraInfo(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the setCameraAbs network packet, with information in double format.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleSetCameraAbs(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the setCameraPct network packet, with information in double format.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleSetCameraPct(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the setCameraRel network packet, with information in double format.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleSetCameraRel(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the mode list for the camera
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleGetCameraModeList(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handle the mode request, generally this is sent when it changes
|
|
||||||
/**
|
|
||||||
* Refer to handleSetCameraMode for a description of the supported modes
|
|
||||||
* and the various packet structures.
|
|
||||||
*
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleCameraModeUpdated(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handle the set mode request
|
|
||||||
/**
|
|
||||||
* The following modes are currently supported:
|
|
||||||
* - Position: The user controls the camera position; no additional parameters
|
|
||||||
* in the packet
|
|
||||||
* - LookAtGoal: The robot automatically points the camera in the direction
|
|
||||||
* of its destination goal; no additional parameters in the packet
|
|
||||||
* - LookAtPoint: The robot "looks" at a specified point in the map; the packet
|
|
||||||
* contains: byte4, the x coordinate; byte4, the y coordinate
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleSetCameraMode(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handle the reset
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleResetCamera(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
// Old methods that send/receive ints
|
|
||||||
|
|
||||||
/// Handles the camera network packet, with information stored as byte integers.
|
|
||||||
AREXPORT void camera(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// Handles the cameraAbs network packet, with information stored as byte integers.
|
|
||||||
AREXPORT void cameraAbs(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// Handles the cameraPct network packet, with information stored as byte integers.
|
|
||||||
AREXPORT void cameraPct(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// Handles the cameraUpdate network packet, with information returned as byte2 integers.
|
|
||||||
AREXPORT void cameraUpdate(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// Handles the cameraInfo network packet, with information returned as byte2 integers.
|
|
||||||
AREXPORT void cameraInfo(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Helper Methods:
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
enum {
|
|
||||||
DOUBLE_FACTOR = 100 ///< Multiplier for putting/getting "double" values to/from a packet
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Adds the given value as a "double" to the given network packet.
|
|
||||||
/**
|
|
||||||
* The "double" value is really a 2-byte integer multiplied by the DOUBLE_FACTOR.
|
|
||||||
**/
|
|
||||||
AREXPORT void addDoubleToPacket(double val,
|
|
||||||
ArNetPacket &packet)
|
|
||||||
{
|
|
||||||
// TODO: Does this need to be rounded? Any error/overflow checking?
|
|
||||||
packet.byte2ToBuf((ArTypes::Byte2) (val * DOUBLE_FACTOR));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Reads a "double" value from the given network packet.
|
|
||||||
/**
|
|
||||||
* The "double" value is really a 2-byte integer multiplied by the DOUBLE_FACTOR.
|
|
||||||
**/
|
|
||||||
AREXPORT double getDoubleFromPacket(ArNetPacket &packet)
|
|
||||||
{
|
|
||||||
int tempVal = packet.bufToByte2();
|
|
||||||
return ((double) tempVal / (double) DOUBLE_FACTOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the current camera zoom as a ratio of its zoom range.
|
|
||||||
AREXPORT double getCurrentZoomRatio()
|
|
||||||
{
|
|
||||||
if (myCamera->getMaxZoom() != myCamera->getMinZoom()) {
|
|
||||||
|
|
||||||
return ((double)(myCamera->getZoom() - myCamera->getMinZoom()))
|
|
||||||
/ ((double)(myCamera->getMaxZoom() - myCamera->getMinZoom()));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} // end method getCurrentZoomRatio
|
|
||||||
|
|
||||||
|
|
||||||
/// Converts the given absolute zoom value to a ratio of the camera's zoom range.
|
|
||||||
AREXPORT double getZoomRatio(double absZoom)
|
|
||||||
{
|
|
||||||
if (myCamera->getMaxZoom() != myCamera->getMinZoom()) {
|
|
||||||
|
|
||||||
return ((double)(absZoom - myCamera->getMinZoom()))
|
|
||||||
/ ((double)(myCamera->getMaxZoom() - myCamera->getMinZoom()));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} // end method getZoomRatio
|
|
||||||
|
|
||||||
|
|
||||||
/// Gets the range of the camera's zoom.
|
|
||||||
AREXPORT double getZoomRange()
|
|
||||||
{
|
|
||||||
return myCamera->getMaxZoom() - myCamera->getMinZoom();
|
|
||||||
|
|
||||||
} // end method getZoomRange
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/// Performs initialization common to all constructors.
|
|
||||||
void init();
|
|
||||||
|
|
||||||
/// Creates command (packet) names for the current camera.
|
|
||||||
void createCommandNames();
|
|
||||||
|
|
||||||
/// Creates the handlers for each of the supported commands.
|
|
||||||
void createCommandCBs();
|
|
||||||
|
|
||||||
/// Adds all supported commands to the server.
|
|
||||||
void addAllCommandsToServer();
|
|
||||||
|
|
||||||
/// Adds the specified command to the server.
|
|
||||||
void addCommandToServer(const char *command,
|
|
||||||
const char *description,
|
|
||||||
const char *argumentDescription,
|
|
||||||
const char *returnDescription,
|
|
||||||
const char *commandGroup);
|
|
||||||
|
|
||||||
/// Removes an unsupported command.
|
|
||||||
void removeCommand(const char *command);
|
|
||||||
|
|
||||||
/// Adds the information about all supported commands to the camera collection.
|
|
||||||
void doAddToCameraCollection(ArCameraCollection &collection);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// Associated robot (primarily used for locking)
|
|
||||||
ArRobot *myRobot;
|
|
||||||
/// Server from which requests are received
|
|
||||||
ArServerBase *myServer;
|
|
||||||
/// Camera that is controlled
|
|
||||||
ArPTZ *myCamera;
|
|
||||||
|
|
||||||
/// Unique name of the associated camera
|
|
||||||
std::string myCameraName;
|
|
||||||
/// Pointer to the camera collection (if any)
|
|
||||||
ArCameraCollection *myCameraCollection;
|
|
||||||
|
|
||||||
/// Map of ArCameraCommand names to a unique network packet name
|
|
||||||
std::map<std::string, std::string> myCommandToPacketNameMap;
|
|
||||||
/// Map of ArCameraCommand names to the preferred default request interval
|
|
||||||
std::map<std::string, int> myCommandToIntervalMap;
|
|
||||||
|
|
||||||
/// Map of ArCameraCommand names to the callback that handles the packet
|
|
||||||
std::map<std::string, ArFunctor2<ArServerClient *, ArNetPacket *> *> myCommandToCBMap;
|
|
||||||
|
|
||||||
enum CameraMode
|
|
||||||
{
|
|
||||||
CAMERA_MODE_POSITION,
|
|
||||||
CAMERA_MODE_LOOK_AT_GOAL,
|
|
||||||
CAMERA_MODE_LOOK_AT_POINT
|
|
||||||
};
|
|
||||||
|
|
||||||
ArMutex myModeMutex;
|
|
||||||
CameraMode myCameraMode;
|
|
||||||
std::map<CameraMode, std::string> myCameraModeNameMap;
|
|
||||||
ArNetPacket myCameraModePacket;
|
|
||||||
ArPose myLookAtPoint;
|
|
||||||
bool myPointResetZoom;
|
|
||||||
ArPose myGoal;
|
|
||||||
bool myGoalAchieved;
|
|
||||||
bool myGoalAchievedLast;
|
|
||||||
bool myGoalResetZoom;
|
|
||||||
|
|
||||||
|
|
||||||
void userTask(void);
|
|
||||||
void buildModePacket(void);
|
|
||||||
|
|
||||||
ArFunctorC<ArServerHandlerCamera> myUserTaskCB;
|
|
||||||
|
|
||||||
// Leaving these just in case they are used by someone...
|
|
||||||
|
|
||||||
/// Old (integer-style) handler for the camera packet.
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
**/
|
|
||||||
ArFunctor2C<ArServerHandlerCamera,
|
|
||||||
ArServerClient *, ArNetPacket *> myCameraCB;
|
|
||||||
/// Old (integer-style) handler for the cameraAbs packet.
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
**/
|
|
||||||
ArFunctor2C<ArServerHandlerCamera,
|
|
||||||
ArServerClient *, ArNetPacket *> myCameraAbsCB;
|
|
||||||
/// Old (integer-style) handler for the cameraUpdate packet.
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
**/
|
|
||||||
ArFunctor2C<ArServerHandlerCamera,
|
|
||||||
ArServerClient *, ArNetPacket *> myCameraUpdateCB;
|
|
||||||
/// Old (integer-style) handler for the cameraInfo packet.
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
**/
|
|
||||||
ArFunctor2C<ArServerHandlerCamera,
|
|
||||||
ArServerClient *, ArNetPacket *> myCameraInfoCB;
|
|
||||||
|
|
||||||
}; // end class ArServerHandlerCamera
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,142 +0,0 @@
|
|||||||
#ifndef ARSERVERHANDLERCAMERACOLLECTION_H
|
|
||||||
#define ARSERVERHANDLERCAMERACOLLECTION_H
|
|
||||||
|
|
||||||
#include <Aria.h>
|
|
||||||
#include <ArExport.h>
|
|
||||||
#include <ArFunctor.h>
|
|
||||||
#include <ArCameraCollection.h>
|
|
||||||
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
#include "ArServerClient.h"
|
|
||||||
|
|
||||||
/// Provides information to a client about different cameras and how to send requests to their different ArServerHandlerCamera and video image server objects.
|
|
||||||
/**
|
|
||||||
* ArServerHandlerCameraCollection defines the network packet handlers to
|
|
||||||
* transmit information regarding the cameras and their video streams that are installed on the robot.
|
|
||||||
*
|
|
||||||
* This class handles the following requests:
|
|
||||||
* <ul>
|
|
||||||
* <li>getCameraList: Replies with a packet containing a 2-byte integer
|
|
||||||
* indicating the number of cameras. Then, for each camera:
|
|
||||||
* <ol>
|
|
||||||
* <li>camera name (string)</li>
|
|
||||||
* <li>camera type (string)</li>
|
|
||||||
* <li>camera name for user display (string)</li>
|
|
||||||
* <li>camera type for user display (string)</li>
|
|
||||||
* <li>list of requests that can be sent for this camera, beginning with the 2-byte number of commands, then, for
|
|
||||||
* each command:
|
|
||||||
* <ol>
|
|
||||||
* <li>the generic descriptive name (string)</li>
|
|
||||||
* <li>the specific command request name (string)</li>
|
|
||||||
* <li>an appropriate frequency for making this request (4-byte integer)</li>
|
|
||||||
* </ol>
|
|
||||||
* </li>
|
|
||||||
* <li>list of parameters, beginning with the 2-byte number of parameters, then,
|
|
||||||
* for each parameter, the parameter definition/value (see ArClientArg for format).
|
|
||||||
* </li>
|
|
||||||
* </ol>
|
|
||||||
* </li>
|
|
||||||
*
|
|
||||||
* <li>setCameraParams: Set some camera parameters. Begins with camera name
|
|
||||||
* string, then for each parameter, the parameter name and value (see
|
|
||||||
* ArClientArg for the format). An empty parameter name string terminates
|
|
||||||
* the list. In reply, this handler sends a packet confirming the changes
|
|
||||||
* (see cameraParamUpdated below).</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* When a camera is added or a parameter changes, the server broadcasts the
|
|
||||||
* following packets to each client:
|
|
||||||
* <ul>
|
|
||||||
* <li>cameraListUpdate: no arguments, use getCameraList to get the new list.</li>
|
|
||||||
*
|
|
||||||
* <li>cameraParamUpdated: starts with camera name, then a list of parameter
|
|
||||||
* name and value (see ArClientArg for format). An empty parameter name
|
|
||||||
* string terminates the list.</li>
|
|
||||||
* </ul>
|
|
||||||
* Note that the cameraParamUpdated is currently only sent in response to a
|
|
||||||
* setCameraParams request. That is, it does not monitor the actual parameter
|
|
||||||
* values in the ArCameraCollection.
|
|
||||||
* <p>
|
|
||||||
* In order to manipulate a particular camera using the request names and other
|
|
||||||
* information provided by ArServerHandlerCameraCollection, see ArServerHandlerCamera and
|
|
||||||
* ArVideoServer.
|
|
||||||
*/
|
|
||||||
class ArServerHandlerCameraCollection
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
/// Name of the network packet to get the camera list.
|
|
||||||
static const char *GET_COLLECTION_PACKET_NAME;
|
|
||||||
/// Name of the network packet to set a particular camera parameter.
|
|
||||||
static const char *SET_PARAMS_PACKET_NAME;
|
|
||||||
|
|
||||||
/// Name of the network packet broadcast when the collection is modified.
|
|
||||||
static const char *COLLECTION_UPDATED_PACKET_NAME;
|
|
||||||
/// Name of the network packet broadcast when a parameter value is modified.
|
|
||||||
static const char *PARAMS_UPDATED_PACKET_NAME;
|
|
||||||
|
|
||||||
/// Command group for these packets.
|
|
||||||
static const char *COMMAND_GROUP;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// Constructor.
|
|
||||||
/**
|
|
||||||
* @param server the ArServerBase * used to send/receive requests
|
|
||||||
* @param cameraCollection the ArCameraCollection * to be transmitted
|
|
||||||
**/
|
|
||||||
AREXPORT ArServerHandlerCameraCollection(ArServerBase *server,
|
|
||||||
ArCameraCollection *cameraCollection);
|
|
||||||
/// Destructor.
|
|
||||||
AREXPORT virtual ~ArServerHandlerCameraCollection();
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// Network Packet Handlers
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Handles the request to get the camera list / collection.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that is making the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void getCameraList(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the request to edit a camera's parameters.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that is making the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void setParams(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// ArCameraCollection Modified Callback
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Callback executed when the associated camera collection is modified.
|
|
||||||
AREXPORT void handleCameraCollectionModified();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/// Disabled copy ctor
|
|
||||||
ArServerHandlerCameraCollection(const ArServerHandlerCameraCollection &);
|
|
||||||
/// Disabled assignment operator
|
|
||||||
ArServerHandlerCameraCollection &operator=(const ArServerHandlerCameraCollection &);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// The server used to send/receive requests
|
|
||||||
ArServerBase *myServer;
|
|
||||||
/// The associated camera collection
|
|
||||||
ArCameraCollection *myCameraCollection;
|
|
||||||
|
|
||||||
/// Server callback for the get camera list request
|
|
||||||
ArFunctor2<ArServerClient *, ArNetPacket *> *myGetCameraListCB;
|
|
||||||
/// Server callback for the set parameter request
|
|
||||||
ArFunctor2<ArServerClient *, ArNetPacket *> *mySetParamCB;
|
|
||||||
|
|
||||||
/// Notification callback when the camera collection has been modified
|
|
||||||
ArFunctor *myCollectionModifiedCB;
|
|
||||||
|
|
||||||
}; // end class ArServerHandlerCameraCollection
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ARSERVERHANDLERCAMERACOLLECTION_H
|
|
@ -1,125 +0,0 @@
|
|||||||
#ifndef ARSERVERHANDLERCOMMMONITOR_H
|
|
||||||
#define ARSERVERHANDLERCOMMMONITOR_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
|
|
||||||
/// Handler that enables the client to monitor communication to the robot server.
|
|
||||||
/**
|
|
||||||
* ArServerHandlerCommMonitor defines network packet handlers that simply verify
|
|
||||||
* the communication between the robot and server.
|
|
||||||
*
|
|
||||||
* This class handles the following requests:
|
|
||||||
* <ul>
|
|
||||||
* <li>heartbeatTcp: Packet broadcast (TCP) periodically to confirm that
|
|
||||||
* the server is alive.</li>
|
|
||||||
* <li>heartbeatUdp: Packet broadcast (UDP) periodically to confirm that
|
|
||||||
* the server is alive.</li>
|
|
||||||
* <li>getHeartbeatInterval: Command to return the expected heartbeat interval.
|
|
||||||
* Packet contains:
|
|
||||||
* <ol>
|
|
||||||
* <li>uByte4 : Interval (msecs)</li>
|
|
||||||
* </ol>
|
|
||||||
* <li>ackCommTcp: Command to acknowledge two-way communication over TCP.
|
|
||||||
* An empty packet is returned.</li>
|
|
||||||
* <li>ackCommUdp: Command to acknowledge two-way communication over UDP.
|
|
||||||
* An empty packet is returned.</li>
|
|
||||||
* </ul>
|
|
||||||
**/
|
|
||||||
class ArServerHandlerCommMonitor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
enum {
|
|
||||||
MIN_HEARTBEAT_INTERVAL = 100,
|
|
||||||
DEFAULT_HEARTBEAT_INTERVAL = 500
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/// Name of the network packet broadcast (TCP) to confirm the server is alive.
|
|
||||||
static const char *HEARTBEAT_TCP_PACKET_NAME;
|
|
||||||
/// Name of the network packet broadcast (UDP) to confirm the server is alive.
|
|
||||||
static const char *HEARTBEAT_UDP_PACKET_NAME;
|
|
||||||
|
|
||||||
/// Name of the network packet to get the heartbeat interval.
|
|
||||||
static const char *GET_HEARTBEAT_INTERVAL_PACKET_NAME;
|
|
||||||
/// Name of the network packet to confirm TCP communication.
|
|
||||||
static const char *ACK_COMM_TCP_PACKET_NAME;
|
|
||||||
/// Name of the network packet to confirm UDP communication.
|
|
||||||
static const char *ACK_COMM_UDP_PACKET_NAME;
|
|
||||||
|
|
||||||
|
|
||||||
static const char *COMMAND_GROUP;
|
|
||||||
static const char *NO_ARGS;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Constructs a new handler to monitor communication between the robot server and client.
|
|
||||||
/**
|
|
||||||
* @param server the ArServerBase used to send/receive requests
|
|
||||||
* @param heartBeatInterval How often to send a "heartbeat" packet to the client
|
|
||||||
**/
|
|
||||||
AREXPORT ArServerHandlerCommMonitor(ArServerBase *server,
|
|
||||||
int heartbeatInterval = DEFAULT_HEARTBEAT_INTERVAL);
|
|
||||||
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerHandlerCommMonitor();
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Packet Handlers:
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Handles the getHeartbeatInterval network packet.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleGetHeartbeatInterval(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the ackCommTcp network packet.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleAckCommTcp(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
|
|
||||||
/// Handles the ackCommUdp network packet.
|
|
||||||
/**
|
|
||||||
* @param client the ArServerClient * that sent the request
|
|
||||||
* @param packet the ArNetPacket * that contains the request
|
|
||||||
**/
|
|
||||||
AREXPORT void handleAckCommUdp(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
|
|
||||||
/// Callback for the server cycle; broadcasts heartbeat packets when interval has elapsed.
|
|
||||||
AREXPORT void cycleCallback();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// Server from which requests are received
|
|
||||||
ArServerBase *myServer;
|
|
||||||
|
|
||||||
/// Number of msecs between heartbeat broadcasts
|
|
||||||
int myHeartbeatInterval;
|
|
||||||
/// Time that the last heartbeat packets were broadcast
|
|
||||||
ArTime myLastHeartbeatTime;
|
|
||||||
|
|
||||||
/// Callback for getting the heartbeat interval
|
|
||||||
ArFunctor2C<ArServerHandlerCommMonitor,
|
|
||||||
ArServerClient *, ArNetPacket *> myGetHeartbeatIntervalCB;
|
|
||||||
/// Callback for replying to the ack request (UDP)
|
|
||||||
ArFunctor2C<ArServerHandlerCommMonitor,
|
|
||||||
ArServerClient *, ArNetPacket *> myAckCommUdpCB;
|
|
||||||
/// Callback for replying to the ack request (TCP)
|
|
||||||
ArFunctor2C<ArServerHandlerCommMonitor,
|
|
||||||
ArServerClient *, ArNetPacket *> myAckCommTcpCB;
|
|
||||||
/// Cycle callback executed to broadcast the heartbeat packets
|
|
||||||
ArFunctorC<ArServerHandlerCommMonitor> myCycleCB;
|
|
||||||
|
|
||||||
}; // end class ArServerHandlerCommMonitor
|
|
||||||
|
|
||||||
#endif // ARSERVERHANDLERCOMMMONITOR_H
|
|
@ -1,69 +0,0 @@
|
|||||||
#ifndef ARSERVERHANDLERCOMMANDS_H
|
|
||||||
#define ARSERVERHANDLERCOMMANDS_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
|
|
||||||
/// Class for having commands that can be called easily on the client
|
|
||||||
/**
|
|
||||||
You can add commands with addCommand and addStringCommand, you can
|
|
||||||
get the list of commands by requesting the data "listCommands" and
|
|
||||||
"listStringCommands".
|
|
||||||
**/
|
|
||||||
class ArServerHandlerCommands
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerHandlerCommands(ArServerBase *server);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerHandlerCommands();
|
|
||||||
/// Sets the text server
|
|
||||||
AREXPORT void setTextServer(ArNetServer *textServer)
|
|
||||||
{ myTextServer = textServer; }
|
|
||||||
/// Adds a command with no arguments
|
|
||||||
AREXPORT bool addCommand(const char *name, const char *description,
|
|
||||||
ArFunctor *functor,
|
|
||||||
const char *commandGroup = NULL);
|
|
||||||
/// Adds a command that takes a string argument
|
|
||||||
AREXPORT bool addStringCommand(const char *name, const char *description,
|
|
||||||
ArFunctor1<ArArgumentBuilder *> *functor,
|
|
||||||
const char *commandGroup = NULL);
|
|
||||||
/// Sets a prefix for commands
|
|
||||||
AREXPORT void setPrefix(const char *prefix);
|
|
||||||
/// Gets the prefix
|
|
||||||
AREXPORT const char *getPrefix(void);
|
|
||||||
/// The function that lists the commands
|
|
||||||
AREXPORT void netListCommands(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// The function that lists the string commands
|
|
||||||
AREXPORT void netListStringCommands(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArNetServer *myTextServer;
|
|
||||||
void netParseCommand(ArServerClient *client, ArNetPacket *packet,
|
|
||||||
ArFunctor *functor);
|
|
||||||
void netParseStringCommand(ArServerClient *client, ArNetPacket *packet,
|
|
||||||
ArFunctor1<ArArgumentBuilder *> *functor);
|
|
||||||
|
|
||||||
void textParseCommand(char **argv, int argc, ArSocket *socket, ArFunctor *functor);
|
|
||||||
void textParseStringCommand(char **argv, int argc, ArSocket *socket,
|
|
||||||
ArFunctor1<ArArgumentBuilder *> *functor);
|
|
||||||
|
|
||||||
std::list<std::string> myCommands;
|
|
||||||
std::list<std::string> myCommandDescriptions;
|
|
||||||
std::list<std::string> myStringCommands;
|
|
||||||
std::list<std::string> myStringCommandDescriptions;
|
|
||||||
std::list<ArFunctor3<ArServerClient *, ArNetPacket *,
|
|
||||||
ArFunctor *> *> myFunctors;
|
|
||||||
std::list<ArFunctor3<ArServerClient *, ArNetPacket *,
|
|
||||||
ArFunctor1<ArArgumentBuilder *> *> *> myStringFunctors;
|
|
||||||
std::string myPrefix;
|
|
||||||
ArFunctor2C<ArServerHandlerCommands,
|
|
||||||
ArServerClient *, ArNetPacket *> myNetListCommandsCB;
|
|
||||||
ArFunctor2C<ArServerHandlerCommands,
|
|
||||||
ArServerClient *, ArNetPacket *> myNetListStringCommandsCB;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,321 +0,0 @@
|
|||||||
#ifndef ARSERVERCONFIGHANDLER_H
|
|
||||||
#define ARSERVERCONFIGHANDLER_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
|
|
||||||
class ArServerClient;
|
|
||||||
|
|
||||||
/// Class for sending and receiving ArConfig data via ArNetworking.
|
|
||||||
/**
|
|
||||||
* ArServerHandlerConfig defines the network packet handlers used to transmit
|
|
||||||
* ArConfig objects to a client, and to modify them based on information
|
|
||||||
* received from the client. Since the packet structure for the ArConfig is
|
|
||||||
* rather complex, this class is best used in conjunction with the
|
|
||||||
* ArClientHandlerConfig.
|
|
||||||
*
|
|
||||||
* This class handles the following requests:
|
|
||||||
* <ul>
|
|
||||||
* <li>getConfigBySections/getConfigBySectionsV2: Replies with multiple
|
|
||||||
* packets, one for each ArConfig section plus an empty packet that
|
|
||||||
* terminates the reply. Each packet contains the following header
|
|
||||||
* information:
|
|
||||||
* <ol>
|
|
||||||
* <li>Section Indicator: Always set to 'S' (byte)</li>
|
|
||||||
* <li>Section Name: (string)</li>
|
|
||||||
* <li>Section Comment: (string) </li>
|
|
||||||
* <li>Section Category Name: (string) Only for getConfigBySectionsV2 </li>
|
|
||||||
* </ol>
|
|
||||||
* For each parameter in the section, the packet then contains a
|
|
||||||
* a Parameter Indicator (always set to 'P' (byte)) followed by a
|
|
||||||
* complete description of the parameter (display hints are included).
|
|
||||||
* See ArClientArgUtils for more information.
|
|
||||||
* </li>
|
|
||||||
* <li>getConfig: This request has been superceded by getConfigBySections. (It
|
|
||||||
* replies with a single packet containing all of the ArConfig
|
|
||||||
* sections as described above. If the ArConfig is large, then it
|
|
||||||
* may not be sent successfully. In addition, it contains no parameter
|
|
||||||
* display hints.)
|
|
||||||
* </li>
|
|
||||||
* <li>setConfig: Parses the received packet and updates the robot's
|
|
||||||
* ArConfig (and saves it to the file). For each modified section,
|
|
||||||
* the received packet is expected to contain:
|
|
||||||
* <ol>
|
|
||||||
* <li>Section Indicator: Always set to "Section" (string)</li>
|
|
||||||
* <li>Section Name: (string) </li>
|
|
||||||
* </ol>
|
|
||||||
* Followed by a brief "text" description of each modified parameter.
|
|
||||||
* This is the parameter name (string) followed by the parameter value
|
|
||||||
* formatted as text (string). See ArClientArgUtils for more information.
|
|
||||||
*
|
|
||||||
* A reply packet containing a string is sent to the client. If the
|
|
||||||
* string is empty, then the config was successfully updated. Otherwise,
|
|
||||||
* the string contains the name of the first parameter that caused an
|
|
||||||
* error during the update handling.
|
|
||||||
* </li>
|
|
||||||
* <li>reloadConfig: Reloads the ArConfig from the text file.
|
|
||||||
* </li>
|
|
||||||
* <li>configUpdated: An empty packet is broadcast to all interested clients
|
|
||||||
* after setConfig or reloadConfig has been completed. The clients may
|
|
||||||
* then request the modified ArConfig data with getConfigBySections
|
|
||||||
* (or getConfig).
|
|
||||||
* </li>
|
|
||||||
* <li>getConfigDefaults: If a "default" configuration file is available,
|
|
||||||
* then this command can be used to send the preferred default values
|
|
||||||
* to the client. The received packet should contain a single string,
|
|
||||||
* which is the name of the section to be retrieved, or an empty string
|
|
||||||
* to indicate all sections.
|
|
||||||
*
|
|
||||||
* For each requested section, the reply packet contains:
|
|
||||||
* <ol>
|
|
||||||
* <li>Section Indicator: Always set to "Section" (string)</li>
|
|
||||||
* <li>Section Name: (string) </li>
|
|
||||||
* </ol>
|
|
||||||
* Followed by a brief "text" description of each default parameter value.
|
|
||||||
* This is the parameter name (string) followed by the parameter value
|
|
||||||
* formatted as text (string). See ArClientArgUtils for more information.
|
|
||||||
* </li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* If you are using this class with the default file option you'll
|
|
||||||
* want to make it AFTER you're done adding things to the config, ie
|
|
||||||
* last, so that the default code can work correctly (it needs to know
|
|
||||||
* about all the info).
|
|
||||||
**/
|
|
||||||
class ArServerHandlerConfig
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Constructor
|
|
||||||
/**
|
|
||||||
* @param server the ArServerBase * used to send and receive network packets;
|
|
||||||
* must be non-NULL
|
|
||||||
* @param config the ArConfig * that is maintained by this server handler
|
|
||||||
* @param defaultFile the char * name of the file that contains the default
|
|
||||||
* values for the ArConfig; if NULL, then getConfigDefaults will not be
|
|
||||||
* supported
|
|
||||||
* @param defaultFileBaseDirectory the char * name of the directory that
|
|
||||||
* contains the default file
|
|
||||||
**/
|
|
||||||
AREXPORT ArServerHandlerConfig(ArServerBase *server,
|
|
||||||
ArConfig *config,
|
|
||||||
const char *defaultFile = NULL,
|
|
||||||
const char *defaultFileBaseDirectory = NULL,
|
|
||||||
bool allowFactory = true,
|
|
||||||
const char *robotName = NULL,
|
|
||||||
bool preventChanges = false,
|
|
||||||
const char *preventChangesString = NULL);
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerHandlerConfig();
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Network Packet Handlers
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Handles the "reloadConfig" request.
|
|
||||||
AREXPORT void reloadConfig(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the "getConfigBySections" request.
|
|
||||||
AREXPORT void getConfigBySections(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the "getConfigBySectionsV2" request.
|
|
||||||
AREXPORT void getConfigBySectionsV2(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the "getConfigBySectionsV3" request.
|
|
||||||
AREXPORT void getConfigBySectionsV3(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the (deprecated) "getConfig" request.
|
|
||||||
AREXPORT void getConfig(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the "setConfig" request.
|
|
||||||
AREXPORT void setConfig(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
AREXPORT void setConfigBySections(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
AREXPORT void setConfigBySectionsV2(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the "getConfigDefaults" request.
|
|
||||||
AREXPORT void getConfigDefaults(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the "getConfigSectionFlags" request.
|
|
||||||
AREXPORT void getConfigSectionFlags(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Handles the "getLastEditablePriority" request.
|
|
||||||
AREXPORT void getLastEditablePriority(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Callback Methods
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Adds a callback to be called before writing to disk
|
|
||||||
AREXPORT void addPreWriteCallback(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called before writing to disk
|
|
||||||
AREXPORT void remPreWriteCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Adds a callback to be called after writing to disk
|
|
||||||
AREXPORT void addPostWriteCallback(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called after writing to disk
|
|
||||||
AREXPORT void remPostWriteCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Adds a callback to be called when the config is updated
|
|
||||||
AREXPORT void addConfigUpdatedCallback(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called when the config is updated
|
|
||||||
AREXPORT void remConfigUpdatedCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Restarts the IO manually (mostly for because of a config change)
|
|
||||||
void restartIO(const char *reason);
|
|
||||||
/// Restarts the software manually (mostly for because of a config change)
|
|
||||||
void restartSoftware(const char *reason);
|
|
||||||
/// Restarts the hardware manually (mostly for because of a config change)
|
|
||||||
void restartHardware(const char *reason);
|
|
||||||
|
|
||||||
/// Adds a callback for when the IO is changed
|
|
||||||
void addRestartIOCB(ArFunctor *functor, int position = 50)
|
|
||||||
{ myRestartIOCBList.addCallback(functor, position); }
|
|
||||||
/// Adds a callback for when the IO is changed
|
|
||||||
void remRestartIOCB(ArFunctor *functor)
|
|
||||||
{ myRestartIOCBList.remCallback(functor); }
|
|
||||||
|
|
||||||
/// Sets a callback for when a RESTART_SERVER config param is changed
|
|
||||||
AREXPORT void setRestartSoftwareCB(ArFunctor *restartServerCB);
|
|
||||||
|
|
||||||
/// Gets the callback for when a RESTART_SERVER config param is changed
|
|
||||||
AREXPORT ArFunctor *getRestartSoftwareCB(void);
|
|
||||||
|
|
||||||
/// Sets a callback for when a RESTART_ROBOT config param is changed
|
|
||||||
AREXPORT void setRestartHardwareCB(ArFunctor *restartRobotCB);
|
|
||||||
|
|
||||||
/// Gets the callback for when a RESTART_ROBOT config param is changed
|
|
||||||
AREXPORT ArFunctor *getRestartHardwareCB(void);
|
|
||||||
|
|
||||||
/// Locks the config so we don't do anything with it
|
|
||||||
AREXPORT int lockConfig(void) { return myConfigMutex.lock(); }
|
|
||||||
/// Tries to lock the config so we don't do anything with it
|
|
||||||
AREXPORT int tryLockConfig(void) { return myConfigMutex.tryLock(); }
|
|
||||||
/// Unlocks the config so we can use it again
|
|
||||||
AREXPORT int unlockConfig(void) { return myConfigMutex.unlock(); }
|
|
||||||
|
|
||||||
/// Writes the config out
|
|
||||||
AREXPORT bool writeConfig(void);
|
|
||||||
/// Notifies the clients that the config was updated
|
|
||||||
AREXPORT bool configUpdated(ArServerClient *client = NULL);
|
|
||||||
|
|
||||||
/// Changes the variables that prevent changes
|
|
||||||
void setPreventChanges(bool preventChanges = false,
|
|
||||||
const char *preventChangesString = NULL);
|
|
||||||
|
|
||||||
/// loads the whole of a default file (for internal use)
|
|
||||||
AREXPORT bool loadDefaultsFromFile(void);
|
|
||||||
/// Parses a line of the default config (for internal use)
|
|
||||||
AREXPORT bool loadDefaultsFromPacket(ArNetPacket *packet);
|
|
||||||
/// Creates an empty default config...
|
|
||||||
AREXPORT void createEmptyConfigDefaults(void);
|
|
||||||
|
|
||||||
/// Changes if factory is allowed... this is internal, only for when
|
|
||||||
/// that decision is deferred
|
|
||||||
void setAllowFactory(bool allowFactory)
|
|
||||||
{ myPermissionAllowFactory = allowFactory; }
|
|
||||||
/// Changes if factory is allowed... this is internal, only for when
|
|
||||||
/// that decision is deferred
|
|
||||||
bool getAllowFactory(void)
|
|
||||||
{ return myPermissionAllowFactory; }
|
|
||||||
protected:
|
|
||||||
|
|
||||||
AREXPORT void doGetConfigBySections(ArServerClient *client,
|
|
||||||
ArNetPacket *packet,
|
|
||||||
int version);
|
|
||||||
|
|
||||||
/// Helper method for the get config callbacks (e.g. getConfigBySections, getConfig, ...).
|
|
||||||
AREXPORT void handleGetConfig(ArServerClient *client,
|
|
||||||
ArNetPacket *packet,
|
|
||||||
bool isMultiplePackets,
|
|
||||||
ArPriority::Priority lastPriority,
|
|
||||||
bool isSendIneditablePriorities,
|
|
||||||
int version);
|
|
||||||
|
|
||||||
/// Helper method for the get config callbacks (e.g. getConfigBySections, getConfig, ...).
|
|
||||||
AREXPORT bool handleGetConfigSection(ArNetPacket &sending,
|
|
||||||
ArServerClient *client,
|
|
||||||
ArNetPacket *packet,
|
|
||||||
bool isMultiplePackets,
|
|
||||||
ArPriority::Priority lastPriority,
|
|
||||||
bool isSendIneditablePriorities,
|
|
||||||
int version,
|
|
||||||
ArConfigSection *section,
|
|
||||||
int startIndex,
|
|
||||||
int paramCount,
|
|
||||||
int sectionIndex,
|
|
||||||
std::set<std::string> &sentParams);
|
|
||||||
|
|
||||||
|
|
||||||
/// Internal method that handles a setConfig packet for myConfig or
|
|
||||||
/// myDefaults
|
|
||||||
bool internalSetConfig(ArServerClient *client,
|
|
||||||
ArNetPacket *packet,
|
|
||||||
int version,
|
|
||||||
bool isMultiplePackets = false);
|
|
||||||
|
|
||||||
/// just creates the default config... (internal, don't use)
|
|
||||||
void createDefaultConfig(const char *defaultFileBaseDir);
|
|
||||||
/// Adds the default config callbacks;
|
|
||||||
void addDefaultServerCommands(void);
|
|
||||||
|
|
||||||
/// Determines the last editable priority based on the input flags
|
|
||||||
ArPriority::Priority findLastEditablePriority();
|
|
||||||
|
|
||||||
ArPriority::Priority convertToPriority(int priorityVal,
|
|
||||||
ArPriority::Priority defaultPriority);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
std::string myRobotName;
|
|
||||||
std::string myLogPrefix;
|
|
||||||
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArConfig *myConfig;
|
|
||||||
|
|
||||||
|
|
||||||
ArConfig *myDefault;
|
|
||||||
std::string myDefaultFile;
|
|
||||||
std::string myDefaultFileBaseDir;
|
|
||||||
ArMutex myDefaultConfigMutex;
|
|
||||||
bool myAddedDefaultServerCommands;
|
|
||||||
|
|
||||||
bool myPermissionAllowFactory;
|
|
||||||
bool myPreventChanges;
|
|
||||||
std::string myPreventChangesString;
|
|
||||||
|
|
||||||
ArMutex myConfigMutex;
|
|
||||||
|
|
||||||
std::list<ArFunctor *> myPreWriteCallbacks;
|
|
||||||
std::list<ArFunctor *> myPostWriteCallbacks;
|
|
||||||
std::list<ArFunctor *> myConfigUpdatedCallbacks;
|
|
||||||
|
|
||||||
ArCallbackList myRestartIOCBList;
|
|
||||||
ArFunctor *myRestartSoftwareCB;
|
|
||||||
bool myRestartSoftwareCBSet;
|
|
||||||
ArFunctor *myRestartHardwareCB;
|
|
||||||
bool myRestartHardwareCBSet;
|
|
||||||
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> myGetConfigBySectionsCB;
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> myGetConfigBySectionsV2CB;
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> myGetConfigBySectionsV3CB;
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> myGetConfigCB;
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> mySetConfigCB;
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> mySetConfigBySectionsCB;
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> mySetConfigBySectionsV2CB;
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> myReloadConfigCB;
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> myGetConfigDefaultsCB;
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> myGetConfigSectionFlagsCB;
|
|
||||||
ArFunctor2C<ArServerHandlerConfig, ArServerClient*, ArNetPacket *> myGetLastEditablePriorityCB;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,185 +0,0 @@
|
|||||||
#ifndef ARSERVERMAP_H
|
|
||||||
#define ARSERVERMAP_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
#include "ArConfig.h"
|
|
||||||
|
|
||||||
|
|
||||||
class ArServerClient;
|
|
||||||
|
|
||||||
class ArMapInterface;
|
|
||||||
|
|
||||||
/** @brief Service providing the contents of a map file to the client.
|
|
||||||
*
|
|
||||||
* A map can be provided from an ArMap object, or else the
|
|
||||||
* filename can be given in the global ArConfig object (see Aria::getConfig())
|
|
||||||
* as "Map" in the "Files" section. This handler can also be configured to
|
|
||||||
* only send "point" data, "line" data, or both kinds of data from the map.
|
|
||||||
*
|
|
||||||
* This service accepts the following data requests:
|
|
||||||
* <ul>
|
|
||||||
* <li><code>getMapId</code>
|
|
||||||
* <li><code>getMapName</code>
|
|
||||||
* <li><code>getMap</code>
|
|
||||||
* <li><code>getGoals</code>
|
|
||||||
* <li><code>getMapBinary</code>
|
|
||||||
* <li><code>getMapMultiScans</code>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* The following data types will also be broadcast to all clients to indicate
|
|
||||||
* certain events:
|
|
||||||
* <ul>
|
|
||||||
* <li><code>mapUpdated</code>
|
|
||||||
* <li><code>goalsUpdated</code>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* The <code>getMapId</code> request replies with: a map
|
|
||||||
* source identifier (NULL-terminated string); a filename for the map
|
|
||||||
* (NULL-terminated string); a checksum value preceded by a 4-byte unsigned
|
|
||||||
* integer providing the length (in bytes) of that checksum value; the total
|
|
||||||
* data size of the map contents (4-byte unsigned integer); and a timestamp
|
|
||||||
* for the map file (last modified, 4-byte signed integer, UNIX time).
|
|
||||||
*
|
|
||||||
* The <code>getMapName</code> request replies with a packet containing a
|
|
||||||
* NULL-terminated string containing the filename of the map, or an empty string
|
|
||||||
* ("") if there is no map.
|
|
||||||
*
|
|
||||||
* The <code>getMap</code> request replies with a series of packets each
|
|
||||||
* containing one line from the map file (as a null-terminated string),
|
|
||||||
* followed by an empty packet signifying
|
|
||||||
* the end of the packet.
|
|
||||||
* (see the documentation for ArMap for the map file
|
|
||||||
* format). This data may be written (with newlines added) to a map file,
|
|
||||||
* or may be parsed directly by an empty ArMap object using ArMap::parseLine()
|
|
||||||
* and ArMap::parsingComplete(). See tests/mapClient.cpp for an example of usage.
|
|
||||||
*
|
|
||||||
* The <code>getGoals</code> request replies with a packet containing a series of NULL-terminated
|
|
||||||
* strings containing the names of the Goal objects in the map.
|
|
||||||
*
|
|
||||||
* The <code>getMapBinary</code> request replies with the map headers and
|
|
||||||
* objects list (see ArMap for map file format) as text, but supplies point
|
|
||||||
* "DATA" and/or "LINES" as an undelimited sequence of 2-byte integers. (In
|
|
||||||
* the case of point data, each pair of integers is a point; for lines, each
|
|
||||||
* sequence of four integers defines a line). This binary representation of data
|
|
||||||
* is more compact than the ASCII text representation. This request results in a
|
|
||||||
* series of packets, with an empty packet signifying the end of the series.
|
|
||||||
*
|
|
||||||
* The <code>getMapMultiScans</code> request is similar to getMapBinary,
|
|
||||||
* but it includes a list of the scan sources, along with the point and lines
|
|
||||||
* for each scan source in binary format.
|
|
||||||
*
|
|
||||||
* The <code>mapUpdated</code> packet is sent to all connected clients whenever
|
|
||||||
* a new map is loaded or the map is changed. The packet contains no data; the
|
|
||||||
* new map can be downloaded using one of the above requests.
|
|
||||||
*
|
|
||||||
* The <code>goalsUpdated</code> packet is sent to all connected clients
|
|
||||||
* whenever the list of Goal objects changes in the map or a new map is loaded.
|
|
||||||
* The packet contains no data; the new list of goals can be downloaded using
|
|
||||||
* <code>getGoals</code>, or by downloading the entire map.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class ArServerHandlerMap
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum DataToSend { LINES = 1, POINTS = 2, BOTH = 3 };
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerHandlerMap(ArServerBase *server,
|
|
||||||
ArMapInterface *arMap = NULL,
|
|
||||||
DataToSend dataToSend = BOTH);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerHandlerMap();
|
|
||||||
/// Loads the map from a file
|
|
||||||
AREXPORT bool loadMap(const char *mapFile);
|
|
||||||
/// Uses a map already loaded
|
|
||||||
AREXPORT void useMap(ArMapInterface *mapObj,
|
|
||||||
bool takeOwnershipOfMap = false);
|
|
||||||
/// Gets the map object this is using
|
|
||||||
AREXPORT ArMapInterface *getMap(void);
|
|
||||||
|
|
||||||
/// Handles the request for the map ID.
|
|
||||||
AREXPORT void serverGetMapId(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// The command that gets the map name
|
|
||||||
AREXPORT void serverGetMapName(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// The command that'll get the map itself
|
|
||||||
AREXPORT void serverGetMap(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// The command that gets the map, with the data in binary format for improved performance
|
|
||||||
AREXPORT void serverGetMapBinary(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Requests that the server send the map, including scan data for multiple sources if available.
|
|
||||||
AREXPORT void serverGetMapMultiScans(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Requests that the server send the map with the specified maximum features.
|
|
||||||
AREXPORT void serverGetMapWithMaxCategory(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// The command that'll get the goals
|
|
||||||
AREXPORT void serverGetGoals(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Sets which kind of data we send
|
|
||||||
AREXPORT void setDataToSend(DataToSend dataToSend)
|
|
||||||
{ myDataToSend = dataToSend; }
|
|
||||||
/// Gets which kind of data we send
|
|
||||||
DataToSend getDataToSend(void) { return myDataToSend; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
AREXPORT void handleCheckMap(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
AREXPORT void sendMapWithMaxCategory(ArServerClient *client,
|
|
||||||
const char *maxCategory);
|
|
||||||
|
|
||||||
AREXPORT bool processFile(void);
|
|
||||||
AREXPORT void mapChanged(void);
|
|
||||||
// internal function that is used to toss the map to the client
|
|
||||||
AREXPORT void writeMapToClient(const char *line, ArServerClient *client);
|
|
||||||
|
|
||||||
|
|
||||||
AREXPORT void writePointsToClient(int pointCount,
|
|
||||||
std::vector<ArPose> *points,
|
|
||||||
ArServerClient *client);
|
|
||||||
|
|
||||||
AREXPORT void writeLinesToClient(int lineCount,
|
|
||||||
std::vector<ArLineSegment> *points,
|
|
||||||
ArServerClient *client);
|
|
||||||
|
|
||||||
ArServerBase *myServer;
|
|
||||||
bool myOwnMap;
|
|
||||||
DataToSend myDataToSend;
|
|
||||||
ArMapInterface *myMap;
|
|
||||||
std::string myMapName;
|
|
||||||
ArServerHandlerMap *myServerHandlerMap;
|
|
||||||
|
|
||||||
bool myAlreadyLoaded;
|
|
||||||
char myMapFileName[512];
|
|
||||||
char myLastMapFile[1024];
|
|
||||||
struct stat myLastMapFileStat;
|
|
||||||
|
|
||||||
ArFunctor2C<ArServerHandlerMap,
|
|
||||||
ArServerClient *, ArNetPacket *> myGetMapIdCB;
|
|
||||||
ArFunctor2C<ArServerHandlerMap,
|
|
||||||
ArServerClient *, ArNetPacket *> myGetMapNameCB;
|
|
||||||
ArFunctor2C<ArServerHandlerMap,
|
|
||||||
ArServerClient *, ArNetPacket *> myGetMapCB;
|
|
||||||
ArFunctor2C<ArServerHandlerMap,
|
|
||||||
ArServerClient *, ArNetPacket *> myGetMapBinaryCB;
|
|
||||||
ArFunctor2C<ArServerHandlerMap,
|
|
||||||
ArServerClient *, ArNetPacket *> myGetMapMultiScansCB;
|
|
||||||
ArFunctor2C<ArServerHandlerMap,
|
|
||||||
ArServerClient *, ArNetPacket *> myGetMapMaxCategoryCB;
|
|
||||||
ArFunctor2C<ArServerHandlerMap,
|
|
||||||
ArServerClient *, ArNetPacket *> myGetGoalsCB;
|
|
||||||
ArFunctor2C<ArServerHandlerMap,
|
|
||||||
ArServerClient *, ArNetPacket *> myCheckMapCB;
|
|
||||||
ArRetFunctorC<bool, ArServerHandlerMap> myProcessFileCB;
|
|
||||||
ArFunctorC<ArServerHandlerMap> myMapChangedCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,193 +0,0 @@
|
|||||||
#ifndef ARSERVERHANDLERMAPPING_H
|
|
||||||
#define ARSERVERHANDLERMAPPING_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
#include "ArServerHandlerCommands.h"
|
|
||||||
#include "ArTempDirectoryHelper.h"
|
|
||||||
|
|
||||||
/// Class that handles the starting, stopping, and status of mapping
|
|
||||||
class ArServerHandlerMapping
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerHandlerMapping(ArServerBase *server, ArRobot *robot,
|
|
||||||
ArLaser *laser,
|
|
||||||
const char *baseDirectory = "",
|
|
||||||
const char *tempDirectory = "",
|
|
||||||
bool useReflectorValues = false,
|
|
||||||
ArLaser *laser2 = NULL,
|
|
||||||
const char *sickSuffix = NULL,
|
|
||||||
const char *sick2Suffix = NULL,
|
|
||||||
std::list<ArLaser *> *extraLasers = NULL);
|
|
||||||
/// Deconstructor
|
|
||||||
AREXPORT virtual ~ArServerHandlerMapping();
|
|
||||||
/// Starts a new map unless ones already made
|
|
||||||
AREXPORT void serverMappingStart(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Ends a map
|
|
||||||
AREXPORT void serverMappingEnd(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Gets the mapping status
|
|
||||||
AREXPORT void serverMappingStatus(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Returns if we're mapping or not
|
|
||||||
AREXPORT bool isMapping(void);
|
|
||||||
|
|
||||||
/// Forces a reading to be taken
|
|
||||||
AREXPORT void forceReading(void);
|
|
||||||
|
|
||||||
/// Gets the filename we're using (make sure the robot's locked)
|
|
||||||
AREXPORT const char *getFileName(void);
|
|
||||||
/// Gets the mapname we're using (make sure the robot's locked)
|
|
||||||
AREXPORT const char *getMapName(void);
|
|
||||||
/// Adds the simple commands to the simple command handler passed in
|
|
||||||
AREXPORT void addSimpleCommands(ArServerHandlerCommands *handlerCommands);
|
|
||||||
/// Adds a loop start to the log
|
|
||||||
AREXPORT void simpleLoopStart(ArArgumentBuilder *arg);
|
|
||||||
/// Adds a loop end to the log
|
|
||||||
AREXPORT void simpleLoopEnd(ArArgumentBuilder *arg);
|
|
||||||
/// Adds a string for adding to the log when we start
|
|
||||||
AREXPORT void addStringForStartOfLogs(
|
|
||||||
const char *str, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a string for adding to the log when we start
|
|
||||||
AREXPORT void remStringForStartOfLogs(const char *str);
|
|
||||||
/// Adds a tag to the logg (has robot pose and stuff) (make sure the
|
|
||||||
/// robot's locked)
|
|
||||||
AREXPORT void addTagToLog(const char *str);
|
|
||||||
/// Adds an info to the log (has no robot pose) (make sure the
|
|
||||||
/// robot's locked)
|
|
||||||
AREXPORT void addInfoToLog(const char *str);
|
|
||||||
/// Adds a new type of location data to the logger
|
|
||||||
AREXPORT bool addLocationData(
|
|
||||||
const char *name,
|
|
||||||
ArRetFunctor3<int, ArTime, ArPose *, ArPoseWithTime *> *functor);
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
// Callback Methods
|
|
||||||
//
|
|
||||||
// The mapping callbacks are invoked in the order in which they appear
|
|
||||||
// in this header file. Namely:
|
|
||||||
// 1. MappingStart
|
|
||||||
// 2. MappingBegun (this is logically "mapping started")
|
|
||||||
// 3. MappingEnd
|
|
||||||
// 4. MappingEnded
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/// Adds a callback for the start of mapping
|
|
||||||
AREXPORT void addMappingStartCallback(
|
|
||||||
ArFunctor *functor, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback for the start of mapping
|
|
||||||
AREXPORT void remMappingStartCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Adds a callback for just after mapping has started
|
|
||||||
AREXPORT void addMappingBegunCallback(
|
|
||||||
ArFunctor *functor, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback for just after mapping has started
|
|
||||||
AREXPORT void remMappingBegunCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Adds a callback for the end of mapping
|
|
||||||
AREXPORT void addMappingEndCallback(
|
|
||||||
ArFunctor *functor, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback for the end of mapping
|
|
||||||
AREXPORT void remMappingEndCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Adds a callback that is invoked after mapping has been ended.
|
|
||||||
AREXPORT void addMappingEndedCallback(
|
|
||||||
ArFunctor *functor, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback from the list invoked after mapping has been ended.
|
|
||||||
AREXPORT void remMappingEndedCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
|
|
||||||
/// Adds a callback to be called before moving from temp dir to base dir
|
|
||||||
AREXPORT void addPreMoveCallback(
|
|
||||||
ArFunctor *functor, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called before moving from temp dir to base dir
|
|
||||||
AREXPORT void remPreMoveCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
/// Adds a callback to be called after moving from temp dir to base dir
|
|
||||||
AREXPORT void addPostMoveCallback(
|
|
||||||
ArFunctor *functor, ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called after moving from temp dir to base dir
|
|
||||||
AREXPORT void remPostMoveCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
// Misc Methods
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
/// The packet handler for starting/stopping scans from the lcd
|
|
||||||
AREXPORT bool packetHandler(ArRobotPacket *packet);
|
|
||||||
/// Get location data map (mostly for internal things)
|
|
||||||
AREXPORT const std::map<std::string, ArRetFunctor3<int, ArTime, ArPose *, ArPoseWithTime *> *,
|
|
||||||
ArStrCaseCmpOp> *getLocationDataMap(void);
|
|
||||||
/// A method to add the strings for the start of a log just straight to an ArMap
|
|
||||||
AREXPORT void addStringsForStartOfLogToMap(ArMap *arMap);
|
|
||||||
|
|
||||||
|
|
||||||
/// Returns a pointer to the optional zip file installed on this handler.
|
|
||||||
AREXPORT ArZippable *getZipFile();
|
|
||||||
|
|
||||||
/// Returns a pointer to a second optional zip file used to contain snapshot images.
|
|
||||||
AREXPORT ArZippable *getSnapshotZipFile();
|
|
||||||
|
|
||||||
/// Sets the optional zip file installed on this handler.
|
|
||||||
AREXPORT void setZipFile(ArZippable *zipFile);
|
|
||||||
|
|
||||||
/// Sets the optional zip file installed on this handler.
|
|
||||||
AREXPORT void setSnapshotZipFile(ArZippable *zipFile);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
|
||||||
AREXPORT std::string makeFilePathName(const char *fileName);
|
|
||||||
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArRobot *myRobot;
|
|
||||||
ArLaser *myLaser;
|
|
||||||
ArLaser *myLaser2;
|
|
||||||
bool myUseReflectorValues;
|
|
||||||
|
|
||||||
std::list<ArFunctor *> myMappingStartCallbacks;
|
|
||||||
std::list<ArFunctor *> myMappingBegunCallbacks;
|
|
||||||
std::list<ArFunctor *> myMappingEndCallbacks;
|
|
||||||
std::list<ArFunctor *> myMappingEndedCallbacks;
|
|
||||||
|
|
||||||
std::list<ArFunctor *> myPreMoveCallbacks;
|
|
||||||
std::list<ArFunctor *> myPostMoveCallbacks;
|
|
||||||
|
|
||||||
std::list<std::string> myStringsForStartOfLog;
|
|
||||||
ArLaserLogger *myLaserLogger;
|
|
||||||
ArLaserLogger *myLaserLogger2;
|
|
||||||
std::string myMapName;
|
|
||||||
std::string myFileName;
|
|
||||||
std::string myFileName2;
|
|
||||||
|
|
||||||
std::string mySuffix;
|
|
||||||
std::string mySuffix2;
|
|
||||||
|
|
||||||
std::list<ArLaser *> *myExtraLasers;
|
|
||||||
|
|
||||||
ArTempDirectoryHelper myTempDirectoryHelper;
|
|
||||||
|
|
||||||
/// Optional zip file in which mapping results may be saved
|
|
||||||
ArZippable *myZipFile;
|
|
||||||
/// Second optional zip file in which snaphots may be saved
|
|
||||||
ArZippable *mySnapshotZipFile;
|
|
||||||
|
|
||||||
std::map<std::string, ArRetFunctor3<int, ArTime, ArPose *,
|
|
||||||
ArPoseWithTime *> *,
|
|
||||||
ArStrCaseCmpOp> myLocationDataMap;
|
|
||||||
|
|
||||||
ArFunctor2C<ArServerHandlerMapping, ArServerClient *, ArNetPacket *> myMappingStartCB;
|
|
||||||
ArFunctor2C<ArServerHandlerMapping, ArServerClient *, ArNetPacket *> myMappingEndCB;
|
|
||||||
ArFunctor2C<ArServerHandlerMapping, ArServerClient *, ArNetPacket *> myMappingStatusCB;
|
|
||||||
ArServerHandlerCommands *myHandlerCommands;
|
|
||||||
ArRetFunctor1C<bool, ArServerHandlerMapping, ArRobotPacket *> myPacketHandlerCB;
|
|
||||||
ArFunctor1C<ArServerHandlerMapping, ArArgumentBuilder *> myLoopStartCB;
|
|
||||||
ArFunctor1C<ArServerHandlerMapping, ArArgumentBuilder *> myLoopEndCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ARSERVERHANDLERMAPPING_H
|
|
@ -1,256 +0,0 @@
|
|||||||
#ifndef ARSERVERHANDLERPOPUP_H
|
|
||||||
#define ARSERVERHANDLERPOPUP_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
|
|
||||||
|
|
||||||
class ArServerClient;
|
|
||||||
|
|
||||||
class ArServerHandlerPopupInfo;
|
|
||||||
|
|
||||||
/// Class for having generic popups appear in MobileEyes (created on the server)
|
|
||||||
/**
|
|
||||||
TODO make the callbacks actually happen
|
|
||||||
**/
|
|
||||||
|
|
||||||
class ArServerHandlerPopup
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerHandlerPopup(ArServerBase *server);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerHandlerPopup();
|
|
||||||
/// Creates a new popup
|
|
||||||
AREXPORT ArTypes::Byte4 createPopup(
|
|
||||||
ArServerHandlerPopupInfo *popupInfo,
|
|
||||||
ArFunctor2<ArTypes::Byte4, int> *callback = NULL);
|
|
||||||
/// Cancels a popup with the ID
|
|
||||||
AREXPORT void closePopup(ArTypes::Byte4 id,
|
|
||||||
const char *closeMessage);
|
|
||||||
/// The call from the network that the popup was clicked
|
|
||||||
/// @internal
|
|
||||||
AREXPORT void netPopupClicked(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// The call from the network for getting the popup list
|
|
||||||
/// @internal
|
|
||||||
AREXPORT void netPopupList(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Our cycle callback
|
|
||||||
/// @internal
|
|
||||||
AREXPORT void serverCycleCallback(void);
|
|
||||||
enum PopupType {
|
|
||||||
NOICON = 0, ///< No icon at all
|
|
||||||
INFORMATION = 1, ///< Just an informational message
|
|
||||||
WARNING = 2, ///< A warning
|
|
||||||
CRITICAL = 3, ///< A critical problem (program failure likely)
|
|
||||||
QUESTION = 4 ///< A question
|
|
||||||
};
|
|
||||||
protected:
|
|
||||||
ArServerBase *myServer;
|
|
||||||
|
|
||||||
class PopupData {
|
|
||||||
public:
|
|
||||||
/// Constructor (copies and owns popupInfo, leaves callback)
|
|
||||||
PopupData(ArServerHandlerPopupInfo *popupInfo,
|
|
||||||
ArTypes::Byte4 id,
|
|
||||||
ArFunctor2<ArTypes::Byte4, int> *callback);
|
|
||||||
/// Destructor, deleted the popup info
|
|
||||||
virtual ~PopupData();
|
|
||||||
/// The popup info
|
|
||||||
ArServerHandlerPopupInfo *myPopupInfo;
|
|
||||||
/// The functor to call when its done
|
|
||||||
ArFunctor2<ArTypes::Byte4, int> *myCallback;
|
|
||||||
/// When we started this popup
|
|
||||||
ArTime myStarted;
|
|
||||||
/// The popup this was serving
|
|
||||||
ArTypes::Byte4 myID;
|
|
||||||
|
|
||||||
};
|
|
||||||
void buildPacket(ArNetPacket *sendingPacket, PopupData *popupData);
|
|
||||||
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
std::map<ArTypes::Byte4, PopupData *> myMap;
|
|
||||||
ArTypes::Byte4 myLastID;
|
|
||||||
ArTime myLastTimeCheck;
|
|
||||||
ArFunctor2C<ArServerHandlerPopup, ArServerClient*,
|
|
||||||
ArNetPacket *> myNetPopupClickedCB;
|
|
||||||
ArFunctor2C<ArServerHandlerPopup, ArServerClient*,
|
|
||||||
ArNetPacket *> myNetPopupListCB;
|
|
||||||
ArFunctorC<ArServerHandlerPopup> myServerCycleCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Holds the information for a popup
|
|
||||||
/**
|
|
||||||
This holds the information for the popup.... So there's a message
|
|
||||||
box with the title which has in it the message, and has between 1
|
|
||||||
and 3 buttons (button0, button1, and button2) with labels of
|
|
||||||
button0Label, button1Label, and button2Label (if the label is empty
|
|
||||||
or NULL then there'll be no button), the default button of
|
|
||||||
defaultButtonNumber (0 - 2) and the escape button number of
|
|
||||||
escapeButtonNumber (0 - 2)... when a button is pushed the
|
|
||||||
|
|
||||||
@param ignoreIdentifier The identifier to use for ignoring these
|
|
||||||
boxes, this should be NULL or empty if you don't want this
|
|
||||||
particular box to be able to be ignored (if any popup with this
|
|
||||||
identifier is already being ignored this one will be too)
|
|
||||||
|
|
||||||
@param title The title of the box (displayed in the titlebar)
|
|
||||||
|
|
||||||
@param message The string that will be displayed in the message box
|
|
||||||
(the point of the whole thing)
|
|
||||||
|
|
||||||
@param popupType The type of popup this is, which controls the icon
|
|
||||||
displayed, may someday affect behavior
|
|
||||||
|
|
||||||
@param defaultButtonPressed The button that enter defaults to (This
|
|
||||||
should be whatever is most likely)
|
|
||||||
|
|
||||||
@param escapeButtonPressed The button that escape defaults to (this
|
|
||||||
should be doesn't change the state, ie like cancel), this also
|
|
||||||
should be whats returned if the X is hit.
|
|
||||||
|
|
||||||
@param button0Label The label that is displayed on button 0, the
|
|
||||||
leftmost button
|
|
||||||
|
|
||||||
@param timeoutInSeconds the number of seconds we should give people
|
|
||||||
to respond to the popup before timing it out, 0 means leave it up
|
|
||||||
forever (note that no clients may be watching this or no one may be
|
|
||||||
at the console and use this option wisely (way too many untimed out
|
|
||||||
popups could bog down the server))
|
|
||||||
|
|
||||||
@param timeoutString The string that will be displayed if a timeout
|
|
||||||
happens
|
|
||||||
|
|
||||||
@param button0Pressed The string that will be put into the box if
|
|
||||||
button0 is pressed (this is mainly so that with multiple clients
|
|
||||||
connected the other clients will get feedback)
|
|
||||||
|
|
||||||
@param button1Label The label that is displayed on button 1 (the
|
|
||||||
middle button if there are 3, right button if there are two)
|
|
||||||
|
|
||||||
@param button1Pressed The string that will be put into the box if
|
|
||||||
button1 is pressed (this is mainly so that with multiple clients
|
|
||||||
connected the other clients will get feedback)
|
|
||||||
|
|
||||||
@param button2Label The label that is displayed on button 2 (the
|
|
||||||
right button)
|
|
||||||
|
|
||||||
@param button2Pressed The string that will be put into the box if
|
|
||||||
button2 is pressed (this is mainly so that with multiple clients
|
|
||||||
connected the other clients will get feedback)
|
|
||||||
**/
|
|
||||||
class ArServerHandlerPopupInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerHandlerPopupInfo(
|
|
||||||
const char *ignoreIdentifier, const char *title,
|
|
||||||
const char *message, ArServerHandlerPopup::PopupType popupType,
|
|
||||||
ArTypes::Byte defaultButtonNumber,
|
|
||||||
ArTypes::Byte escapeButtonNumber,
|
|
||||||
int timeoutInSeconds, const char *timeoutString,
|
|
||||||
const char *button0Label, const char *button0Pressed,
|
|
||||||
const char *button1Label = "", const char *button1Pressed = "",
|
|
||||||
const char *button2Label = "", const char *button2Pressed = "");
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerHandlerPopupInfo();
|
|
||||||
/// Copy constructor
|
|
||||||
AREXPORT ArServerHandlerPopupInfo(const ArServerHandlerPopupInfo &popupInfo);
|
|
||||||
/// Assignment operator
|
|
||||||
AREXPORT ArServerHandlerPopupInfo &operator=(
|
|
||||||
const ArServerHandlerPopupInfo &popupInfo);
|
|
||||||
|
|
||||||
/// Gets the popup identifer (this is used only for ignoring popups, if empty or NULL then it can't be ignored)
|
|
||||||
const char *getIgnoreIdentifier(void) { return myIgnoreIdentifier.c_str(); }
|
|
||||||
/// Gets the title (the title of the popup box)
|
|
||||||
const char *getTitle(void) { return myTitle.c_str(); }
|
|
||||||
/// Gets the message (the long string that is displayed that explains things)
|
|
||||||
const char *getMessage(void) { return myMessage.c_str(); }
|
|
||||||
/// Gets the type (the icon thats displayed and what type of popup it is)
|
|
||||||
ArServerHandlerPopup::PopupType getPopupType(void) { return myPopupType; }
|
|
||||||
/// Gets the default button number (whats pressed when enter is hit)
|
|
||||||
ArTypes::Byte getDefaultButtonNumber(void) { return myDefaultButtonNumber; }
|
|
||||||
/// Gets the escape button number (whats pressed when escape is hit)
|
|
||||||
ArTypes::Byte getEscapeButtonNumber(void) { return myEscapeButtonNumber; }
|
|
||||||
/// Gets the timeout in seconds (0 is never)
|
|
||||||
int getTimeout(void) { return myTimeout; }
|
|
||||||
/// Gets the timeout string (the string that is displayed on the popup if timeout occurs)
|
|
||||||
const char * getTimeoutString(void)
|
|
||||||
{ return myTimeoutString.c_str(); }
|
|
||||||
/// Gets the button0Label (the label on the leftmost button, must have a label)
|
|
||||||
const char *getButton0Label(void) { return myButton0Label.c_str(); }
|
|
||||||
/// Gets the button0Pressed (string sent as box disppears if this button is pressed)
|
|
||||||
const char *getButton0Pressed(void) { return myButton0Pressed.c_str(); }
|
|
||||||
|
|
||||||
/// Gets the button1Label (the label on the middle button, empty string or NULL for no button)
|
|
||||||
const char *getButton1Label(void) { return myButton1Label.c_str(); }
|
|
||||||
/// Gets the button1Pressed (string sent as box disppears if this button is pressed)
|
|
||||||
const char *getButton1Pressed(void) { return myButton1Pressed.c_str(); }
|
|
||||||
/// Gets the button2Label (the label on the right button, empty string or NULL for no button)
|
|
||||||
const char *getButton2Label(void) { return myButton2Label.c_str(); }
|
|
||||||
/// Gets the button2Pressed (string sent as box disppears if this button is pressed)
|
|
||||||
const char *getButton2Pressed(void) { return myButton2Pressed.c_str(); }
|
|
||||||
|
|
||||||
/// Gets the popup identifer (this is used only for ignoring popups, if empty or NULL then it can't be ignored)
|
|
||||||
void setIgnoreIdentifier(const char *identifier)
|
|
||||||
{ if (identifier != NULL) myIgnoreIdentifier = identifier; else myIgnoreIdentifier = ""; }
|
|
||||||
/// Sets the title (the title of the popup box)
|
|
||||||
void setTitle(const char *title)
|
|
||||||
{ if (title != NULL) myTitle = title; else myTitle = ""; }
|
|
||||||
/// Sets the message (the long string that is displayed that explains things)
|
|
||||||
void setMessage(const char *message)
|
|
||||||
{ if (message != NULL) myMessage = message; else myMessage = ""; }
|
|
||||||
/// Sets the type (the icon thats displayed and what type of popup it is)
|
|
||||||
void setPopupType(ArServerHandlerPopup::PopupType popupType)
|
|
||||||
{ myPopupType = popupType; }
|
|
||||||
/// Sets the default button number (whats pressed when enter is hit)
|
|
||||||
void setDefaultButtonNumber(ArTypes::Byte defaultButtonNumber)
|
|
||||||
{ myDefaultButtonNumber = defaultButtonNumber; }
|
|
||||||
/// Sets the escape button number (whats pressed when escape is hit)
|
|
||||||
void setEscapeButtonNumber(ArTypes::Byte escapeButtonNumber)
|
|
||||||
{ myEscapeButtonNumber = escapeButtonNumber; }
|
|
||||||
/// Sets the timeout in seconds (0 is never)
|
|
||||||
void setTimeout(int timeoutInSeconds)
|
|
||||||
{ myTimeout = timeoutInSeconds; }
|
|
||||||
/// Sets the timeout string (the string that is displayed on the popup if timeout occurs)
|
|
||||||
void setTimeoutString(const char *timeoutString)
|
|
||||||
{ if (timeoutString != NULL) myTimeoutString = timeoutString; else myTimeoutString = ""; }
|
|
||||||
/// Sets the button0Label (the label on the leftmost button, must have a label)
|
|
||||||
void setButton0Label(const char *label)
|
|
||||||
{ if (label != NULL) myButton0Label = label; else myButton0Label = ""; }
|
|
||||||
/// Sets the button0Pressed (string sent as box disppears if this button is pressed)
|
|
||||||
void setButton0Pressed(const char *pressed)
|
|
||||||
{ if (pressed != NULL) myButton0Pressed = pressed; else myButton0Pressed = ""; }
|
|
||||||
/// Sets the button1Label (the label on the middle button, empty string or NULL for no button)
|
|
||||||
void setButton1Label(const char *label)
|
|
||||||
{ if (label != NULL) myButton1Label = label; else myButton1Label = ""; }
|
|
||||||
/// Sets the button1Pressed (string sent as box disppears if this button is pressed)
|
|
||||||
void setButton1Pressed(const char *pressed)
|
|
||||||
{ if (pressed != NULL) myButton1Pressed = pressed; else myButton1Pressed = ""; }
|
|
||||||
/// Sets the button2Label (the label on the right button, empty string or NULL for no button)
|
|
||||||
void setButton2Label(const char *label)
|
|
||||||
{ if (label != NULL) myButton2Label = label; else myButton2Label = ""; }
|
|
||||||
/// Sets the button2Pressed (string sent as box disppears if this button is pressed)
|
|
||||||
void setButton2Pressed(const char *pressed)
|
|
||||||
{ if (pressed != NULL) myButton2Pressed = pressed; else myButton2Pressed = ""; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::string myIgnoreIdentifier;
|
|
||||||
std::string myTitle;
|
|
||||||
std::string myMessage;
|
|
||||||
ArServerHandlerPopup::PopupType myPopupType;
|
|
||||||
ArTypes::Byte myDefaultButtonNumber;
|
|
||||||
ArTypes::Byte myEscapeButtonNumber;
|
|
||||||
int myTimeout;
|
|
||||||
std::string myTimeoutString;
|
|
||||||
std::string myButton0Label;
|
|
||||||
std::string myButton0Pressed;
|
|
||||||
std::string myButton1Label;
|
|
||||||
std::string myButton1Pressed;
|
|
||||||
std::string myButton2Label;
|
|
||||||
std::string myButton2Pressed;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARSERVERHANDLERPOPUP_H
|
|
@ -1,88 +0,0 @@
|
|||||||
#ifndef ARSERVERINFODRAWINGS_H
|
|
||||||
#define ARSERVERINFODRAWINGS_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
|
|
||||||
class ArServerClient;
|
|
||||||
|
|
||||||
/** Service to provide clients with information about graphical figures to be
|
|
||||||
displayed with the map.
|
|
||||||
|
|
||||||
Use addDrawing() to add a figure, or use addRangeDevice() or
|
|
||||||
addRobotsRangeDevice() to automatically create standard drawings for
|
|
||||||
range devices.
|
|
||||||
|
|
||||||
Clients may use the <code>listDrawings</code> data
|
|
||||||
request to receive a list of figures and metadata about those figures.
|
|
||||||
The reply packet to the <code>listDrawings</code> request is as follows:
|
|
||||||
<ol>
|
|
||||||
<li>Number of figures (4-byte integer)Then, for each figure, the following values are given
|
|
||||||
<li>For each figure:
|
|
||||||
<ol>
|
|
||||||
<li>Figure name (null-terminated string)</li>
|
|
||||||
<li>Shape ID (null-terminated string)</li>
|
|
||||||
<li>Primary color: <ol>
|
|
||||||
<li>Unused (byte)</li>
|
|
||||||
<li>Red (byte)</li>
|
|
||||||
<li>Green (byte)</li>
|
|
||||||
<li>Blue (byte)</li>
|
|
||||||
</ol></li>
|
|
||||||
<li>Shape size (4-byte integer)</li>
|
|
||||||
<li>Layer number (4-byte integer)</li>
|
|
||||||
<li>Suggested refresh time (4-byte integer)</li>
|
|
||||||
<li>Secordary color: <ol>
|
|
||||||
<li>Unused (byte)</li>
|
|
||||||
<li>Red (byte)</li>
|
|
||||||
<li>Green (byte)</li>
|
|
||||||
<li>Blue (byte)</li>
|
|
||||||
</ol></li>
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
This command is in the <code>SensorInfo</code> permission group for users.
|
|
||||||
*/
|
|
||||||
class ArServerInfoDrawings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerInfoDrawings(ArServerBase *server);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerInfoDrawings();
|
|
||||||
/// Adds a shape to the set of figures
|
|
||||||
AREXPORT bool addDrawing(ArDrawingData *drawingData, const char *name,
|
|
||||||
ArFunctor2<ArServerClient *, ArNetPacket *> *functor);
|
|
||||||
/// Adds a specific range device to be drawn (using its default shape)
|
|
||||||
AREXPORT bool addRangeDevice(ArRangeDevice *rangeDevice);
|
|
||||||
/// Adds all of the robot's range devices (using their default shape)
|
|
||||||
AREXPORT bool addRobotsRangeDevices(ArRobot *robot);
|
|
||||||
/// Client callback: Puts the list of shapes that can be drawn and their metadata into a reply packet (internal use mostly)
|
|
||||||
AREXPORT void netListDrawings(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
AREXPORT void netGetDrawingList(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Client callback utility: Puts the current data for the given range device into a reply packet (internal use mostly)
|
|
||||||
AREXPORT void netRangeDeviceCurrent(ArServerClient *client,
|
|
||||||
ArNetPacket *packet,
|
|
||||||
ArRangeDevice *device);
|
|
||||||
/// Client callback utilit: Puts the cumulative buffer of the given range device into a reply packet (internal use mostly)
|
|
||||||
AREXPORT void netRangeDeviceCumulative(ArServerClient *client,
|
|
||||||
ArNetPacket *packet,
|
|
||||||
ArRangeDevice *device);
|
|
||||||
/// internal function that gets the drawing data for a drawing
|
|
||||||
/// @internal
|
|
||||||
AREXPORT ArDrawingData *internalGetDrawingData(const char *name);
|
|
||||||
/// internal function that gets the functor for a drawing
|
|
||||||
/// @internal
|
|
||||||
AREXPORT ArFunctor2<ArServerClient *, ArNetPacket *> *internalGetDrawingCallback(const char *name);
|
|
||||||
protected:
|
|
||||||
ArServerBase *myServer;
|
|
||||||
std::map<std::string, ArDrawingData *, ArStrCaseCmpOp> myDrawingDatas;
|
|
||||||
std::map<std::string, ArFunctor2<ArServerClient *, ArNetPacket *> *, ArStrCaseCmpOp> myDrawingCallbacks;
|
|
||||||
ArFunctor2C<ArServerInfoDrawings, ArServerClient *, ArNetPacket *> myNetListDrawingsCB;
|
|
||||||
ArFunctor2C<ArServerInfoDrawings, ArServerClient *, ArNetPacket *> myNetGetDrawingListCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,123 +0,0 @@
|
|||||||
#ifndef ARSERVERROBOTINFO_H
|
|
||||||
#define ARSERVERROBOTINFO_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
|
|
||||||
class ArServerClient;
|
|
||||||
|
|
||||||
/** Server component providing basic robot status information to clients.
|
|
||||||
* This service accepts the following data requests:
|
|
||||||
* <ul>
|
|
||||||
* <li><code>update</code></li>
|
|
||||||
* <li><code>physicalInfo</code></li>
|
|
||||||
* <li><code>batteryInfo</code></li>
|
|
||||||
* <li><code>activityTimeInfo</code></li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* For bandwidth savings you should use <code>updateNumbers</code>
|
|
||||||
* and <code>updateStrings</code> instead of <code>update</code>.
|
|
||||||
*
|
|
||||||
* The <code>update</code> request returns data regarding the current
|
|
||||||
* state of the robot.
|
|
||||||
* It replies with the following data packet:
|
|
||||||
* <ol>
|
|
||||||
* <li>Status (Null-terminated string)</li>
|
|
||||||
* <li>Mode (Null-terminated string)</li>
|
|
||||||
* <li>Battery voltage (times 10) (2 Byte integer)</li>
|
|
||||||
* <li>X position (4 byte floating point number)</li>
|
|
||||||
* <li>Y position (4 byte floating point number)</li>
|
|
||||||
* <li>Theta (2-byte floating point number)</li>
|
|
||||||
* <li>Forward velocity (2-byte integer)</li>
|
|
||||||
* <li>Rotation velocity (2-byte integer)</li>
|
|
||||||
* </ol>
|
|
||||||
*
|
|
||||||
* The <code>updateNumbers</code> request returns data regarding the current
|
|
||||||
* state of the robot.
|
|
||||||
* It replies with the following data packet:
|
|
||||||
* <ol>
|
|
||||||
* <li>Battery voltage (times 10) (2 Byte integer)</li>
|
|
||||||
* <li>X position (4 byte floating point number)</li>
|
|
||||||
* <li>Y position (4 byte floating point number)</li>
|
|
||||||
* <li>Theta (2-byte floating point number)</li>
|
|
||||||
* <li>Forward velocity (2-byte integer)</li>
|
|
||||||
* <li>Rotation velocity (2-byte integer)</li>
|
|
||||||
* </ol>
|
|
||||||
*
|
|
||||||
* The <code>updateStrings</code> request broadcasts data regarding
|
|
||||||
* the current state of the robot. Request this at -1 to get the
|
|
||||||
* broadcasts and an initial packet with the inital data.
|
|
||||||
* It replies with the following data packet:
|
|
||||||
* <ol>
|
|
||||||
* <li>Status (Null-terminated string)</li>
|
|
||||||
* <li>Mode (Null-terminated string)</li>
|
|
||||||
*</ol>
|
|
||||||
*
|
|
||||||
* The <code>physicalInfo</code> request returns data regarding the physical characteristics of
|
|
||||||
* the robot. This information does not change during the robot execution. It replies with the
|
|
||||||
* following data packet:
|
|
||||||
* <ol>
|
|
||||||
* <li>Robot type (Null-terminated string)</li>
|
|
||||||
* <li>Robot sub-type (Null-terminated string)</li>
|
|
||||||
* <li>Robot width in mm (2 byte integer)</li>
|
|
||||||
* <li>Robot front length - mm from center of rotation to front of robot (2 byte integer)</li>
|
|
||||||
* <li>Robot rear length - mm from center of rotation to back of robot (2 byte integer)</li>
|
|
||||||
* </ol>
|
|
||||||
*
|
|
||||||
* The <code>batteryInfo</code> request replies with the following data packet:
|
|
||||||
* <ol>
|
|
||||||
* <li>Warning voltage (double)</li>
|
|
||||||
* <li>Shutdown voltage (double)</li>
|
|
||||||
* </ol>
|
|
||||||
*
|
|
||||||
* The <code>activityTimeInfo</code> request replies with the following data packet:
|
|
||||||
* <ol>
|
|
||||||
* <li>Sec since - the ArServerMode::getActiveModeActivityTimeSecSince value (4-byte int)</li>
|
|
||||||
* </ol>
|
|
||||||
*
|
|
||||||
* These requests are in the <code>RobotInfo</code> command group.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ArServerInfoRobot
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerInfoRobot(ArServerBase *server, ArRobot *robot);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerInfoRobot();
|
|
||||||
/// The function that sends updates about the robot off to the client
|
|
||||||
AREXPORT void update(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// The function that sends updates about the robot off to the client
|
|
||||||
AREXPORT void updateNumbers(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// The function that sends updates about the robot off to the client
|
|
||||||
AREXPORT void updateStrings(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// The function that sends battery info about the robot off to the client
|
|
||||||
AREXPORT void batteryInfo(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// The function that sends information about the physical robot
|
|
||||||
AREXPORT void physicalInfo(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
/// The function that sends information about the time that the server mode was last active
|
|
||||||
AREXPORT void activityTimeInfo(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
protected:
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArRobot *myRobot;
|
|
||||||
|
|
||||||
void userTask(void);
|
|
||||||
|
|
||||||
std::string myStatus;
|
|
||||||
std::string myExtendedStatus;
|
|
||||||
std::string myMode;
|
|
||||||
std::string myOldStatus;
|
|
||||||
std::string myOldExtendedStatus;
|
|
||||||
std::string myOldMode;
|
|
||||||
|
|
||||||
|
|
||||||
ArFunctor2C<ArServerInfoRobot, ArServerClient *, ArNetPacket *> myUpdateCB;
|
|
||||||
ArFunctor2C<ArServerInfoRobot, ArServerClient *, ArNetPacket *> myUpdateNumbersCB;
|
|
||||||
ArFunctor2C<ArServerInfoRobot, ArServerClient *, ArNetPacket *> myUpdateStringsCB;
|
|
||||||
ArFunctor2C<ArServerInfoRobot, ArServerClient *, ArNetPacket *> myBatteryInfoCB;
|
|
||||||
ArFunctor2C<ArServerInfoRobot, ArServerClient *, ArNetPacket *> myPhysicalInfoCB;
|
|
||||||
ArFunctor2C<ArServerInfoRobot, ArServerClient *, ArNetPacket *> myActivityTimeInfoCB;
|
|
||||||
ArFunctorC<ArServerInfoRobot> myUserTaskCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,65 +0,0 @@
|
|||||||
#ifndef ARSERVERSENSORINFO_H
|
|
||||||
#define ARSERVERSENSORINFO_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
|
|
||||||
class ArServerClient;
|
|
||||||
|
|
||||||
/** Service providing clients with data from range sensors.
|
|
||||||
* This service accepts the following data requests:
|
|
||||||
* <ul>
|
|
||||||
* <li><code>getSensorList</code> to get a list of all robot sensors</li>
|
|
||||||
* <li><code>getSensorCurrent</code> to get one range sensor's set of current readings</li>
|
|
||||||
* <li><code>getSensorCumulative</code> to get one range sensor's set of cumualtive readings</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* The <code>getSensorList</code> request replies with the following data packet:
|
|
||||||
* <ol>
|
|
||||||
* <li>Number of sensors (2-byte integer)
|
|
||||||
* <li>For each sensor:
|
|
||||||
* <ol><li>sensor name (Null-terminated string)</li></ol>
|
|
||||||
* </li>
|
|
||||||
* </ol>
|
|
||||||
*
|
|
||||||
* The <code>getSensorCurrent</code> and <code>getSensorCumulative</code>
|
|
||||||
* requests must include the following data:
|
|
||||||
* <ol>
|
|
||||||
* <li>Sensor name (Null-terminated string)</li>
|
|
||||||
* </ol>
|
|
||||||
*
|
|
||||||
* The <code>getSensorCurrent</code> and <code>getSensorCumulative</code>
|
|
||||||
* requests reply with the following data packets:
|
|
||||||
* <ol>
|
|
||||||
* <li>Number of readings, or -1 for invalid sensor name error (2-byte integer)</li>
|
|
||||||
* <li>Sensor name (null-terminated string)</li>
|
|
||||||
* <li>For each reading:
|
|
||||||
* <ol>
|
|
||||||
* <li>X coordinate of reading (4-byte integer)</li>
|
|
||||||
* <li>Y coordinate of reading (4-byte integer)</li>
|
|
||||||
* </ol>
|
|
||||||
* </li>
|
|
||||||
* </ol>
|
|
||||||
*
|
|
||||||
* This service's requests are all in the <code>SensorInfo</code> group.
|
|
||||||
*/
|
|
||||||
class ArServerInfoSensor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AREXPORT ArServerInfoSensor(ArServerBase *server, ArRobot *robot);
|
|
||||||
AREXPORT virtual ~ArServerInfoSensor();
|
|
||||||
AREXPORT void getSensorList(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
AREXPORT void getSensorCurrent(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
AREXPORT void getSensorCumulative(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
protected:
|
|
||||||
ArRobot *myRobot;
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArFunctor2C<ArServerInfoSensor, ArServerClient *, ArNetPacket *> myGetSensorListCB;
|
|
||||||
ArFunctor2C<ArServerInfoSensor, ArServerClient *, ArNetPacket *> myGetSensorCurrentCB;
|
|
||||||
ArFunctor2C<ArServerInfoSensor, ArServerClient *, ArNetPacket *> myGetSensorCumulativeCB;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,67 +0,0 @@
|
|||||||
#ifndef ARSERVERHANDLERSTRINGS_H
|
|
||||||
#define ARSERVERHANDLERSTRINGS_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
|
|
||||||
class ArServerClient;
|
|
||||||
|
|
||||||
/**
|
|
||||||
This will set up strings to send to MobileEyes so that server
|
|
||||||
developers can easily add more information. There are different
|
|
||||||
ways ways you can add a string (they all are the same way
|
|
||||||
internally). The raw way is addString which takes a functor with a
|
|
||||||
buffer and a buffer len, the functor then has to fill in the string
|
|
||||||
when called. The other ways are set up for convenience and are
|
|
||||||
wrappers in this class around the addString, the other ways are
|
|
||||||
addStringInt, addStringDouble, addStringBool, these all take a
|
|
||||||
functor that returns the type and a format string (in addition to
|
|
||||||
the name and maxLen again).
|
|
||||||
**/
|
|
||||||
class ArServerInfoStrings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerInfoStrings(ArServerBase *server);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT ~ArServerInfoStrings();
|
|
||||||
/// Gets the information about the strings being sent
|
|
||||||
AREXPORT void netGetStringsInfo(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Gets the strings
|
|
||||||
AREXPORT void netGetStrings(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Adds a string to the list in the raw format
|
|
||||||
AREXPORT void addString(const char *name, ArTypes::UByte2 maxLen,
|
|
||||||
ArFunctor2<char *, ArTypes::UByte2> *functor);
|
|
||||||
/// Gets the functor for adding a string (for ArStringInfoGroup)
|
|
||||||
ArFunctor3<const char *, ArTypes::UByte2,
|
|
||||||
ArFunctor2<char *, ArTypes::UByte2> *> *
|
|
||||||
getAddStringFunctor(void) { return &myAddStringFunctor; }
|
|
||||||
|
|
||||||
/// Gets a string info holder, for internal purposes
|
|
||||||
AREXPORT ArStringInfoHolder *internalGetStringInfoHolder(const char *name);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ArServerBase *myServer;
|
|
||||||
|
|
||||||
AREXPORT void buildStringsInfoPacket(void);
|
|
||||||
ArNetPacket myStringInfoPacket;
|
|
||||||
AREXPORT void buildStringsPacket(void);
|
|
||||||
ArNetPacket myStringPacket;
|
|
||||||
ArTime myLastStringPacketBuild;
|
|
||||||
|
|
||||||
std::list<ArStringInfoHolder *> myStrings;
|
|
||||||
ArTypes::UByte2 myMaxMaxLength;
|
|
||||||
ArMutex myStringsMutex;
|
|
||||||
ArFunctor3C<ArServerInfoStrings, const char *, ArTypes::UByte2,
|
|
||||||
ArFunctor2<char *, ArTypes::UByte2> *> myAddStringFunctor;
|
|
||||||
|
|
||||||
ArFunctor2C<ArServerInfoStrings, ArServerClient *,
|
|
||||||
ArNetPacket *> myNetGetStringsInfoCB;
|
|
||||||
ArFunctor2C<ArServerInfoStrings, ArServerClient *,
|
|
||||||
ArNetPacket *> myNetGetStringsCB;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARSERVERHANDLERSTRINGS_H
|
|
@ -1,252 +0,0 @@
|
|||||||
#ifndef ARSERVERMODE_H
|
|
||||||
#define ARSERVERMODE_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
|
|
||||||
class ArServerModeIdle;
|
|
||||||
class ArServerClient;
|
|
||||||
|
|
||||||
/// A mode for controlling the robot (only one active)
|
|
||||||
|
|
||||||
/**
|
|
||||||
This is a lot like ArMode but for net control instead...
|
|
||||||
|
|
||||||
Only one mode can control the robot at once, this is made to be
|
|
||||||
subclassed. Each subclass needs to implement activate and
|
|
||||||
deactivate, activate MUST call baseActivate and if baseActivate
|
|
||||||
returns false then the mode is NOT active and shouldn't do
|
|
||||||
anything. Further each class should set myMode and myStatus to the
|
|
||||||
mode its in and the things its doing... You can lock your mode in
|
|
||||||
with lockMode and unlock it with unlockMode but you should redefine
|
|
||||||
the inherited requestUnlock and unlock yourself and deactivate
|
|
||||||
gracefully.
|
|
||||||
|
|
||||||
If you want to implement a server mode as a default mode then you also
|
|
||||||
need to implement checkDefault which will be called when nothing
|
|
||||||
else is active
|
|
||||||
|
|
||||||
Note that there's a new mechanism in place where if you use
|
|
||||||
addModeData instead of addData on the ArServerBase the command will
|
|
||||||
be placed into a map of available modes with commands that can be
|
|
||||||
gotten by the client. The active mode and whether its locked and
|
|
||||||
will unlock and such can now be gotten too... this is all so that
|
|
||||||
different commands can be disabled in client GUIs when they aren't
|
|
||||||
available.
|
|
||||||
**/
|
|
||||||
class ArServerMode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerMode(ArRobot *robot, ArServerBase *server, const char *name);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerMode();
|
|
||||||
/// This function should return the action group this mode uses
|
|
||||||
AREXPORT virtual ArActionGroup *getActionGroup(void) { return NULL; }
|
|
||||||
/** The function called when the mode is activated. Subclasses must implement
|
|
||||||
* this, but also call baseActivate().-
|
|
||||||
*/
|
|
||||||
AREXPORT virtual void activate(void) = 0;
|
|
||||||
/** The function called when the mode is deactivated. Subclasses must
|
|
||||||
* implement this, and also call baseDeactivate().
|
|
||||||
*/
|
|
||||||
AREXPORT virtual void deactivate(void) = 0;
|
|
||||||
/// The function called if the mode is not activated because another mode superceded it.
|
|
||||||
AREXPORT virtual void activationDenied(void) {}
|
|
||||||
|
|
||||||
/// The ArMode's user task, don't need one, subclass must provide if needed
|
|
||||||
AREXPORT virtual void userTask(void) {}
|
|
||||||
/// This will be called if another mode wants the lock broken (can ignore)
|
|
||||||
AREXPORT virtual void requestUnlock(void) { }
|
|
||||||
/// This will be called if another mode has to break the lock
|
|
||||||
AREXPORT virtual void forceUnlock(void);
|
|
||||||
/// Locks this mode in until its unlocked (mode must be the active mode)
|
|
||||||
AREXPORT void lockMode(bool willUnlockIfRequested = false);
|
|
||||||
/// Unlocks the mode so other modes can activate
|
|
||||||
AREXPORT void unlockMode(void);
|
|
||||||
/// Gets a string representing the mode we're in
|
|
||||||
AREXPORT const char *getMode(void) const { return myMode.c_str(); }
|
|
||||||
/// Gets a string representing the status of the mode we're in
|
|
||||||
AREXPORT const char *getStatus(void) const { return myStatus.c_str(); }
|
|
||||||
/// Gets a string representing the extended status of the mode we're
|
|
||||||
/// in
|
|
||||||
AREXPORT const char *getExtendedStatus(void) const { return myExtendedStatus.c_str(); }
|
|
||||||
/// Gets the active mode string
|
|
||||||
AREXPORT static const char *getActiveModeModeString(void);
|
|
||||||
/// Gets the active status string
|
|
||||||
AREXPORT static const char *getActiveModeStatusString(void);
|
|
||||||
/// Gets the active extended status string
|
|
||||||
AREXPORT static const char *getActiveModeExtendedStatusString(void);
|
|
||||||
/// Gets the name of the mode we're in
|
|
||||||
AREXPORT const char *getName(void) const { return myName.c_str(); }
|
|
||||||
/// Gets if this mode is active or not
|
|
||||||
AREXPORT bool isActive(void) const { return myIsActive; }
|
|
||||||
/// Gets if the active mode is locked or not
|
|
||||||
AREXPORT static bool isLocked(void);
|
|
||||||
/// Gets whether we'll unlock if requested or not
|
|
||||||
AREXPORT static bool willUnlockIfRequested(void);
|
|
||||||
/// Gets the active mode
|
|
||||||
AREXPORT static ArServerMode *getActiveMode(void);
|
|
||||||
/// Gets if we've set our activity time
|
|
||||||
AREXPORT bool hasSetActivityTime(void) { return myHasSetActivityTime; }
|
|
||||||
/// Gets the time of our last activity
|
|
||||||
AREXPORT ArTime getActivityTime(void);
|
|
||||||
/// Sets that we're active right now
|
|
||||||
AREXPORT void setActivityTimeToNow(void);
|
|
||||||
/// Gets the seconds since the activity of our active mode
|
|
||||||
AREXPORT static int getActiveModeActivityTimeSecSince(void);
|
|
||||||
/// Gets if the active mode set the activity time this cycle or not
|
|
||||||
AREXPORT static bool getActiveModeSetActivityThisCycle(void);
|
|
||||||
/// Sets this mode to default (so if a mode deactivates it activates this)
|
|
||||||
AREXPORT void addAsDefaultMode(ArListPos::Pos pos = ArListPos::LAST);
|
|
||||||
/// Sees if this wants to become the default mode
|
|
||||||
/**
|
|
||||||
This will be called when there would be no other modes, if this
|
|
||||||
mode wants to take over it should activate itself, if it doesn't
|
|
||||||
want to take over it shouldn't activate
|
|
||||||
**/
|
|
||||||
AREXPORT virtual void checkDefault(void) {}
|
|
||||||
/// This should only be used by careful people and probably not then
|
|
||||||
AREXPORT void setMode(const char *str) { myMode = str; }
|
|
||||||
/// This should only be used by careful people and probably not then
|
|
||||||
/**
|
|
||||||
This changes the status of the mode and sets the
|
|
||||||
myStatusSetThisCycle to true. If the mode inheriting is setting
|
|
||||||
the status in cycles then it should use this status instead and
|
|
||||||
then clear the myStatusSetThisFlag to false.
|
|
||||||
**/
|
|
||||||
AREXPORT void setStatus(const char *str)
|
|
||||||
{ myStatus = str; myStatusSetThisCycle = true; }
|
|
||||||
/// Adds data to the list of this mode's commands
|
|
||||||
|
|
||||||
|
|
||||||
/// Returns whether the mode should be automatically resumed after it was interrupted
|
|
||||||
/**
|
|
||||||
* This method primarily applies when the mode has been interrupted by a
|
|
||||||
* forced docking situation. In that case, when the docking mode is complete,
|
|
||||||
* it will resume the interrupted mode -- if this method returns true. This
|
|
||||||
* would primarily be applicable to very long, complex modes.
|
|
||||||
*
|
|
||||||
* The default return value is false.
|
|
||||||
**/
|
|
||||||
AREXPORT virtual bool isAutoResumeAfterInterrupt();
|
|
||||||
|
|
||||||
|
|
||||||
AREXPORT bool addModeData(
|
|
||||||
const char *name, const char *description,
|
|
||||||
ArFunctor2<ArServerClient *, ArNetPacket *> *functor,
|
|
||||||
const char *argumentDescription, const char *returnDescription,
|
|
||||||
const char *commandGroup = NULL, const char *dataFlags = NULL);
|
|
||||||
/// Gets the list of data for each mode
|
|
||||||
AREXPORT static void getModeDataList(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Gets the info about which mode is active and such
|
|
||||||
AREXPORT static void getModeInfo(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
/// Handles the packet request for the mode busy state.
|
|
||||||
AREXPORT static void getModeBusy(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
|
|
||||||
/// Adds a callback for when this class is activated
|
|
||||||
void addActivateCallback(
|
|
||||||
ArFunctor *functor, int position = 50)
|
|
||||||
{ myActivateCallbacks.addCallback(functor, position); }
|
|
||||||
/// Removes a callback for when this class is activated
|
|
||||||
void remActivateCallback(ArFunctor *functor)
|
|
||||||
{ myActivateCallbacks.remCallback(functor); }
|
|
||||||
/// Adds a callback for when this class is deactivated
|
|
||||||
void addDeactivateCallback(
|
|
||||||
ArFunctor *functor, int position = 50)
|
|
||||||
{ myDeactivateCallbacks.addCallback(functor, position); }
|
|
||||||
/// Removes a callback for when this class is deactivated
|
|
||||||
void remDeactivateCallback(ArFunctor *functor)
|
|
||||||
{ myDeactivateCallbacks.remCallback(functor); }
|
|
||||||
|
|
||||||
/// Adds a single shot callback for when this class is deactivated
|
|
||||||
void addSingleShotDeactivateCallback(
|
|
||||||
ArFunctor *functor, int position = 50)
|
|
||||||
{ mySingleShotDeactivateCallbacks.addCallback(functor, position); }
|
|
||||||
/// Removes a single shot callback for when this class is deactivated
|
|
||||||
void remSingleShotDeactivateCallback(ArFunctor *functor)
|
|
||||||
{ mySingleShotDeactivateCallbacks.remCallback(functor); }
|
|
||||||
|
|
||||||
/// Call that gets our idle mode
|
|
||||||
AREXPORT static ArServerModeIdle *getIdleMode(void);
|
|
||||||
protected:
|
|
||||||
AREXPORT static void modeUserTask(void);
|
|
||||||
AREXPORT static void buildModeInfoPacket(ArNetPacket *packet);
|
|
||||||
AREXPORT static std::list<ArServerMode *> *getRequestedActivateModes(void);
|
|
||||||
AREXPORT void checkBroadcastModeInfoPacket(void);
|
|
||||||
/** Activates this mode if it can (returns true if it can, false otherwise).
|
|
||||||
If we have an ArRobot instance (myRobot), then robot motion is stopped.
|
|
||||||
Activity time is reset, and activate callbacks are called.
|
|
||||||
*/
|
|
||||||
AREXPORT bool baseActivate(void);
|
|
||||||
/** Deactivates this mode. Deactivation callbacks are called. The next mode to
|
|
||||||
be activated is activated, if any. (E.g. the global default mode)
|
|
||||||
*/
|
|
||||||
AREXPORT void baseDeactivate(void);
|
|
||||||
|
|
||||||
ArCallbackList myActivateCallbacks;
|
|
||||||
ArCallbackList myDeactivateCallbacks;
|
|
||||||
ArCallbackList mySingleShotDeactivateCallbacks;
|
|
||||||
|
|
||||||
bool myIsActive;
|
|
||||||
ArRobot *myRobot;
|
|
||||||
ArServerBase *myServer;
|
|
||||||
std::string myName;
|
|
||||||
// inheritors will want to play with these two strings as they are
|
|
||||||
// what is shown to the user
|
|
||||||
std::string myMode;
|
|
||||||
std::string myStatus;
|
|
||||||
bool myStatusSetThisCycle;
|
|
||||||
std::string myExtendedStatus;
|
|
||||||
|
|
||||||
// variables for activity time (so we can do things if idle) this
|
|
||||||
// isn't static so that each mode can have its own
|
|
||||||
// 'myHasSetActivityTime' so that if a mode doesn't use this scheme
|
|
||||||
// it doesn't get tromped on
|
|
||||||
bool myHasSetActivityTime;
|
|
||||||
bool mySetActivityThisCycle;
|
|
||||||
ArTime myActivityTime;
|
|
||||||
ArMutex myActivityTimeMutex;
|
|
||||||
|
|
||||||
AREXPORT static bool ourActiveModeLocked;
|
|
||||||
AREXPORT static bool ourActiveModeWillUnlockIfRequested;
|
|
||||||
AREXPORT static ArServerMode *ourActiveMode;
|
|
||||||
AREXPORT static ArServerMode *ourNextActiveMode;
|
|
||||||
AREXPORT static ArServerMode *ourLastActiveMode;
|
|
||||||
AREXPORT static bool ourActiveModeSetActivityThisCycle;
|
|
||||||
|
|
||||||
AREXPORT ArServerMode *getLastActiveMode();
|
|
||||||
|
|
||||||
AREXPORT static bool ourIsBusy;
|
|
||||||
AREXPORT static ArServerBase *ourServerBase;
|
|
||||||
|
|
||||||
AREXPORT static std::list<ArServerMode *> ourModes;
|
|
||||||
AREXPORT static std::list<ArServerMode *> ourDefaultModes;
|
|
||||||
AREXPORT static std::list<ArServerMode *> ourRequestedActivateModes;
|
|
||||||
AREXPORT static std::multimap<std::string, std::string> ourModeDataMap;
|
|
||||||
AREXPORT static ArMutex ourModeDataMapMutex;
|
|
||||||
|
|
||||||
AREXPORT static ArGlobalFunctor2<ArServerClient *,
|
|
||||||
ArNetPacket *> ourGetModeDataListCB;
|
|
||||||
AREXPORT static ArGlobalFunctor2<ArServerClient *,
|
|
||||||
ArNetPacket *> ourGetModeInfoCB;
|
|
||||||
AREXPORT static ArGlobalFunctor2<ArServerClient *,
|
|
||||||
ArNetPacket *> ourGetModeBusyCB;
|
|
||||||
|
|
||||||
AREXPORT static bool ourBroadcastActiveModeLocked;
|
|
||||||
AREXPORT static ArServerMode *ourBroadcastActiveMode;
|
|
||||||
AREXPORT static bool ourBroadcastActiveModeWillUnlockIfRequested;
|
|
||||||
AREXPORT static ArGlobalFunctor ourUserTaskCB;
|
|
||||||
AREXPORT static bool ourUserTaskAdded;
|
|
||||||
// so we can easily just get the verbose out of this one
|
|
||||||
ArLog::LogLevel myVerboseLogLevel;
|
|
||||||
|
|
||||||
AREXPORT static ArServerModeIdle *ourIdleMode;
|
|
||||||
AREXPORT static ArMutex ourIdleModeMutex;
|
|
||||||
AREXPORT static bool ourIdleModeCreated;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARSERVERMODE_H
|
|
@ -1,56 +0,0 @@
|
|||||||
#ifndef ARSERVERMODEDRIVE_H
|
|
||||||
#define ARSERVERMODEDRIVE_H
|
|
||||||
|
|
||||||
#include "ariaTypedefs.h"
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
#include "ArServerMode.h"
|
|
||||||
|
|
||||||
class ArServerModeDrive : public ArServerMode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AREXPORT ArServerModeDrive(ArServerBase *server, ArRobot *robot,
|
|
||||||
bool takeControlOnJoystick = false);
|
|
||||||
AREXPORT virtual ~ArServerModeDrive();
|
|
||||||
AREXPORT virtual void activate(void);
|
|
||||||
AREXPORT virtual void deactivate(void);
|
|
||||||
/// This adds commands that'll let you disable and enable safe driving
|
|
||||||
AREXPORT void addControlCommands(ArServerHandlerCommands *handlerCommands);
|
|
||||||
AREXPORT void driveJoystick(double vel,
|
|
||||||
double rotVel,
|
|
||||||
bool isActivating = true);
|
|
||||||
AREXPORT void serverDriveJoystick(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
AREXPORT virtual void userTask(void);
|
|
||||||
AREXPORT void setThrottleParams(int lowSpeed, int highSpeed);
|
|
||||||
AREXPORT virtual ArActionGroup *getActionGroup(void) { return &myDriveGroup;}
|
|
||||||
AREXPORT void setSafeDriving(bool safe);
|
|
||||||
AREXPORT bool getSafeDriving(void);
|
|
||||||
/// this action will be activated in unsafe mode
|
|
||||||
AREXPORT void setExtraUnsafeAction(ArAction *action)
|
|
||||||
{ myExtraUnsafeAction = action; }
|
|
||||||
protected:
|
|
||||||
AREXPORT void serverSafeDrivingEnable(void);
|
|
||||||
AREXPORT void serverSafeDrivingDisable(void);
|
|
||||||
AREXPORT void joyUserTask(void);
|
|
||||||
ArAction *myExtraUnsafeAction;
|
|
||||||
ArJoyHandler *myJoyHandler;
|
|
||||||
ArActionJoydrive myJoydriveAction;
|
|
||||||
ArActionInput *myInputAction;
|
|
||||||
ArActionStop myStopAction;
|
|
||||||
ArActionGroupInput myDriveGroup;
|
|
||||||
ArFunctor2C<ArServerModeDrive, ArServerClient *, ArNetPacket *> myServerDriveJoystickCB;
|
|
||||||
ArFunctorC<ArServerModeDrive> myJoyUserTaskCB;
|
|
||||||
bool myDriveSafely;
|
|
||||||
bool myNewDriveSafely;
|
|
||||||
double myVel;
|
|
||||||
double myRotVel;
|
|
||||||
bool myTakeControlOnJoystick;
|
|
||||||
// for the simple commands
|
|
||||||
ArServerHandlerCommands *myHandlerCommands;
|
|
||||||
ArFunctorC<ArServerModeDrive> myServerSafeDrivingEnableCB;
|
|
||||||
ArFunctorC<ArServerModeDrive> myServerSafeDrivingDisableCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ARNETMODEDRIVE_H
|
|
@ -1,43 +0,0 @@
|
|||||||
#ifndef ARNETMODEIDLE_H
|
|
||||||
#define ARNETMODEIDLE_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerMode.h"
|
|
||||||
|
|
||||||
/// Mode that the ArServerMode infrastructure will activate if someone
|
|
||||||
/// tries to switch from one mode to another and there's idle
|
|
||||||
/// processing to be done...
|
|
||||||
class ArServerModeIdle : public ArServerMode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerModeIdle(ArServerBase *server, ArRobot *robot);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerModeIdle();
|
|
||||||
AREXPORT virtual void activate(void);
|
|
||||||
AREXPORT virtual void deactivate(void);
|
|
||||||
AREXPORT virtual void userTask(void);
|
|
||||||
/// Gets the mode that this mode interrupted (or NULL if none)
|
|
||||||
AREXPORT void setModeInterrupted(ArServerMode *modeInterrupted);
|
|
||||||
/// Gets the mode that this mode interrupted (or NULL if it didn't interrupt anything)
|
|
||||||
AREXPORT ArServerMode *getModeInterrupted(void);
|
|
||||||
AREXPORT virtual ArActionGroup *getActionGroup(void) { return &myStopGroup; }
|
|
||||||
/// Adds to the config
|
|
||||||
AREXPORT void addToConfig(ArConfig *config, const char *section = "Teleop settings");
|
|
||||||
/// Sets whether we're using the range devices that depend on location
|
|
||||||
AREXPORT void setUseLocationDependentDevices(
|
|
||||||
bool useLocationDependentDevices, bool internal = false);
|
|
||||||
/// Gets whether we're using the range devices that depend on location
|
|
||||||
AREXPORT bool getUseLocationDependentDevices(void);
|
|
||||||
protected:
|
|
||||||
ArActionDeceleratingLimiter *myLimiterForward;
|
|
||||||
ArActionDeceleratingLimiter *myLimiterBackward;
|
|
||||||
ArActionDeceleratingLimiter *myLimiterLateralLeft;
|
|
||||||
ArActionDeceleratingLimiter *myLimiterLateralRight;
|
|
||||||
ArActionGroupStop myStopGroup;
|
|
||||||
bool myUseLocationDependentDevices;
|
|
||||||
ArServerMode *myModeInterrupted;
|
|
||||||
ArFunctor2C<ArServerModeIdle, ArServerClient *, ArNetPacket *> myNetIdleCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARNETMODEIDLE_H
|
|
@ -1,132 +0,0 @@
|
|||||||
#ifndef ARSERVERMODERATIODRIVE_H
|
|
||||||
#define ARSERVERMODERATIODRIVE_H
|
|
||||||
|
|
||||||
#include "ariaTypedefs.h"
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerMode.h"
|
|
||||||
|
|
||||||
class ArServerHandlerCommands;
|
|
||||||
|
|
||||||
class ArServerModeRatioDrive : public ArServerMode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerModeRatioDrive(ArServerBase *server, ArRobot *robot,
|
|
||||||
bool takeControlOnJoystick = true,
|
|
||||||
bool useComputerJoystick = true,
|
|
||||||
bool useRobotJoystick = true,
|
|
||||||
bool useServerCommands = true,
|
|
||||||
const char *name = "ratioDrive",
|
|
||||||
bool robotJoystickOverridesLocks = true);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerModeRatioDrive();
|
|
||||||
AREXPORT virtual void activate(void);
|
|
||||||
AREXPORT virtual void deactivate(void);
|
|
||||||
/// This adds commands that'll let you disable and enable safe driving
|
|
||||||
AREXPORT void addControlCommands(ArServerHandlerCommands *handlerCommands);
|
|
||||||
/// Sets the ratio drive action
|
|
||||||
AREXPORT void ratioDrive(double transRatio,
|
|
||||||
double rotRatio,
|
|
||||||
double throttleRatio,
|
|
||||||
bool isActivating = false,
|
|
||||||
double latRatio = 0);
|
|
||||||
/// Adds to a config in a section
|
|
||||||
AREXPORT void addToConfig(ArConfig *config, const char *section);
|
|
||||||
AREXPORT virtual void userTask(void);
|
|
||||||
AREXPORT virtual ArActionGroup *getActionGroup(void) { return &myRatioDriveGroup;}
|
|
||||||
ArActionRatioInput *getActionRatioInput(void) { return myRatioAction; }
|
|
||||||
/// Sets whether we're safe driving or not
|
|
||||||
AREXPORT void setSafeDriving(bool safe, bool internal = false);
|
|
||||||
/// Gets whether we're driving safely or not
|
|
||||||
AREXPORT bool getSafeDriving(void);
|
|
||||||
/// Sets whether we're using the range devices that depend on location
|
|
||||||
AREXPORT void setUseLocationDependentDevices(
|
|
||||||
bool useLocationDependentDevices, bool internal = false);
|
|
||||||
/// Gets whether we're using the range devices that depend on location
|
|
||||||
AREXPORT bool getUseLocationDependentDevices(void);
|
|
||||||
/// Adds a callback mode for when safe driving is activated
|
|
||||||
void addSafeDrivingCallback(ArFunctor *functor, int position = 50)
|
|
||||||
{ mySafeDrivingCallbacks.addCallback(functor, position); }
|
|
||||||
/// Removes a callback mode for when safe driving is activated
|
|
||||||
void remSafeDrivingCallback(ArFunctor *functor)
|
|
||||||
{ mySafeDrivingCallbacks.remCallback(functor); }
|
|
||||||
/// Adds a callback mode for when unsafe driving is activated
|
|
||||||
void addUnsafeDrivingCallback(ArFunctor *functor, int position = 50)
|
|
||||||
{ myUnsafeDrivingCallbacks.addCallback(functor, position); }
|
|
||||||
/// Removes a callback mode for when unsafe driving is activated
|
|
||||||
void remUnsafeDrivingCallback(ArFunctor *functor)
|
|
||||||
{ myUnsafeDrivingCallbacks.remCallback(functor); }
|
|
||||||
/// Adds a callback mode for when trying to back up
|
|
||||||
void addDrivingBackwardsCallback(ArFunctor *functor, int position = 50)
|
|
||||||
{ myDrivingBackwardsCallbacks.addCallback(functor, position); }
|
|
||||||
/// Removes a callback mode for when trying to back up
|
|
||||||
void remDrivingBackwardsCallback(ArFunctor *functor)
|
|
||||||
{ myDrivingBackwardsCallbacks.remCallback(functor); }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
AREXPORT void serverRatioDrive(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
AREXPORT void serverSetSafeDrive(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
AREXPORT void serverGetSafeDrive(ArServerClient *client,
|
|
||||||
ArNetPacket *packet);
|
|
||||||
AREXPORT void serverSafeDrivingEnable(void);
|
|
||||||
AREXPORT void serverSafeDrivingDisable(void);
|
|
||||||
AREXPORT void ratioFireCallback(void);
|
|
||||||
AREXPORT void joyUserTask(void);
|
|
||||||
ArJoyHandler *myJoyHandler;
|
|
||||||
ArRobotJoyHandler *myRobotJoyHandler;
|
|
||||||
|
|
||||||
bool myTakeControlOnJoystick;
|
|
||||||
bool myUseComputerJoystick;
|
|
||||||
bool myUseRobotJoystick;
|
|
||||||
bool myUseServerCommands;
|
|
||||||
bool myPrinting;
|
|
||||||
bool myRobotJoystickOverridesLock;
|
|
||||||
double myTransRatio;
|
|
||||||
double myRotRatio;
|
|
||||||
double myThrottleRatio;
|
|
||||||
double myLatRatio;
|
|
||||||
|
|
||||||
double myTimeout;
|
|
||||||
|
|
||||||
bool myGotServerCommand;
|
|
||||||
bool myLastTimedOut;
|
|
||||||
|
|
||||||
ArActionDeceleratingLimiter *myLimiterForward;
|
|
||||||
ArActionDeceleratingLimiter *myLimiterBackward;
|
|
||||||
ArActionDeceleratingLimiter *myLimiterLateralLeft;
|
|
||||||
ArActionDeceleratingLimiter *myLimiterLateralRight;
|
|
||||||
ArRatioInputJoydrive *myJoydrive;
|
|
||||||
ArRatioInputRobotJoydrive *myRobotJoydrive;
|
|
||||||
ArActionRatioInput *myRatioAction;
|
|
||||||
ArActionMovementParameters *myMovementParameters;
|
|
||||||
ArActionGroup myRatioDriveGroup;
|
|
||||||
bool myDriveSafely;
|
|
||||||
bool myNewDriveSafely;
|
|
||||||
bool myUseLocationDependentDevices;
|
|
||||||
bool myLastRobotSafeDrive;
|
|
||||||
|
|
||||||
ArTime myLastCommand;
|
|
||||||
|
|
||||||
// SEEKUR
|
|
||||||
bool mySentRecenter;
|
|
||||||
|
|
||||||
ArCallbackList mySafeDrivingCallbacks;
|
|
||||||
ArCallbackList myUnsafeDrivingCallbacks;
|
|
||||||
ArCallbackList myDrivingBackwardsCallbacks;
|
|
||||||
|
|
||||||
ArFunctorC<ArServerModeRatioDrive> myJoyUserTaskCB;
|
|
||||||
ArFunctor2C<ArServerModeRatioDrive, ArServerClient *, ArNetPacket *> myServerSetSafeDriveCB;
|
|
||||||
ArFunctor2C<ArServerModeRatioDrive, ArServerClient *, ArNetPacket *> myServerGetSafeDriveCB;
|
|
||||||
ArFunctor2C<ArServerModeRatioDrive, ArServerClient *, ArNetPacket *> myServerRatioDriveCB;
|
|
||||||
ArFunctorC<ArServerModeRatioDrive> myRatioFireCB;
|
|
||||||
|
|
||||||
// for the simple commands
|
|
||||||
ArServerHandlerCommands *myHandlerCommands;
|
|
||||||
ArFunctorC<ArServerModeRatioDrive> myServerSafeDrivingEnableCB;
|
|
||||||
ArFunctorC<ArServerModeRatioDrive> myServerSafeDrivingDisableCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ARNETMODERATIODRIVE_H
|
|
@ -1,37 +0,0 @@
|
|||||||
#ifndef ARNETMODESTOP_H
|
|
||||||
#define ARNETMODESTOP_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerMode.h"
|
|
||||||
|
|
||||||
class ArServerModeStop : public ArServerMode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AREXPORT ArServerModeStop(ArServerBase *server, ArRobot *robot,
|
|
||||||
bool defunct = false);
|
|
||||||
AREXPORT virtual ~ArServerModeStop();
|
|
||||||
AREXPORT virtual void activate(void);
|
|
||||||
AREXPORT virtual void deactivate(void);
|
|
||||||
AREXPORT void stop(void);
|
|
||||||
AREXPORT void netStop(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
AREXPORT virtual void userTask(void);
|
|
||||||
AREXPORT virtual void checkDefault(void) { activate(); }
|
|
||||||
AREXPORT virtual ArActionGroup *getActionGroup(void) { return &myStopGroup; }
|
|
||||||
/// Adds to the config
|
|
||||||
AREXPORT void addToConfig(ArConfig *config, const char *section = "Teleop settings");
|
|
||||||
/// Sets whether we're using the range devices that depend on location
|
|
||||||
AREXPORT void setUseLocationDependentDevices(
|
|
||||||
bool useLocationDependentDevices, bool internal = false);
|
|
||||||
/// Gets whether we're using the range devices that depend on location
|
|
||||||
AREXPORT bool getUseLocationDependentDevices(void);
|
|
||||||
protected:
|
|
||||||
ArActionDeceleratingLimiter *myLimiterForward;
|
|
||||||
ArActionDeceleratingLimiter *myLimiterBackward;
|
|
||||||
ArActionDeceleratingLimiter *myLimiterLateralLeft;
|
|
||||||
ArActionDeceleratingLimiter *myLimiterLateralRight;
|
|
||||||
ArActionGroupStop myStopGroup;
|
|
||||||
bool myUseLocationDependentDevices;
|
|
||||||
ArFunctor2C<ArServerModeStop, ArServerClient *, ArNetPacket *> myNetStopCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARNETMODESTOP_H
|
|
@ -1,26 +0,0 @@
|
|||||||
#ifndef ARNETMODEWANDER_H
|
|
||||||
#define ARNETMODEWANDER_H
|
|
||||||
|
|
||||||
#include "ariaTypedefs.h"
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
#include "ArServerMode.h"
|
|
||||||
|
|
||||||
class ArServerModeWander : public ArServerMode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AREXPORT ArServerModeWander(ArServerBase *server, ArRobot *robot);
|
|
||||||
AREXPORT virtual ~ArServerModeWander();
|
|
||||||
AREXPORT virtual void activate(void);
|
|
||||||
AREXPORT virtual void deactivate(void);
|
|
||||||
AREXPORT void wander(void);
|
|
||||||
AREXPORT void netWander(ArServerClient *client, ArNetPacket *packet);
|
|
||||||
AREXPORT virtual void userTask(void);
|
|
||||||
AREXPORT virtual void checkDefault(void) { activate(); }
|
|
||||||
AREXPORT virtual ArActionGroup *getActionGroup(void) {return &myWanderGroup;}
|
|
||||||
protected:
|
|
||||||
ArActionGroupWander myWanderGroup;
|
|
||||||
ArFunctor2C<ArServerModeWander, ArServerClient *, ArNetPacket *> myNetWanderCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARNETMODEWANDER_H
|
|
@ -1,301 +0,0 @@
|
|||||||
#ifndef ARSERVERSIMPLECOMMANDS_H
|
|
||||||
#define ARSERVERSIMPLECOMMANDS_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArServerBase.h"
|
|
||||||
#include "ArServerHandlerCommands.h"
|
|
||||||
#include "ArServerHandlerPopup.h"
|
|
||||||
|
|
||||||
/// Class for sending commands to the microcontroller (uC)
|
|
||||||
/**
|
|
||||||
This class will let you send commands to the microcontroller (com,
|
|
||||||
comInt, and com2Bytes).
|
|
||||||
**/
|
|
||||||
class ArServerSimpleComUC
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerSimpleComUC(ArServerHandlerCommands *handlerCommands,
|
|
||||||
ArRobot *robot);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerSimpleComUC();
|
|
||||||
/// Handles the command
|
|
||||||
AREXPORT void command(ArArgumentBuilder *arg);
|
|
||||||
/// Handles the motor commands
|
|
||||||
AREXPORT void motionCommand(ArArgumentBuilder *arg);
|
|
||||||
protected:
|
|
||||||
void processCommand(ArArgumentBuilder *arg, bool motionCommand);
|
|
||||||
ArRobot *myRobot;
|
|
||||||
ArServerHandlerCommands *myHandlerCommands;
|
|
||||||
ArFunctor1C<ArServerSimpleComUC, ArArgumentBuilder *> myCommandCB;
|
|
||||||
ArFunctor1C<ArServerSimpleComUC, ArArgumentBuilder *> myMotionCommandCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Class for enabling or disabling logging of movement commands and data
|
|
||||||
/**
|
|
||||||
This just calls ArRobot::setLogMovementSent and
|
|
||||||
ArRobot::setLogLovementReceived. It makes these available for easy
|
|
||||||
enabling or disabling on the client side.
|
|
||||||
**/
|
|
||||||
class ArServerSimpleComMovementLogging
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerSimpleComMovementLogging(
|
|
||||||
ArServerHandlerCommands *handlerCommands, ArRobot *robot,
|
|
||||||
ArServerHandlerPopup *popupHandler = NULL);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerSimpleComMovementLogging();
|
|
||||||
/// Enable logging of movement commands sent to the robot
|
|
||||||
AREXPORT void logMovementSentEnable(void);
|
|
||||||
/// Disable logging of movement commands sent to the robot
|
|
||||||
AREXPORT void logMovementSentDisable(void);
|
|
||||||
/// Enable logging of movement received from the robot
|
|
||||||
AREXPORT void logMovementReceivedEnable(void);
|
|
||||||
/// Disable logging of movement received from the robot
|
|
||||||
AREXPORT void logMovementReceivedDisable(void);
|
|
||||||
/// Enable logging of velocities received from the robot
|
|
||||||
AREXPORT void logVelocitiesReceivedEnable(void);
|
|
||||||
/// Disable logging of velocities received from the robot
|
|
||||||
AREXPORT void logVelocitiesReceivedDisable(void);
|
|
||||||
/// Enable tracking of packets from the robot
|
|
||||||
AREXPORT void packetsReceivedTrackingEnable(void);
|
|
||||||
/// Disable tracking of packets from the robot
|
|
||||||
AREXPORT void packetsReceivedTrackingDisable(void);
|
|
||||||
/// Enable tracking of packets from the robot
|
|
||||||
AREXPORT void packetsSentTrackingEnable(void);
|
|
||||||
/// Disable tracking of packets from the robot
|
|
||||||
AREXPORT void packetsSentTrackingDisable(void);
|
|
||||||
/// Enable logging of velocities received from the robot
|
|
||||||
AREXPORT void logActionsEnable(void);
|
|
||||||
/// Disable logging of velocities received from the robot
|
|
||||||
AREXPORT void logActionsDisable(void);
|
|
||||||
/// Log the status of the actions on the robot
|
|
||||||
AREXPORT void logActions(void);
|
|
||||||
/// Popups up the movement parameters
|
|
||||||
AREXPORT void popupMovementParams(void);
|
|
||||||
/// Resets the odometer
|
|
||||||
AREXPORT void resetOdometer(void);
|
|
||||||
protected:
|
|
||||||
ArRobot *myRobot;
|
|
||||||
ArServerHandlerCommands *myHandlerCommands;
|
|
||||||
ArServerHandlerPopup *myPopupHandler;
|
|
||||||
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myLogMovementSentEnableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myLogMovementSentDisableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myLogMovementReceivedEnableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myLogMovementReceivedDisableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myLogVelocitiesReceivedEnableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myLogVelocitiesReceivedDisableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myPacketsReceivedTrackingEnableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myPacketsReceivedTrackingDisableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myPacketsSentTrackingEnableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myPacketsSentTrackingDisableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myLogActionsEnableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myLogActionsDisableCB;
|
|
||||||
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myLogActionsCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myPopupMovementParamsCB;
|
|
||||||
ArFunctorC<ArServerSimpleComMovementLogging> myResetOdometerCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Class for enabling or disabling the gyro
|
|
||||||
/**
|
|
||||||
This just calls ArAnalogGyro::activate and
|
|
||||||
ArAnalogGyro::deactivate. If you want to see the gyro data if you
|
|
||||||
use the robot's movement received (either
|
|
||||||
ArRobot::setLogMovementReceived or use
|
|
||||||
ArServerSimpleComMovementLogging)
|
|
||||||
**/
|
|
||||||
class ArServerSimpleComGyro
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerSimpleComGyro(
|
|
||||||
ArServerHandlerCommands *handlerCommands, ArRobot *robot,
|
|
||||||
ArAnalogGyro *gyro);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerSimpleComGyro();
|
|
||||||
/// Enables the gyro
|
|
||||||
AREXPORT void gyroEnable(void);
|
|
||||||
/// Disables the gyro
|
|
||||||
AREXPORT void gyroDisable(void);
|
|
||||||
protected:
|
|
||||||
ArRobot *myRobot;
|
|
||||||
ArAnalogGyro *myGyro;
|
|
||||||
ArServerHandlerCommands *myHandlerCommands;
|
|
||||||
ArFunctorC<ArServerSimpleComGyro> myGyroEnableCB;
|
|
||||||
ArFunctorC<ArServerSimpleComGyro> myGyroDisableCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/// Request configuration from robot controller and log the result
|
|
||||||
class ArServerSimpleComLogRobotConfig
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AREXPORT ArServerSimpleComLogRobotConfig(
|
|
||||||
ArServerHandlerCommands *commands, ArRobot* robot,
|
|
||||||
ArServerHandlerPopup *popupHandler = NULL);
|
|
||||||
AREXPORT void logConfig(void);
|
|
||||||
AREXPORT void logMovementConfig(void);
|
|
||||||
AREXPORT void logOrigConfig(void);
|
|
||||||
AREXPORT void popupConfig(void);
|
|
||||||
AREXPORT void popupOrigConfig(void);
|
|
||||||
AREXPORT void popupMovementConfig(void);
|
|
||||||
private:
|
|
||||||
void configPacketArrived(void);
|
|
||||||
ArServerHandlerCommands *myHandlerCommands;
|
|
||||||
ArRobot* myRobot;
|
|
||||||
ArServerHandlerPopup *myPopupHandler;
|
|
||||||
|
|
||||||
bool myLogConfig;
|
|
||||||
bool myPopupConfig;
|
|
||||||
bool myLogConfigMovement;
|
|
||||||
bool myPopupConfigMovement;
|
|
||||||
|
|
||||||
|
|
||||||
ArFunctorC<ArServerSimpleComLogRobotConfig> myPacketArrivedCB;
|
|
||||||
ArRobotConfigPacketReader myPacketReader;
|
|
||||||
ArFunctorC<ArServerSimpleComLogRobotConfig> myLogConfigCB;
|
|
||||||
ArFunctorC<ArServerSimpleComLogRobotConfig> myLogMovementConfigCB;
|
|
||||||
ArFunctorC<ArServerSimpleComLogRobotConfig> myLogOrigConfigCB;
|
|
||||||
ArFunctorC<ArServerSimpleComLogRobotConfig> myPopupConfigCB;
|
|
||||||
ArFunctorC<ArServerSimpleComLogRobotConfig> myPopupOrigConfigCB;
|
|
||||||
ArFunctorC<ArServerSimpleComLogRobotConfig> myPopupMovementConfigCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Log current ArRobot actions.
|
|
||||||
class ArServerSimpleComLogActions
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AREXPORT ArServerSimpleComLogActions(ArServerHandlerCommands *commands, ArRobot* robot);
|
|
||||||
AREXPORT void logActions();
|
|
||||||
private:
|
|
||||||
ArRobot* myRobot;
|
|
||||||
ArFunctorC<ArServerSimpleComLogActions> myCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ArServerSimpleServerCommands
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AREXPORT ArServerSimpleServerCommands(
|
|
||||||
ArServerHandlerCommands *commands, ArServerBase *server,
|
|
||||||
bool addLogConnections = true);
|
|
||||||
AREXPORT virtual ~ArServerSimpleServerCommands();
|
|
||||||
AREXPORT void logTerseTracking(void);
|
|
||||||
AREXPORT void logVerboseTracking(void);
|
|
||||||
AREXPORT void resetTracking(void);
|
|
||||||
AREXPORT void logConnections(void);
|
|
||||||
private:
|
|
||||||
ArServerBase *myServer;
|
|
||||||
ArFunctorC<ArServerSimpleServerCommands> myTerseTrackingCB;
|
|
||||||
ArFunctorC<ArServerSimpleServerCommands> myVerboseTrackingCB;
|
|
||||||
ArFunctorC<ArServerSimpleServerCommands> myResetTrackingCB;
|
|
||||||
ArFunctorC<ArServerSimpleServerCommands> myLogConnectionsCB;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Class for sending popups out the server
|
|
||||||
/**
|
|
||||||
This class will let you make a popup in MobileEyes, mostly for testing
|
|
||||||
**/
|
|
||||||
class ArServerSimplePopup
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerSimplePopup(ArServerHandlerCommands *commands,
|
|
||||||
ArServerHandlerPopup *popupHandler);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerSimplePopup();
|
|
||||||
/// Handles the command
|
|
||||||
AREXPORT void simplePopup(ArArgumentBuilder *arg);
|
|
||||||
protected:
|
|
||||||
ArServerHandlerCommands *myCommands;
|
|
||||||
ArServerHandlerPopup *myPopupHandler;
|
|
||||||
ArFunctor1C<ArServerSimplePopup, ArArgumentBuilder *> mySimplePopupCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Class that logs a special debug packet from the robot
|
|
||||||
class ArServerSimpleLogRobotDebugPackets
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerSimpleLogRobotDebugPackets(
|
|
||||||
ArServerHandlerCommands *commands, ArRobot *robot,
|
|
||||||
const char *baseDirectory = "");
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerSimpleLogRobotDebugPackets();
|
|
||||||
/// Starts the logging
|
|
||||||
AREXPORT bool startLogging(
|
|
||||||
const char *fileName = "robotDebugPacketsLog.txt");
|
|
||||||
/// Ends the logging
|
|
||||||
AREXPORT bool stopLogging(void);
|
|
||||||
/// Internal function that parses the packet
|
|
||||||
AREXPORT bool packetHandler(ArRobotPacket *packet);
|
|
||||||
/// Adds the robot debug info to the info group
|
|
||||||
AREXPORT void addToInfoGroup(ArStringInfoGroup *infoGroup,
|
|
||||||
const char *name, int whichVal,
|
|
||||||
const char *format = "%d");
|
|
||||||
/// Gets the number of values there are
|
|
||||||
AREXPORT int getNumValues(void);
|
|
||||||
/// Gets a particular value
|
|
||||||
AREXPORT int getValue(int whichVal);
|
|
||||||
protected:
|
|
||||||
ArRobot *myRobot;
|
|
||||||
ArServerHandlerCommands *myCommands;
|
|
||||||
// the file we write to, if its NULL we're not logging
|
|
||||||
FILE *myFile;
|
|
||||||
std::string myBaseDir;
|
|
||||||
std::map<int, int> myVals;
|
|
||||||
int myNumVals;
|
|
||||||
ArRetFunctor1C<bool, ArServerSimpleLogRobotDebugPackets,
|
|
||||||
ArRobotPacket *> myPacketHandlerCB;
|
|
||||||
ArRetFunctor1C<bool, ArServerSimpleLogRobotDebugPackets,
|
|
||||||
const char *> myStartLoggingCB;
|
|
||||||
ArRetFunctorC<bool, ArServerSimpleLogRobotDebugPackets> myStopLoggingCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/// Class for sending commands to the microcontroller (uC)
|
|
||||||
/**
|
|
||||||
This class will let you send commands to the microcontroller (com,
|
|
||||||
comInt, and com2Bytes).
|
|
||||||
**/
|
|
||||||
class ArServerSimpleConnectionTester
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerSimpleConnectionTester(
|
|
||||||
ArServerHandlerCommands *handlerCommands, ArRobot *robot);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArServerSimpleConnectionTester();
|
|
||||||
/// Handles the command
|
|
||||||
AREXPORT void connectionTestStart(void);
|
|
||||||
/// Handles the motor commands
|
|
||||||
AREXPORT void connectionTestStop(void);
|
|
||||||
protected:
|
|
||||||
ArRobot *myRobot;
|
|
||||||
ArServerHandlerCommands *myHandlerCommands;
|
|
||||||
|
|
||||||
bool packetHandler(ArRobotPacket *packet);
|
|
||||||
void userTask(void);
|
|
||||||
void log(void);
|
|
||||||
|
|
||||||
bool myFirst;
|
|
||||||
int myReceivedPackets;
|
|
||||||
int myMissedPackets;
|
|
||||||
int myMissedMotorPackets;
|
|
||||||
int myPacketsThisCycle;
|
|
||||||
int myCyclesSincePacket;
|
|
||||||
ArTime myPacketReceived;
|
|
||||||
ArTime myLastLog;
|
|
||||||
|
|
||||||
ArFunctorC<ArServerSimpleConnectionTester> myConnectionTestStartCB;
|
|
||||||
ArFunctorC<ArServerSimpleConnectionTester> myConnectionTestStopCB;
|
|
||||||
ArRetFunctor1C<bool, ArServerSimpleConnectionTester,
|
|
||||||
ArRobotPacket *> myPacketHandlerCB;
|
|
||||||
ArFunctorC<ArServerSimpleConnectionTester> myUserTaskCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,103 +0,0 @@
|
|||||||
#ifndef ARSERVERSIMPLEOPENER_H
|
|
||||||
#define ARSERVERSIMPLEOPENER_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
|
|
||||||
class ArServerBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Set up and open an ArNetworking server
|
|
||||||
|
|
||||||
Some program command line options affect behavior:
|
|
||||||
@verbinclude ArServerSimpleOpener_options
|
|
||||||
|
|
||||||
To set the
|
|
||||||
port the server uses use '-serverPort <i>serverPortNumber</i>' or
|
|
||||||
'-sp <i>serverPortNumber</i>'. To set the file to look in for user
|
|
||||||
information use '-userInfo <i>fileName</i>' or "-ui
|
|
||||||
<i>fileName</i>'. To log out the user information use
|
|
||||||
'-logUserInfo' or 'lui'. To log out the command groups use
|
|
||||||
'-logCommandGroups' or '-lcg'. To set the key used for the server
|
|
||||||
(that the client has to know to connect if using user and password)
|
|
||||||
use '-serverInfoFile <i>file</i>'. With a file that has in it
|
|
||||||
'serverKey <i>serverKey</i>'. You should obviously make sure no one you
|
|
||||||
don't want to know that server key can read your file that it is
|
|
||||||
in.
|
|
||||||
|
|
||||||
For more details about all of these options see ArServerBase.
|
|
||||||
|
|
||||||
@sa ArServerBase
|
|
||||||
**/
|
|
||||||
class ArServerSimpleOpener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerSimpleOpener(ArArgumentParser *parser,
|
|
||||||
const char *prefix = "",
|
|
||||||
bool addAriaCallbacks = true);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT ~ArServerSimpleOpener();
|
|
||||||
/// Function to open up the server
|
|
||||||
AREXPORT bool open(ArServerBase *server, const char *baseDirectory = "",
|
|
||||||
int secondsToTryFor = 240);
|
|
||||||
/// Function to parse the arguments given in the constructor
|
|
||||||
AREXPORT bool parseArgs(void);
|
|
||||||
/// Function to parse the arguments given in an arbitrary parser
|
|
||||||
AREXPORT bool parseArgs(ArArgumentParser *parser);
|
|
||||||
/// Log the options the simple connector has
|
|
||||||
AREXPORT void logOptions(void) const;
|
|
||||||
/// Logs the things requested for logging, may check things later
|
|
||||||
AREXPORT bool checkAndLog(void) const;
|
|
||||||
/// Returns true if the open failed because of a bad user file
|
|
||||||
bool wasUserFileBad(void) { return myBadUserFile; }
|
|
||||||
/// Returns true if the open failed because it couldn't open
|
|
||||||
bool didOpenFail(void) { return myOpenFailed; }
|
|
||||||
/** Get the server's port number
|
|
||||||
* @return the server's port number
|
|
||||||
*/
|
|
||||||
int getPort() { return myServerPort; }
|
|
||||||
|
|
||||||
/** Set default server port number (normally 7272). This must be called before
|
|
||||||
* parsing command line arguments.
|
|
||||||
* @since 2.7.6
|
|
||||||
*/
|
|
||||||
void setDefaultPort(int port) { myServerPort = port; }
|
|
||||||
|
|
||||||
/// Parses the file for holding the server key
|
|
||||||
AREXPORT bool parseFile(const char *fileName);
|
|
||||||
/// Sets the tcpOnly flag
|
|
||||||
void setServerTcpOnly(bool serverTcpOnly) { myTcpOnly = serverTcpOnly; }
|
|
||||||
protected:
|
|
||||||
AREXPORT bool parseArgsWithOutPrefix(ArArgumentParser *parser);
|
|
||||||
AREXPORT bool parseArgsWithPrefix(ArArgumentParser *parser);
|
|
||||||
AREXPORT void logOptionsWithOutPrefix(void) const;
|
|
||||||
AREXPORT void logOptionsWithPrefix(void) const;
|
|
||||||
|
|
||||||
bool fileServerKeyCallback(ArArgumentBuilder *arg);
|
|
||||||
|
|
||||||
void reset(void);
|
|
||||||
const char *myUserFile;
|
|
||||||
//const char *myServerKey;
|
|
||||||
std::string myServerKey;
|
|
||||||
int myServerPort;
|
|
||||||
const char *myOpenOnIP;
|
|
||||||
ArServerBase *myServer;
|
|
||||||
bool myLogUserInfo;
|
|
||||||
bool myLogCommandGroups;
|
|
||||||
bool myTcpOnly;
|
|
||||||
bool myBadUserFile;
|
|
||||||
bool myOpenFailed;
|
|
||||||
// our parser
|
|
||||||
ArArgumentParser *myParser;
|
|
||||||
bool myOwnParser;
|
|
||||||
std::string myPrefix;
|
|
||||||
|
|
||||||
// file parser for the server key file
|
|
||||||
ArFileParser myFileParser;
|
|
||||||
ArRetFunctorC<bool, ArServerSimpleOpener> myParseArgsCB;
|
|
||||||
ArConstFunctorC<ArServerSimpleOpener> myLogOptionsCB;
|
|
||||||
ArRetFunctor1C<bool, ArServerSimpleOpener,
|
|
||||||
ArArgumentBuilder *> myFileServerKeyCB;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARSERVERSIMPLEOPENER_H
|
|
@ -1,71 +0,0 @@
|
|||||||
#ifndef ARSERVERUSERINFO_H
|
|
||||||
#define ARSERVERUSERINFO_H
|
|
||||||
|
|
||||||
#include "Aria.h"
|
|
||||||
|
|
||||||
/// This class holds information about users and loads it from a file
|
|
||||||
/**
|
|
||||||
For a description of the algorithm used to match passwords and keys
|
|
||||||
and all look at the documentation for ArServerBase.
|
|
||||||
|
|
||||||
The file format for this class is set up to be easy to make a new
|
|
||||||
version of and yet read all the old versions.
|
|
||||||
|
|
||||||
For all of the versions everything after ; or # is ignored. The
|
|
||||||
version information is then the first line of non comments.
|
|
||||||
|
|
||||||
The first version is described as such: The version string is
|
|
||||||
'<code>UserInfoVersion1</code>'. Then there are lines that follow for each user
|
|
||||||
which are '<code>user</code> <i>userName password groups</i>'. The passwords are
|
|
||||||
plain text in the file, though they aren't sent that way over the
|
|
||||||
network (look at ArServerBase docs for details).
|
|
||||||
To display the groups available use ArServerBase::logCommandGroups().
|
|
||||||
|
|
||||||
There is an example user info file in ArNetworking/examples/serverDemo.userInfo
|
|
||||||
|
|
||||||
**/
|
|
||||||
class ArServerUserInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArServerUserInfo(const char *baseDirectory = NULL);
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT ~ArServerUserInfo();
|
|
||||||
/// Loads the file, returns false if it wasn't there
|
|
||||||
AREXPORT bool readFile(const char *fileName);
|
|
||||||
/// Sets the base directory
|
|
||||||
AREXPORT void setBaseDirectory(const char *baseDirectory);
|
|
||||||
/// Matchs a user and password, false if user or password is wrong
|
|
||||||
AREXPORT bool matchUserPassword(const char *user, unsigned char password[16],
|
|
||||||
const char *passwordKey,
|
|
||||||
const char *serverKey,
|
|
||||||
bool logFailureVerbosely = false) const;
|
|
||||||
AREXPORT bool doNotUse(void) const;
|
|
||||||
/// Gets the groups a user is in (returns empty set if no user)
|
|
||||||
AREXPORT std::set<std::string, ArStrCaseCmpOp> getUsersGroups(
|
|
||||||
const char *user) const;
|
|
||||||
/// Logs the users and groups
|
|
||||||
AREXPORT void logUsers(void) const;
|
|
||||||
protected:
|
|
||||||
bool v1HeaderCallback(ArArgumentBuilder * arg);
|
|
||||||
bool v1UserCallback(ArArgumentBuilder * arg);
|
|
||||||
bool v1DoNotUseCallback(ArArgumentBuilder * arg);
|
|
||||||
void removeHandlers(void);
|
|
||||||
void logDigest(unsigned char digest[16]) const;
|
|
||||||
|
|
||||||
ArMutex myDataMutex;
|
|
||||||
std::map<std::string, std::string, ArStrCaseCmpOp> myPasswords;
|
|
||||||
std::map<std::string, std::set<std::string, ArStrCaseCmpOp> *,
|
|
||||||
ArStrCaseCmpOp> myGroups;
|
|
||||||
ArRetFunctor1C<bool, ArServerUserInfo, ArArgumentBuilder *> myV1HeaderCB;
|
|
||||||
ArRetFunctor1C<bool, ArServerUserInfo, ArArgumentBuilder *> myV1UserCB;
|
|
||||||
ArRetFunctor1C<bool, ArServerUserInfo, ArArgumentBuilder *> myV1DoNotUseCB;
|
|
||||||
std::string myBaseDirectory;
|
|
||||||
ArFileParser myParser;
|
|
||||||
bool myGotHeader;
|
|
||||||
bool myDoNotUse;
|
|
||||||
bool myLogFailureVerbosely;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARSERVERUSERINFO_H
|
|
@ -1,75 +0,0 @@
|
|||||||
#ifndef ARTEMPDIRECTORYHELPER_H
|
|
||||||
#define ARTEMPDIRECTORYHELPER_H
|
|
||||||
|
|
||||||
#include "ariaTypedefs.h"
|
|
||||||
#include "ArFunctor.h"
|
|
||||||
|
|
||||||
/// Helper class that manages the transition of temporary files to the base directory.
|
|
||||||
class ArTempDirectoryHelper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Constructor
|
|
||||||
AREXPORT ArTempDirectoryHelper(const char *baseDirectory = "",
|
|
||||||
const char *tempDirectory = "");
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
AREXPORT virtual ~ArTempDirectoryHelper();
|
|
||||||
|
|
||||||
|
|
||||||
/// Returns the name of the directory for temporary files.
|
|
||||||
AREXPORT const char *getTempDirectory();
|
|
||||||
/// Returns the name of the target base directory.
|
|
||||||
AREXPORT const char *getBaseDirectory();
|
|
||||||
|
|
||||||
|
|
||||||
/// Creates a complete file path name for the specified file in the temporary directory.
|
|
||||||
AREXPORT std::string makeTempFilePathName(const char *fileName);
|
|
||||||
|
|
||||||
/// Creates a complete file path name for the specified file in the base directory.
|
|
||||||
AREXPORT std::string makeBaseFilePathName(const char *fileName);
|
|
||||||
|
|
||||||
|
|
||||||
/// Moves the specified file from the temporary directory to the base directory.
|
|
||||||
AREXPORT bool moveFileToBaseDirectory(const char *fileName);
|
|
||||||
|
|
||||||
/// Moves the specified files from the temporary directory to the base directory.
|
|
||||||
AREXPORT bool moveFilesToBaseDirectory
|
|
||||||
(const std::list<std::string> &fileNameList);
|
|
||||||
|
|
||||||
|
|
||||||
/// Adds a callback to be called before moving from temp dir to base dir
|
|
||||||
AREXPORT void addPreMoveCallback(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called before moving from temp dir to base dir
|
|
||||||
AREXPORT void remPreMoveCallback(ArFunctor *functor);
|
|
||||||
/// Adds a callback to be called after moving from temp dir to base dir
|
|
||||||
AREXPORT void addPostMoveCallback(ArFunctor *functor,
|
|
||||||
ArListPos::Pos position = ArListPos::LAST);
|
|
||||||
/// Removes a callback to be called after moving from temp dir to base dir
|
|
||||||
AREXPORT void remPostMoveCallback(ArFunctor *functor);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// Creates a complete file path name for the specified file and directory.
|
|
||||||
AREXPORT std::string makeFilePathName(const char *fileName,
|
|
||||||
const char *dirName);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/// Path name of the base directory
|
|
||||||
std::string myBaseDirectory;
|
|
||||||
/// Path name of the temporary directory
|
|
||||||
std::string myTempDirectory;
|
|
||||||
|
|
||||||
/// List of callbacks invoked before the files are moved
|
|
||||||
std::list<ArFunctor *> myPreMoveCallbacks;
|
|
||||||
/// List of callbacks invoked after the files are moved
|
|
||||||
std::list<ArFunctor *> myPostMoveCallbacks;
|
|
||||||
|
|
||||||
}; // end class ArTempDirectoryHelper
|
|
||||||
|
|
||||||
#endif // ARTEMPDIRECTORYHELPER_H
|
|
||||||
|
|
||||||
|
|
@ -1,104 +0,0 @@
|
|||||||
/*
|
|
||||||
This is the software we use for doing the md5 checksums, its from
|
|
||||||
http://sourceforge.net/project/showfiles.php?group_id=42360
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
|
|
||||||
L. Peter Deutsch
|
|
||||||
ghost@aladdin.com
|
|
||||||
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
Independent implementation of MD5 (RFC 1321).
|
|
||||||
|
|
||||||
This code implements the MD5 Algorithm defined in RFC 1321, whose
|
|
||||||
text is available at
|
|
||||||
http://www.ietf.org/rfc/rfc1321.txt
|
|
||||||
The code is derived from the text of the RFC, including the test suite
|
|
||||||
(section A.5) but excluding the rest of Appendix A. It does not include
|
|
||||||
any code or documentation that is identified in the RFC as being
|
|
||||||
copyrighted.
|
|
||||||
|
|
||||||
The original and principal author of md5.h is L. Peter Deutsch
|
|
||||||
<ghost@aladdin.com>. Other authors are noted in the change history
|
|
||||||
that follows (in reverse chronological order):
|
|
||||||
|
|
||||||
2002-04-13 lpd Removed support for non-ANSI compilers; removed
|
|
||||||
references to Ghostscript; clarified derivation from RFC 1321;
|
|
||||||
now handles byte order either statically or dynamically.
|
|
||||||
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
|
|
||||||
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
|
|
||||||
added conditionalization for C++ compilation from Martin
|
|
||||||
Purschke <purschke@bnl.gov>.
|
|
||||||
1999-05-03 lpd Original version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef md5_INCLUDED
|
|
||||||
# define md5_INCLUDED
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This package supports both compile-time and run-time determination of CPU
|
|
||||||
* byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
|
|
||||||
* compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
|
|
||||||
* defined as non-zero, the code will be compiled to run only on big-endian
|
|
||||||
* CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
|
|
||||||
* run on either big- or little-endian CPUs, but will run slightly less
|
|
||||||
* efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef unsigned char md5_byte_t; /* 8-bit byte */
|
|
||||||
typedef unsigned int md5_word_t; /* 32-bit word */
|
|
||||||
|
|
||||||
/* Define the state of the MD5 Algorithm. */
|
|
||||||
typedef struct md5_state_s {
|
|
||||||
md5_word_t count[2]; /* message length in bits, lsw first */
|
|
||||||
md5_word_t abcd[4]; /* digest buffer */
|
|
||||||
md5_byte_t buf[64]; /* accumulate block */
|
|
||||||
} md5_state_t;
|
|
||||||
|
|
||||||
// MPL (ActivMedia) taking out the extern since its only being used in c++
|
|
||||||
/*
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
// RH (ActivMedia/MobileRobots) Added "AREXPORT" symbol to all public functions. On Windows, this must be defined
|
|
||||||
// to either import or export the symbols to/from DLLs. On other platforms, it should be defined to be nothing.
|
|
||||||
|
|
||||||
/* Initialize the algorithm. */
|
|
||||||
AREXPORT void md5_init(md5_state_t *pms);
|
|
||||||
|
|
||||||
/* Append a string to the message. */
|
|
||||||
AREXPORT void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
|
|
||||||
|
|
||||||
/* Finish the message and return the digest. */
|
|
||||||
AREXPORT void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
|
|
||||||
|
|
||||||
/// MPL (ActivMedia) taking out the extern since its only being used in c++
|
|
||||||
/*
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} // end extern "C"
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* md5_INCLUDED */
|
|
@ -1,268 +0,0 @@
|
|||||||
/* SWIG Wrapper for ArNetworking */
|
|
||||||
|
|
||||||
#ifdef SWIGPYTHON
|
|
||||||
%module(docstring="Python wrapper library for ArNetworking", directors="1") ArNetworkingPy
|
|
||||||
#else
|
|
||||||
# ifdef SWIGJAVA
|
|
||||||
%module(docstring="Java wrapper library for ArNetworking", directors="1") ArNetworkingJava
|
|
||||||
# else
|
|
||||||
%module(docstring="Wrapper library for ArNetworking", directors="1") ArNetworking
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SWIGIMPORTED
|
|
||||||
#warning Imported ArNetworking wrapper
|
|
||||||
#endif
|
|
||||||
|
|
||||||
%feature("autodoc", "1");
|
|
||||||
/*
|
|
||||||
%feature("directors", "1");*/ /* Enable on all classes. */
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include <cstddef>
|
|
||||||
#include "Aria.h"
|
|
||||||
#include "ArNetworking.h"
|
|
||||||
#include "../include/wrapper_ExtraClasses.h"
|
|
||||||
%}
|
|
||||||
%warnfilter(451) ArUtil;
|
|
||||||
|
|
||||||
|
|
||||||
/* Import all of Aria's wrapper classes */
|
|
||||||
#ifndef SWIG_IMPORTED_ARIA
|
|
||||||
#warning ArNetworking importing ARIA wrapper configuration...
|
|
||||||
%import ../include/wrapper.i
|
|
||||||
#define SWIG_IMPORTED_ARIA 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* In Java, we need to import the Aria package's namespace */
|
|
||||||
%typemap(javaimports) SWIGTYPE %{import com.mobilerobots.Aria.*;%}
|
|
||||||
%pragma(java) jniclassimports=%{import com.mobilerobots.Aria.*; %}
|
|
||||||
%pragma(java) moduleimports=%{import com.mobilerobots.Aria.*; %}
|
|
||||||
|
|
||||||
|
|
||||||
/* In Java, we need to override how SWIG defines some methods in the wrappers,
|
|
||||||
* to be public not protected (the defaut javabody typemap is defined in
|
|
||||||
* java.swg) so that other packages such as ArNetworking and ARNL can access them:
|
|
||||||
*/
|
|
||||||
%typemap(javabody) SWIGTYPE %{
|
|
||||||
private long swigCPtr;
|
|
||||||
protected boolean swigCMemOwn;
|
|
||||||
|
|
||||||
/* for internal use by swig only */
|
|
||||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
|
||||||
swigCMemOwn = cMemoryOwn;
|
|
||||||
swigCPtr = cPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* for internal use by swig only */
|
|
||||||
public static long getCPtr($javaclassname obj) {
|
|
||||||
return (obj == null) ? 0 : obj.swigCPtr;
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
|
|
||||||
%typemap(javabody_derived) SWIGTYPE %{
|
|
||||||
private long swigCPtr;
|
|
||||||
|
|
||||||
/* for internal use by swig only */
|
|
||||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
|
||||||
super($imclassname.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn);
|
|
||||||
swigCPtr = cPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* for internal use by swig only */
|
|
||||||
public static long getCPtr($javaclassname obj) {
|
|
||||||
return (obj == null) ? 0 : obj.swigCPtr;
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
|
|
||||||
|
|
||||||
%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
|
|
||||||
private long swigCPtr;
|
|
||||||
|
|
||||||
/* for internal use by swig only */
|
|
||||||
public $javaclassname(long cPtr, boolean bFutureUse) {
|
|
||||||
swigCPtr = cPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected $javaclassname() {
|
|
||||||
swigCPtr = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* for internal use by swig only */
|
|
||||||
public static long getCPtr($javaclassname obj) {
|
|
||||||
return (obj == null) ? 0 : obj.swigCPtr;
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* In Python, use typemaps to convert functions to functors: */
|
|
||||||
#ifdef SWIGPYTHON
|
|
||||||
%{
|
|
||||||
#include "../include/wrapper_Functors.h"
|
|
||||||
|
|
||||||
class ArPyFunctor_ServerData :
|
|
||||||
public ArFunctor2<ArServerClient*, ArNetPacket*>
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
PyObject *pyFunction;
|
|
||||||
public:
|
|
||||||
ArPyFunctor_ServerData(PyObject* _f) :
|
|
||||||
pyFunction(_f),
|
|
||||||
ArFunctor2<ArServerClient*, ArNetPacket*>()
|
|
||||||
{
|
|
||||||
Py_INCREF(pyFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
~ArPyFunctor_ServerData() {
|
|
||||||
Py_DECREF(pyFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void invoke() {
|
|
||||||
Py_FatalError("ArPyFunctor_ServerData (for <ArServerClient*, ArNetPacket*>) invoked with no arguments!");
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void invoke(ArServerClient *cli) {
|
|
||||||
Py_FatalError("ArPyFunctor_ServerData must be invoked with exactly 2 arguments (ArServerClient*, ArNetPacket*), 1 given.");
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void invoke(ArServerClient *cli, ArNetPacket *pkt)
|
|
||||||
{
|
|
||||||
PyObject *args = PyTuple_New(2);
|
|
||||||
PyObject *cliObj = SWIG_Python_NewPointerObj(cli, SWIGTYPE_p_ArServerClient, 0);
|
|
||||||
PyObject *pktObj = SWIG_Python_NewPointerObj(pkt, SWIGTYPE_p_ArNetPacket, 0);
|
|
||||||
PyTuple_SetItem(args, 0, cliObj);
|
|
||||||
PyTuple_SetItem(args, 1, pktObj);
|
|
||||||
PyObject *r = PyObject_CallObject(pyFunction, args);
|
|
||||||
if(!r)
|
|
||||||
{
|
|
||||||
fputs("** ArPyFunctor_ServerData: Error calling Python function: ", stderr);
|
|
||||||
PyErr_Print();
|
|
||||||
}
|
|
||||||
Py_DECREF(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual const char* getName() {
|
|
||||||
return (const char*) PyString_AsString(PyObject_Str(pyFunction));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ArPyFunctor_NetPacket:
|
|
||||||
public ArFunctor1<ArNetPacket*>,
|
|
||||||
ArPyFunctor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ArPyFunctor_NetPacket(PyObject* f) : ArFunctor1<ArNetPacket*>(), ArPyFunctor(f)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void invoke()
|
|
||||||
{
|
|
||||||
Py_FatalError("ArPyFonctor_NetPacket (for <ArNetPacket*>) invoked with no arguments!");
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void invoke(ArNetPacket* pkt)
|
|
||||||
{
|
|
||||||
PyObject *args = PyTuple_New(1);
|
|
||||||
PyObject *pktObj = SWIG_Python_NewPointerObj(pkt, SWIGTYPE_p_ArNetPacket, 0);
|
|
||||||
PyTuple_SetItem(args, 0, pktObj);
|
|
||||||
PyObject *r = PyObject_CallObject(pyFunction, args);
|
|
||||||
if(!r)
|
|
||||||
{
|
|
||||||
fputs("** ArPyFunctor_NetPacket: Error calling python function: ", stderr);
|
|
||||||
PyErr_Print();
|
|
||||||
}
|
|
||||||
Py_DECREF(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual const char* getName() {
|
|
||||||
return ArPyFunctor::getName();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
%}
|
|
||||||
|
|
||||||
|
|
||||||
%typemap(in) ArFunctor2<ArServerClient*, ArNetPacket*>* {
|
|
||||||
$1 = new ArPyFunctor_ServerData($input); // XXX memory leak
|
|
||||||
}
|
|
||||||
|
|
||||||
%typecheck(SWIG_TYPECHECK_POINTER) ArFunctor2<ArServerClient*, ArNetPacket*>* {
|
|
||||||
$1 = PyCallable_Check($input);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(in) ArFunctor1<ArNetPacket*>* {
|
|
||||||
$1 = new ArPyFunctor_NetPacket($input); // XXX memory leak
|
|
||||||
}
|
|
||||||
|
|
||||||
%typecheck(SWIG_TYPECHECK_POINTER) ArFunctor1<ArNetPacket*>* {
|
|
||||||
$1 = PyCallable_Check($input);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif //SWIGPYTHON
|
|
||||||
|
|
||||||
/* But in Java, just name the functor templates and enable directors so you can subclass them: */
|
|
||||||
#ifdef SWIGJAVA
|
|
||||||
%feature("director") ArFunctor1<ArServerClient*>;
|
|
||||||
%feature("director") ArFunctor1<ArNetPacket*>;
|
|
||||||
%feature("director") ArFunctor2<ArServerClient*, ArNetPacket*>;
|
|
||||||
%template(ArFunctor_ServerClient) ArFunctor1<ArServerClient*>;
|
|
||||||
%template(ArFunctor_NetPacket) ArFunctor1<ArNetPacket*>;
|
|
||||||
%template(ArFunctor_ServerData) ArFunctor2<ArServerClient*, ArNetPacket*>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* include files */
|
|
||||||
/* Don't include md5.h */
|
|
||||||
|
|
||||||
/* base classes */
|
|
||||||
%include "ArNetPacket.h"
|
|
||||||
%include "ArServerBase.h"
|
|
||||||
%include "ArServerMode.h"
|
|
||||||
|
|
||||||
/* derived classes */
|
|
||||||
%include "ArClientArgUtils.h"
|
|
||||||
%include "ArClientBase.h"
|
|
||||||
%include "ArClientCommands.h"
|
|
||||||
%include "ArClientData.h"
|
|
||||||
%include "ArClientFileUtils.h"
|
|
||||||
%include "ArClientHandlerConfig.h"
|
|
||||||
%include "ArClientSimpleConnector.h"
|
|
||||||
%include "ArHybridForwarderVideo.h"
|
|
||||||
%include "ArNetPacketReceiverTcp.h"
|
|
||||||
%include "ArNetPacketReceiverUdp.h"
|
|
||||||
%include "ArNetPacketSenderTcp.h"
|
|
||||||
%include "ArServerClient.h"
|
|
||||||
%include "ArServerClientIdentifier.h"
|
|
||||||
%include "ArServerClientData.h"
|
|
||||||
%include "ArServerCommands.h"
|
|
||||||
%include "ArServerData.h"
|
|
||||||
#ifndef WIN32
|
|
||||||
%include "ArServerFileUtils.h"
|
|
||||||
#endif
|
|
||||||
%include "ArServerHandlerCamera.h"
|
|
||||||
%include "ArServerHandlerCameraCollection.h"
|
|
||||||
%include "ArServerHandlerCommMonitor.h"
|
|
||||||
%include "ArServerHandlerCommands.h"
|
|
||||||
%include "ArServerHandlerConfig.h"
|
|
||||||
%include "ArServerHandlerMap.h"
|
|
||||||
%include "ArServerHandlerMapping.h"
|
|
||||||
%include "ArServerInfoDrawings.h"
|
|
||||||
%include "ArServerInfoRobot.h"
|
|
||||||
%include "ArServerInfoSensor.h"
|
|
||||||
%include "ArServerInfoStrings.h"
|
|
||||||
%include "ArServerModeDrive.h"
|
|
||||||
%include "ArServerModeIdle.h"
|
|
||||||
%include "ArServerModeRatioDrive.h"
|
|
||||||
%include "ArServerModeStop.h"
|
|
||||||
%include "ArServerModeWander.h"
|
|
||||||
%include "ArServerSimpleCommands.h"
|
|
||||||
%include "ArServerSimpleOpener.h"
|
|
||||||
%include "ArServerUserInfo.h"
|
|
||||||
|
|
||||||
#include "../include/wrapper_ExtraClasses.h"
|
|
||||||
|
|
||||||
/* The End. */
|
|
@ -1,48 +0,0 @@
|
|||||||
|
|
||||||
ifdef JAVA_BIN
|
|
||||||
JAVAC=$(JAVA_BIN)/javac
|
|
||||||
JAVA=$(JAVA_BIN)/java
|
|
||||||
else
|
|
||||||
JAVAC=javac
|
|
||||||
JAVA=java
|
|
||||||
endif
|
|
||||||
|
|
||||||
#### Different options for Windows or Linux:
|
|
||||||
host:=$(shell uname | cut -d _ -f 1)
|
|
||||||
ifeq ($(host),MINGW32) # host is MINGW32 on Windows:
|
|
||||||
CLASSPATH_SEP=;
|
|
||||||
RUNTIME_PATH_VAR=PATH
|
|
||||||
RUNTIME_LIB_DIR=../../bin
|
|
||||||
LIB_EXT=dll
|
|
||||||
LIB_PREFIX=
|
|
||||||
else
|
|
||||||
CLASSPATH_SEP=:
|
|
||||||
RUNTIME_PATH_VAR=LD_LIBRARY_PATH
|
|
||||||
RUNTIME_LIB_DIR=../../lib
|
|
||||||
LIB_EXT=so
|
|
||||||
LIB_PREFIX=lib
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
all: $(patsubst %.java,%.class,$(wildcard *.java))
|
|
||||||
|
|
||||||
%.class: %.java ../../java/Aria.jar ../../java/ArNetworking.jar $(RUNTIME_LIB_DIR)/$(LIB_PREFIX)Aria.$(LIB_EXT) $(RUNTIME_LIB_DIR)/$(LIB_PREFIX)ArNetworking.$(LIB_EXT)
|
|
||||||
@echo $^
|
|
||||||
"$(JAVAC)" -classpath "../../java/Aria.jar$(CLASSPATH_SEP)../../java/ArNetworking.jar" $<
|
|
||||||
|
|
||||||
run%: %.class
|
|
||||||
$(RUNTIME_PATH_VAR)=$$$(RUNTIME_PATH_VAR):$(RUNTIME_LIB_DIR) "$(JAVA)" -cp ../../java/Aria.jar:../../java/ArNetworking.jar:. $* $(ARGS)
|
|
||||||
|
|
||||||
gdb%: %.class
|
|
||||||
$(RUNTIME_PATH_VAR)=$$$(RUNTIME_PATH_VAR):$(RUNTIME_LIB_DIR) gdb --args "$(JAVA)" -cp ../../java/Aria.jar:../../java/ArNetworking.jar:. $* $(ARGS)
|
|
||||||
|
|
||||||
info:
|
|
||||||
@echo host=$(host)
|
|
||||||
@echo "JAVA_BIN=$(JAVA_BIN)"
|
|
||||||
@echo "JAVAC=$(JAVAC)"
|
|
||||||
@echo "JAVA=$(JAVA)"
|
|
||||||
@echo "CLASSPATH_SEP=$(CLASSPATH_SEP)"
|
|
||||||
@echo "RUNTIME_PATH_VAR=$(RUNTIME_PATH_VAR)"
|
|
||||||
@echo "RUNTIME_LIB_DIR=$(RUNTIME_LIB_DIR)"
|
|
||||||
@echo "LIB_EXT=$(LIB_EXT)"
|
|
@ -1,71 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
USING THE JAVA WRAPPER FOR ARNETWORKING
|
|
||||||
|
|
||||||
"Wrapper" libraries for Java have been provided for both Aria and ArNetworking
|
|
||||||
in Aria's "java" directory ("../java"). This wrapper layer provides a Java API which simply
|
|
||||||
makes calls into the regular ArNetworking C++ implementation (using JNI).
|
|
||||||
|
|
||||||
To use the ArNetworking Java wrapper you need to download a Java SDK. Sun J2SE JDK
|
|
||||||
1.6 (Java SE6) was used to build the wrapper. You can download it from:
|
|
||||||
|
|
||||||
http://java.sun.com/javase/downloads
|
|
||||||
|
|
||||||
Find the Java SE Development Kit 6 and click "Download". (Only the JDK
|
|
||||||
is needed, ARIA does not need Java EE or any other extra Java technologies.)
|
|
||||||
|
|
||||||
The JDK also includes the runtime environment (JRE) that allows you to run
|
|
||||||
Java programs. If you only need the JRE, it can also
|
|
||||||
be obtained from <http://java.sun.com>.
|
|
||||||
|
|
||||||
Install it on your system, then you should put the bin
|
|
||||||
directory of the SDK into your PATH environment variable.
|
|
||||||
|
|
||||||
For information about Java on Debian GNU/Linux systems, install the
|
|
||||||
"java-common" package, and see the Debian Java FAQ in
|
|
||||||
/usr/share/doc/java-common/debian-java-faq/index.html
|
|
||||||
Chapter 11 describes how to install the Java 2 SDK from Blackdown using
|
|
||||||
Apt.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
In Windows you must then put the Aria\bin directory into your PATH enviornment
|
|
||||||
variable so that Java can find the dll needed to run the wrapper (use the System
|
|
||||||
control panel, or set in in the command shell prior to running java). On Linux,
|
|
||||||
Aria/lib should be in your LD_LIBRARY_PATH or in /etc/ld.so.conf.
|
|
||||||
|
|
||||||
For an example you should start the simulator, then go into
|
|
||||||
the javaExamples directory and compile the simple Java
|
|
||||||
example, and then run it.
|
|
||||||
|
|
||||||
On Windows:
|
|
||||||
javac -classpath ../../java/Aria.jar;../../java/ArNetworking.jar simple.java
|
|
||||||
java -cp ../../java/Aria.jar;../../java/ArNetworking.jar;. simple
|
|
||||||
|
|
||||||
On Linux:
|
|
||||||
javac -classpath ../../java/Aria.jar:../../java/ArNetworking.jar simple.java
|
|
||||||
java -cp ../../java/Aria.jar:../../java/ArNetworking.jar:. simple
|
|
||||||
|
|
||||||
The difference is the separator in the class path (; vs :).
|
|
||||||
|
|
||||||
The Java wrapper is not as well tested as ArNetworking itself. If you encounter
|
|
||||||
problems using it, please notify the aria-users mailing list.
|
|
||||||
|
|
||||||
|
|
||||||
REBUILDING THE JAVA WRAPPER
|
|
||||||
|
|
||||||
If you want to rebuild the Java wrapper you need to install SWIG:
|
|
||||||
See <http://www.swig.org/download.html> You should get at
|
|
||||||
least version 1.3.17. You then need to set the environment variable
|
|
||||||
JAVA_INCLUDE to the include directory in your Java SDK, and
|
|
||||||
JAVA_BIN to the bin directory in your Java SDK. (If you installed
|
|
||||||
the j2sdk1.4 from Blackdown on Debian, JAVA_INCLUDE should be
|
|
||||||
/usr/lib/j2se/1.4/include).
|
|
||||||
|
|
||||||
In Linux, set your path so that swig is in the path then run
|
|
||||||
'make java' in the Aria directory, then again in the ArNetworking directory.
|
|
||||||
|
|
||||||
In Windows with Visual Studio .NET, open java/ArNetworkingJava.vcproj, select
|
|
||||||
Tools menu -> Options -> Projects -> VC++ Directories and add your SWIG
|
|
||||||
directory. Then you should just be able to build the library.
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
|||||||
|
|
||||||
import com.mobilerobots.Aria.*;
|
|
||||||
import com.mobilerobots.ArNetworking.*;
|
|
||||||
|
|
||||||
class ResponseCallback extends ArFunctor_NetPacket
|
|
||||||
{
|
|
||||||
public void invoke(ArNetPacket packet)
|
|
||||||
{
|
|
||||||
System.out.println("customClientExample: ResponseCallback: Got a packet from the server with type " + packet.getCommand());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class customClientExample {
|
|
||||||
|
|
||||||
|
|
||||||
/* This loads all the ArNetworking classes (they will be in the global
|
|
||||||
* namespace) when this class is loaded: */
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
System.loadLibrary("AriaJava");
|
|
||||||
System.loadLibrary("ArNetworkingJava");
|
|
||||||
} catch (UnsatisfiedLinkError e) {
|
|
||||||
System.err.println("Native code libraries (AriaJava and ArNetworkingJava .so or .DLL) failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String argv[])
|
|
||||||
{
|
|
||||||
Aria.init();
|
|
||||||
|
|
||||||
ArClientBase client = new ArClientBase();
|
|
||||||
ResponseCallback testCB = new ResponseCallback();
|
|
||||||
|
|
||||||
ArTime startTime = new ArTime();
|
|
||||||
startTime.setToNow();
|
|
||||||
System.out.println("customClientExample: trying to connect to a server running on the local host at port 7273...");
|
|
||||||
if (!client.blockingConnect("localhost", 7273))
|
|
||||||
{
|
|
||||||
System.err.println("Error: Could not connect to server on localhost:7273, exiting.");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("customClientExample: Connected after " + startTime.mSecSince() + " msec.");
|
|
||||||
|
|
||||||
client.runAsync();
|
|
||||||
|
|
||||||
System.out.println("\ncustomClientExample: Adding data handler callbacks...");
|
|
||||||
client.addHandler("test", testCB);
|
|
||||||
client.addHandler("test2", testCB);
|
|
||||||
client.addHandler("test3", testCB);
|
|
||||||
client.logDataList();
|
|
||||||
|
|
||||||
System.out.println("\ncustomClientExample: Requesting \"test\" once...");
|
|
||||||
client.requestOnce("test");
|
|
||||||
|
|
||||||
System.out.println("\ncustomClientExample: Requesting \"test2\" with a frequency of 10ms...");
|
|
||||||
client.request("test2", 100);
|
|
||||||
|
|
||||||
System.out.println("\ncustomClientExample: Requesting \"test3\" with a frequency of -1 (updates may happen at any time the server sends them) and waiting 5 sec...");
|
|
||||||
client.request("test3", -1);
|
|
||||||
ArUtil.sleep(5000);
|
|
||||||
|
|
||||||
System.out.println("\ncustomClientExample: Changing request frequency of \"test2\" to 300ms and waiting 5 sec");
|
|
||||||
client.request("test2", 300);
|
|
||||||
ArUtil.sleep(5000);
|
|
||||||
|
|
||||||
System.out.println("\ncustomClientExample: Cancelling \"test2\" request.");
|
|
||||||
client.requestStop("test2");
|
|
||||||
|
|
||||||
System.out.println("\ncustomClientExample: waiting 10 seconds, then disconnecting...");
|
|
||||||
ArUtil.sleep(10000);
|
|
||||||
client.disconnect();
|
|
||||||
ArUtil.sleep(50);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
|
|
||||||
import com.mobilerobots.Aria.*;
|
|
||||||
import com.mobilerobots.ArNetworking.*;
|
|
||||||
|
|
||||||
class RequestCallback extends ArFunctor_ServerData
|
|
||||||
{
|
|
||||||
public void invoke(ArServerClient client, ArNetPacket packet)
|
|
||||||
{
|
|
||||||
ArNetPacket sending = new ArNetPacket();
|
|
||||||
System.out.println("customServerExample: RequestCallback: responding to a request packet with ID " + packet.getCommand());
|
|
||||||
client.sendPacketTcp(sending); // just send back an empty packet.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class customServerExample {
|
|
||||||
|
|
||||||
|
|
||||||
/* This loads all the ArNetworking classes (they will be in the global
|
|
||||||
* namespace) when this class is loaded: */
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
System.loadLibrary("AriaJava");
|
|
||||||
System.loadLibrary("ArNetworkingJava");
|
|
||||||
} catch (UnsatisfiedLinkError e) {
|
|
||||||
System.err.println("Native code libraries (AriaJava and ArNetworkingJava .so or .DLL) failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] argv)
|
|
||||||
{
|
|
||||||
Aria.init();
|
|
||||||
ArServerBase server = new ArServerBase();
|
|
||||||
ArNetPacket packet = new ArNetPacket(); // empty packet to test broadcasting
|
|
||||||
|
|
||||||
RequestCallback testCB = new RequestCallback();
|
|
||||||
|
|
||||||
server.addData("test", "some wierd test", testCB, "none", "none");
|
|
||||||
server.addData("test2", "another wierd test", testCB, "none", "none");
|
|
||||||
server.addData("test3", "yet another wierd test", testCB, "none", "none");
|
|
||||||
if (!server.open(7273))
|
|
||||||
{
|
|
||||||
System.err.println("customServerExample: Could not open server port 7273");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
server.runAsync();
|
|
||||||
System.out.println("customServerExample: ready for customClientExamples to connect on port 7273; will broadcast \"test3\" packet every 4 seconds as well.");
|
|
||||||
while (server.getRunningWithLock())
|
|
||||||
{
|
|
||||||
ArUtil.sleep(4000);
|
|
||||||
server.broadcastPacketTcp(packet, "test3");
|
|
||||||
}
|
|
||||||
Aria.shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
|||||||
|
|
||||||
import com.mobilerobots.Aria.*;
|
|
||||||
import com.mobilerobots.ArNetworking.*;
|
|
||||||
|
|
||||||
public class simple {
|
|
||||||
|
|
||||||
/* This loads all the ArNetworking classes (they will be in the global
|
|
||||||
* namespace) when this class is loaded: */
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
System.loadLibrary("AriaJava");
|
|
||||||
System.loadLibrary("ArNetworkingJava");
|
|
||||||
} catch (UnsatisfiedLinkError e) {
|
|
||||||
System.err.println("Native code libraries (AriaJava and ArNetworkingJava .so or .DLL) failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Main program: */
|
|
||||||
public static void main(String argv[]) {
|
|
||||||
System.out.println("Starting Java ArNetworking Test");
|
|
||||||
|
|
||||||
/* Global Aria class inititalizaton */
|
|
||||||
Aria.init(Aria.SigHandleMethod.SIGHANDLE_THREAD, true);
|
|
||||||
|
|
||||||
/* Robot and device objects */
|
|
||||||
ArRobot robot = new ArRobot("robot1", true, true, true);
|
|
||||||
ArSonarDevice sonar = new ArSonarDevice();
|
|
||||||
robot.addRangeDevice(sonar);
|
|
||||||
|
|
||||||
/* Make connector and parse arguments from argv */
|
|
||||||
ArSimpleConnector conn = new ArSimpleConnector(argv);
|
|
||||||
if(!Aria.parseArgs())
|
|
||||||
{
|
|
||||||
Aria.logOptions();
|
|
||||||
Aria.shutdown();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Connect to the robot */
|
|
||||||
System.out.println("Connecting to robot...");
|
|
||||||
if (!conn.connectRobot(robot))
|
|
||||||
{
|
|
||||||
System.err.println("Could not connect to robot, exiting.\n");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open the sever */
|
|
||||||
ArServerBase server = new ArServerBase();
|
|
||||||
if(!server.open(7272))
|
|
||||||
{
|
|
||||||
System.err.println("Could not open server on port 7272, exiting.");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
System.out.println("Opened server on port 7272.");
|
|
||||||
|
|
||||||
/* Informational services: */
|
|
||||||
ArServerInfoRobot servInfoRobot = new ArServerInfoRobot(server, robot);
|
|
||||||
ArServerInfoSensor servInfoSensor = new ArServerInfoSensor(server, robot);
|
|
||||||
ArServerInfoDrawings servInfoDraw = new ArServerInfoDrawings(server);
|
|
||||||
servInfoDraw.addRobotsRangeDevices(robot);
|
|
||||||
|
|
||||||
/* Control mode services: */
|
|
||||||
ArServerModeStop servModeStop = new ArServerModeStop(server, robot);
|
|
||||||
ArServerModeRatioDrive servModeDrive = new ArServerModeRatioDrive(server, robot);
|
|
||||||
ArServerModeWander servModeWander = new ArServerModeWander(server, robot);
|
|
||||||
servModeStop.addAsDefaultMode();
|
|
||||||
servModeStop.activate();
|
|
||||||
|
|
||||||
/* Simple text command service ("custom commands" in MobileEyes): */
|
|
||||||
ArServerHandlerCommands commands = new ArServerHandlerCommands(server);
|
|
||||||
|
|
||||||
// Relay microcontroller commands directly:
|
|
||||||
ArServerSimpleComUC cmdUC = new ArServerSimpleComUC(commands, robot);
|
|
||||||
|
|
||||||
// Log information:
|
|
||||||
ArServerSimpleComMovementLogging cmdLog = new ArServerSimpleComMovementLogging(commands, robot);
|
|
||||||
ArServerSimpleComLogRobotConfig cmdConfigLog = new ArServerSimpleComLogRobotConfig(commands, robot);
|
|
||||||
|
|
||||||
|
|
||||||
/* Run robot and server threads in the backrgound: */
|
|
||||||
System.out.println("Running...");
|
|
||||||
robot.enableMotors();
|
|
||||||
robot.runAsync(true);
|
|
||||||
server.runAsync();
|
|
||||||
robot.waitForRunExit();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
|
|
||||||
USING THE PYTHON WRAPPER FOR ARNETWORKING
|
|
||||||
|
|
||||||
A "wrapper" module for Python has been provided in ARIA's "python" directory.
|
|
||||||
This wrapper layer provides a Python API which simply makes calls into the
|
|
||||||
regular ArNetworking C++ implementation. In general, the Python API mirrors
|
|
||||||
the C++ API, with some exceptions which are noted in the Reference Manual
|
|
||||||
for the C++ library.
|
|
||||||
|
|
||||||
The ArNetworking wrapper should be used in conjunction with the ARIA wrapper.
|
|
||||||
See the README.txt for the ARIA pythonExamples for details.
|
|
||||||
|
|
||||||
To use the wrapper modules, you must add ARIA's python directory to
|
|
||||||
an environment variable called PYTHONPATH. On Windows, the Aria 'bin'
|
|
||||||
directory must also be in your PATH variable.
|
|
||||||
|
|
||||||
Note that the Python wrapper API is not as well tested as Aria itself. If
|
|
||||||
you encounter problems, please notify the aria-users mailing list. Furthermore,
|
|
||||||
some methods have been omitted or renamed, and you have to do a few things
|
|
||||||
differently.
|
|
||||||
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
|||||||
from AriaPy import *
|
|
||||||
from ArNetworkingPy import *
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def testCB(packet):
|
|
||||||
print "client: received reply packet with command %d\n" % (packet.getCommand())
|
|
||||||
|
|
||||||
Aria_init()
|
|
||||||
|
|
||||||
client = ArClientBase()
|
|
||||||
|
|
||||||
startTime = ArTime()
|
|
||||||
startTime.setToNow()
|
|
||||||
if not client.blockingConnect("localhost", 7273):
|
|
||||||
print "Could not connect to server at localhost port 7273, exiting"
|
|
||||||
Aria_exit(1);
|
|
||||||
print "client: Took %ld msec to connect\n" % (startTime.mSecSince())
|
|
||||||
|
|
||||||
client.runAsync()
|
|
||||||
|
|
||||||
client.lock()
|
|
||||||
|
|
||||||
print "Client detected the following data requests on the server:"
|
|
||||||
client.logDataList()
|
|
||||||
|
|
||||||
print "Adding callback for data requests \"test\", \"test2\", \"test3\"..."
|
|
||||||
client.addHandler("test", testCB)
|
|
||||||
client.addHandler("test2", testCB)
|
|
||||||
client.addHandler("test3", testCB)
|
|
||||||
|
|
||||||
|
|
||||||
print "Requesting \"test\" once..."
|
|
||||||
client.requestOnce("test")
|
|
||||||
|
|
||||||
print "Requesting \"test2\" every 100ms..."
|
|
||||||
client.request("test2", 100)
|
|
||||||
|
|
||||||
print "Requesting \"test3\" to be sent at server's discrecion..."
|
|
||||||
client.request("test3", -1)
|
|
||||||
client.unlock()
|
|
||||||
|
|
||||||
print "Waiting 2 sec..."
|
|
||||||
ArUtil_sleep(2000)
|
|
||||||
|
|
||||||
print "Changing request frequency of \"test2\" to 300ms..."
|
|
||||||
client.lock()
|
|
||||||
client.request("test2", 300)
|
|
||||||
client.unlock()
|
|
||||||
|
|
||||||
print "Watiing 2 sec..."
|
|
||||||
ArUtil_sleep(1000)
|
|
||||||
|
|
||||||
print "Stopping request for \"test2\"..."
|
|
||||||
client.lock()
|
|
||||||
client.requestStop("test2")
|
|
||||||
client.unlock()
|
|
||||||
|
|
||||||
print "Waiting 2 sec..."
|
|
||||||
ArUtil_sleep(2000)
|
|
||||||
|
|
||||||
print "Disconnecting and exiting."
|
|
||||||
client.lock()
|
|
||||||
client.disconnect()
|
|
||||||
client.unlock()
|
|
||||||
ArUtil_sleep(50)
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
|||||||
from AriaPy import *
|
|
||||||
from ArNetworkingPy import *
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def requestCallback(client, packet):
|
|
||||||
replyPacket = ArNetPacket()
|
|
||||||
replyPacket.strToBuf("Reply");
|
|
||||||
print "requestCallback received a packet with command #%d. Sending a reply...\n" % (packet.getCommand())
|
|
||||||
client.sendPacketTcp(replyPacket)
|
|
||||||
|
|
||||||
Aria_init()
|
|
||||||
server = ArServerBase()
|
|
||||||
packet = ArNetPacket()
|
|
||||||
|
|
||||||
server.addData("test", "some wierd test", requestCallback, "none", "none")
|
|
||||||
server.addData("test2", "another wierd test", requestCallback, "none", "none")
|
|
||||||
server.addData("test3", "yet another wierd test", requestCallback, "none", "none")
|
|
||||||
if not server.open(7273):
|
|
||||||
print "Error: Could not open server port 7273"
|
|
||||||
Aria_exit(1)
|
|
||||||
print "Opened server on port 7273. Connect with customClientExample."
|
|
||||||
server.runAsync()
|
|
||||||
while (server.getRunningWithLock()):
|
|
||||||
ArUtil_sleep(1000)
|
|
||||||
server.broadcastPacketTcp(packet, "test3")
|
|
||||||
Aria_exit(0)
|
|
||||||
|
|
@ -1,204 +0,0 @@
|
|||||||
from AriaPy import *
|
|
||||||
from ArNetworkingPy import *
|
|
||||||
import sys
|
|
||||||
from math import sin
|
|
||||||
|
|
||||||
|
|
||||||
# This is an example server that shows how to draw arbitrary figures in a
|
|
||||||
# client (e.g. MobileEyes).
|
|
||||||
|
|
||||||
|
|
||||||
# These are callbacks that respond to client requests for the drawings'
|
|
||||||
# geometry data.
|
|
||||||
|
|
||||||
|
|
||||||
def exampleHomeDrawingNetCallback(client, requestPkt):
|
|
||||||
print "exampleHomeDrawingNetCallback"
|
|
||||||
|
|
||||||
reply = ArNetPacket()
|
|
||||||
|
|
||||||
# 7 Vertices
|
|
||||||
reply.byte4ToBuf(7)
|
|
||||||
|
|
||||||
# Centered on 0,0.
|
|
||||||
# X: Y:
|
|
||||||
reply.byte4ToBuf(-500); reply.byte4ToBuf(500); # Vertex 1
|
|
||||||
reply.byte4ToBuf(-500); reply.byte4ToBuf(-500); # Vertex 2
|
|
||||||
reply.byte4ToBuf(500); reply.byte4ToBuf(-500); # Vertex 3
|
|
||||||
reply.byte4ToBuf(500); reply.byte4ToBuf(500); # Vertex 4
|
|
||||||
reply.byte4ToBuf(0); reply.byte4ToBuf(1000); # Vertex 5
|
|
||||||
reply.byte4ToBuf(-500); reply.byte4ToBuf(500); # Vertex 6
|
|
||||||
reply.byte4ToBuf(500); reply.byte4ToBuf(500); # Vertex 7
|
|
||||||
|
|
||||||
client.sendPacketUdp(reply)
|
|
||||||
print "exampleHomeDrawingNetCallback Done."
|
|
||||||
|
|
||||||
def exampleDotsDrawingNetCallback(client, requestPkt):
|
|
||||||
reply = ArNetPacket()
|
|
||||||
|
|
||||||
tik = ArUtil_getTime() % 200
|
|
||||||
t = tik / 5.0
|
|
||||||
|
|
||||||
# Three dots
|
|
||||||
reply.byte4ToBuf(3)
|
|
||||||
|
|
||||||
# Dot 1:
|
|
||||||
reply.byte4ToBuf(3000); # X coordinate (mm)
|
|
||||||
reply.byte4ToBuf((int) (sin(t) * 1000));# Y
|
|
||||||
|
|
||||||
# Dot 2:
|
|
||||||
reply.byte4ToBuf(3500); # X
|
|
||||||
reply.byte4ToBuf((int) (sin(t+500) * 1000));# Y
|
|
||||||
|
|
||||||
# Dot 3:
|
|
||||||
reply.byte4ToBuf(4000); # X
|
|
||||||
reply.byte4ToBuf((int) (sin(t+1000) * 1000));# Y
|
|
||||||
|
|
||||||
client.sendPacketUdp(reply)
|
|
||||||
|
|
||||||
def exampleXDrawingNetCallback(client, requestPkt):
|
|
||||||
reply = ArNetPacket()
|
|
||||||
|
|
||||||
# X marks the spot. 2 line segments, so 4 vertices:
|
|
||||||
reply.byte4ToBuf(4)
|
|
||||||
|
|
||||||
# Segment 1:
|
|
||||||
reply.byte4ToBuf(-4250); # X1
|
|
||||||
reply.byte4ToBuf(250); # Y1
|
|
||||||
reply.byte4ToBuf(-3750); # X2
|
|
||||||
reply.byte4ToBuf(-250); # Y2
|
|
||||||
|
|
||||||
# Segment 2:
|
|
||||||
reply.byte4ToBuf(-4250); # X1
|
|
||||||
reply.byte4ToBuf(-250); # Y1
|
|
||||||
reply.byte4ToBuf(-3750); # X2
|
|
||||||
reply.byte4ToBuf(250); # Y2
|
|
||||||
|
|
||||||
client.sendPacketUdp(reply)
|
|
||||||
|
|
||||||
def exampleArrowsDrawingNetCallback(client, requestPkt):
|
|
||||||
# 1 arrow that points at the robot
|
|
||||||
reply = ArNetPacket()
|
|
||||||
reply.byte4ToBuf(1) # 1 arrow
|
|
||||||
reply.byte4ToBuf(0); # Pos. X
|
|
||||||
reply.byte4ToBuf(700); # Pos. Y
|
|
||||||
client.sendPacketUdp(reply)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Main program:
|
|
||||||
|
|
||||||
Aria_init()
|
|
||||||
robot = ArRobot()
|
|
||||||
server = ArServerBase()
|
|
||||||
|
|
||||||
parser = ArArgumentParser(sys.argv)
|
|
||||||
simpleConnector = ArSimpleConnector(parser)
|
|
||||||
simpleOpener = ArServerSimpleOpener(parser)
|
|
||||||
|
|
||||||
parser.loadDefaultArguments()
|
|
||||||
|
|
||||||
if not Aria_parseArgs() or not parser.checkHelpAndWarnUnparsed():
|
|
||||||
Aria_logOptions()
|
|
||||||
Aria_exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
if not simpleOpener.open(server):
|
|
||||||
if simpleOpener.wasUserFileBad():
|
|
||||||
print "Error: Bad user/password/permissions file."
|
|
||||||
else:
|
|
||||||
print "Error: Could not open server port. Use -help to see options."
|
|
||||||
Aria_exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
# Devices
|
|
||||||
sonarDev = ArSonarDevice()
|
|
||||||
robot.addRangeDevice(sonarDev)
|
|
||||||
|
|
||||||
irs = ArIRs()
|
|
||||||
robot.addRangeDevice(irs)
|
|
||||||
|
|
||||||
bumpers = ArBumpers()
|
|
||||||
robot.addRangeDevice(bumpers)
|
|
||||||
|
|
||||||
sick = ArSick()
|
|
||||||
robot.addRangeDevice(sick);
|
|
||||||
|
|
||||||
|
|
||||||
# attach services to the server
|
|
||||||
serverInfoRobot = ArServerInfoRobot(server, robot)
|
|
||||||
serverInfoSensor = ArServerInfoSensor(server, robot)
|
|
||||||
|
|
||||||
# This is the service that provides drawing data to the client.
|
|
||||||
drawings = ArServerInfoDrawings(server)
|
|
||||||
|
|
||||||
# Convenience function that sets up drawings for all the robot's current
|
|
||||||
# range devices (using default shape and color info)
|
|
||||||
drawings.addRobotsRangeDevices(robot)
|
|
||||||
|
|
||||||
# Add our custom drawings
|
|
||||||
|
|
||||||
linedd = ArDrawingData("polyLine", ArColor(255, 0, 0), 2, 49) # shape name, color, size, layer
|
|
||||||
drawings.addDrawing( linedd, "exampleDrawing_Home", exampleHomeDrawingNetCallback)
|
|
||||||
|
|
||||||
dotsdd = ArDrawingData("polyDots", ArColor(0, 255, 0), 250, 48)
|
|
||||||
drawings.addDrawing(dotsdd, "exampleDrawing_Dots", exampleDotsDrawingNetCallback)
|
|
||||||
|
|
||||||
segdd = ArDrawingData("polySegments", ArColor(0, 0, 0), 4, 52)
|
|
||||||
drawings.addDrawing( segdd, "exampleDrawing_XMarksTheSpot", exampleXDrawingNetCallback)
|
|
||||||
|
|
||||||
ardd = ArDrawingData("polyArrows", ArColor(255, 0, 255), 500, 100)
|
|
||||||
drawings.addDrawing( ardd, "exampleDrawing_Arrows", exampleArrowsDrawingNetCallback)
|
|
||||||
|
|
||||||
# modes for moving the robot
|
|
||||||
modeStop = ArServerModeStop(server, robot)
|
|
||||||
modeDrive = ArServerModeDrive(server, robot)
|
|
||||||
modeRatioDrive = ArServerModeRatioDrive(server, robot)
|
|
||||||
modeWander = ArServerModeWander(server, robot)
|
|
||||||
modeStop.addAsDefaultMode()
|
|
||||||
modeStop.activate()
|
|
||||||
|
|
||||||
# set up some simple commands ("custom commands")
|
|
||||||
commands = ArServerHandlerCommands(server)
|
|
||||||
uCCommands = ArServerSimpleComUC(commands, robot)
|
|
||||||
loggingCommands = ArServerSimpleComMovementLogging(commands, robot)
|
|
||||||
configCommands = ArServerSimpleComLogRobotConfig(commands, robot)
|
|
||||||
|
|
||||||
# add the commands to enable and disable safe driving to the simple commands
|
|
||||||
modeDrive.addControlCommands(commands)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Connect to the robot.
|
|
||||||
if not simpleConnector.connectRobot(robot):
|
|
||||||
print "Error: Could not connect to robot... exiting"
|
|
||||||
Aria_exit(1)
|
|
||||||
|
|
||||||
# set up the laser before handing it to the laser mode
|
|
||||||
simpleConnector.setupLaser(sick)
|
|
||||||
|
|
||||||
robot.enableMotors()
|
|
||||||
|
|
||||||
# start the robot cycle running in a background thread
|
|
||||||
robot.runAsync(True)
|
|
||||||
|
|
||||||
# start the laser processing cycle in a background thread
|
|
||||||
sick.runAsync()
|
|
||||||
|
|
||||||
# connect the laser if it was requested
|
|
||||||
if not simpleConnector.connectLaser(sick):
|
|
||||||
print "Error: Could not connect to laser... exiting"
|
|
||||||
Aria_exit(2)
|
|
||||||
|
|
||||||
# log whatever we wanted to before the runAsync
|
|
||||||
simpleOpener.checkAndLog()
|
|
||||||
|
|
||||||
# run the server thread in the background
|
|
||||||
server.runAsync()
|
|
||||||
|
|
||||||
print "Server is now running on port %d..." % (simpleOpener.getPort())
|
|
||||||
|
|
||||||
robot.waitForRunExit()
|
|
||||||
Aria_exit(0)
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
|||||||
from AriaPy import *
|
|
||||||
from ArNetworkingPy import *
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# This example demonstrates how to use ArNetworking in Python.
|
|
||||||
|
|
||||||
# Global library initialization, just like the C++ API:
|
|
||||||
Aria_init()
|
|
||||||
|
|
||||||
# Create a robot object:
|
|
||||||
robot = ArRobot()
|
|
||||||
|
|
||||||
# make a gyro
|
|
||||||
gyro = ArAnalogGyro(robot)
|
|
||||||
|
|
||||||
#sonar, must be added to the robot
|
|
||||||
sonarDev = ArSonarDevice()
|
|
||||||
#add the sonar to the robot
|
|
||||||
robot.addRangeDevice(sonarDev)
|
|
||||||
|
|
||||||
# make the core server object:
|
|
||||||
server = ArServerBase()
|
|
||||||
|
|
||||||
# Create a "simple connector" object and connect to either the simulator
|
|
||||||
# or the robot. Unlike the C++ API which takes int and char* pointers,
|
|
||||||
# the Python constructor just takes argv as a list.
|
|
||||||
print "Connecting..."
|
|
||||||
|
|
||||||
con = ArSimpleConnector(sys.argv)
|
|
||||||
if (not con.connectRobot(robot)):
|
|
||||||
print "Could not connect to robot, exiting"
|
|
||||||
Aria_exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
# Open the server on port 7272:
|
|
||||||
if (not server.open(7272)):
|
|
||||||
print "Could not open server, exiting"
|
|
||||||
Aria_exit(1)
|
|
||||||
|
|
||||||
# Create various services and attach them to the core server
|
|
||||||
serverInfoRobot = ArServerInfoRobot(server, robot)
|
|
||||||
serverInfoSensor = ArServerInfoSensor(server, robot)
|
|
||||||
drawings = ArServerInfoDrawings(server)
|
|
||||||
drawings.addRobotsRangeDevices(robot)
|
|
||||||
|
|
||||||
# ways of moving the robot
|
|
||||||
modeStop = ArServerModeStop(server, robot)
|
|
||||||
modeRatioDrive = ArServerModeRatioDrive(server, robot)
|
|
||||||
modeWander = ArServerModeWander(server, robot)
|
|
||||||
modeStop.addAsDefaultMode()
|
|
||||||
modeStop.activate()
|
|
||||||
|
|
||||||
# set up the simple commands ("custom commands" in MobileEyes)
|
|
||||||
commands = ArServerHandlerCommands(server)
|
|
||||||
# add the simple commands for the microcontroller
|
|
||||||
uCCommands = ArServerSimpleComUC(commands, robot)
|
|
||||||
# add the simple commands for logging
|
|
||||||
loggingCommands = ArServerSimpleComMovementLogging(commands, robot)
|
|
||||||
# add the simple commands for the gyro
|
|
||||||
gyroCommands = ArServerSimpleComGyro(commands, robot, gyro)
|
|
||||||
# Add the simple command for logging the robot config and orig robot config
|
|
||||||
configCommands = ArServerSimpleComLogRobotConfig(commands, robot)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Run the robot and server threads in the background:
|
|
||||||
print "Running..."
|
|
||||||
robot.runAsync(1)
|
|
||||||
|
|
||||||
server.runAsync()
|
|
||||||
|
|
||||||
robot.enableMotors()
|
|
||||||
|
|
||||||
robot.waitForRunExit()
|
|
||||||
|
|
||||||
Aria_exit(0)
|
|
@ -1,923 +0,0 @@
|
|||||||
#include "Aria.h"
|
|
||||||
#include "ArExport.h"
|
|
||||||
#include "ArCentralForwarder.h"
|
|
||||||
|
|
||||||
|
|
||||||
AREXPORT ArCentralForwarder::ArCentralForwarder(
|
|
||||||
ArServerBase *mainServer, ArSocket *socket,
|
|
||||||
const char *robotName, int port,
|
|
||||||
std::map<int, ArTime *> *usedPorts,
|
|
||||||
ArFunctor2<ArCentralForwarder *,
|
|
||||||
ArServerClient *> *forwarderServerClientRemovedCB,
|
|
||||||
const char *enforceProtocolVersion,
|
|
||||||
ArServerCommands::Type enforceType) :
|
|
||||||
myReceiveDataFunctor(this, &ArCentralForwarder::receiveData),
|
|
||||||
myInternalRequestChangedFunctor(this,
|
|
||||||
&ArCentralForwarder::internalRequestChanged),
|
|
||||||
myInternalRequestOnceFunctor(this,
|
|
||||||
&ArCentralForwarder::internalRequestOnce,
|
|
||||||
NULL, NULL, true),
|
|
||||||
myRobotServerClientRemovedCB(
|
|
||||||
this, &ArCentralForwarder::robotServerClientRemoved),
|
|
||||||
myNetCentralHeartbeatCB(this, &ArCentralForwarder::netCentralHeartbeat),
|
|
||||||
myClientServerClientRemovedCB(
|
|
||||||
this, &ArCentralForwarder::clientServerClientRemoved)
|
|
||||||
{
|
|
||||||
myMainServer = mainServer;
|
|
||||||
mySocket = socket;
|
|
||||||
myRobotName = robotName;
|
|
||||||
myStartingPort = port;
|
|
||||||
myUsedPorts = usedPorts;
|
|
||||||
myForwarderServerClientRemovedCB = forwarderServerClientRemovedCB;
|
|
||||||
if (enforceProtocolVersion != NULL)
|
|
||||||
myEnforceProtocolVersion = enforceProtocolVersion;
|
|
||||||
else
|
|
||||||
myEnforceProtocolVersion = "";
|
|
||||||
myEnforceType = enforceType;
|
|
||||||
|
|
||||||
myPrefix = "ArCentralForwarder_";
|
|
||||||
myPrefix += myRobotName;
|
|
||||||
myPrefix += ": ";
|
|
||||||
myServer = NULL;
|
|
||||||
myClient = NULL;
|
|
||||||
myPort = 0;
|
|
||||||
myState = STATE_STARTING;
|
|
||||||
myBeingReplaced = false;
|
|
||||||
myRobotHasCentralServerHeartbeat = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AREXPORT ArCentralForwarder::~ArCentralForwarder()
|
|
||||||
{
|
|
||||||
if (myServer != NULL)
|
|
||||||
{
|
|
||||||
myServer->close();
|
|
||||||
delete myServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myClient != NULL)
|
|
||||||
{
|
|
||||||
if (myClient->isConnected())
|
|
||||||
myClient->disconnect();
|
|
||||||
delete myClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MPL adding this since it looks like it leaks this
|
|
||||||
if (mySocket != NULL)
|
|
||||||
{
|
|
||||||
delete mySocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myRequestOnces.begin() != myRequestOnces.end())
|
|
||||||
ArUtil::deleteSetPairs(myRequestOnces.begin(), myRequestOnces.end());
|
|
||||||
myRequestOnces.clear();
|
|
||||||
if (myLastRequest.begin() != myLastRequest.end())
|
|
||||||
ArUtil::deleteSetPairs(myLastRequest.begin(), myLastRequest.end());
|
|
||||||
myLastRequest.clear();
|
|
||||||
if (myLastBroadcast.begin() != myLastBroadcast.end())
|
|
||||||
ArUtil::deleteSetPairs(myLastBroadcast.begin(), myLastBroadcast.end());
|
|
||||||
myLastBroadcast.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::callOnce(
|
|
||||||
double heartbeatTimeout, double udpHeartbeatTimeout,
|
|
||||||
double robotBackupTimeout, double clientBackupTimeout)
|
|
||||||
{
|
|
||||||
if (myBeingReplaced)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "ArCentralForwarder::%s: being replaced by a duplicate, disconnecting",
|
|
||||||
myRobotName.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myState == STATE_CONNECTED)
|
|
||||||
{
|
|
||||||
return connectedCallOnce(heartbeatTimeout, udpHeartbeatTimeout,
|
|
||||||
robotBackupTimeout, clientBackupTimeout);
|
|
||||||
}
|
|
||||||
else if (myState == STATE_CONNECTING)
|
|
||||||
{
|
|
||||||
return connectingCallOnce(heartbeatTimeout, udpHeartbeatTimeout,
|
|
||||||
robotBackupTimeout, clientBackupTimeout);
|
|
||||||
}
|
|
||||||
else if (myState == STATE_GATHERING)
|
|
||||||
{
|
|
||||||
return gatheringCallOnce(heartbeatTimeout, udpHeartbeatTimeout,
|
|
||||||
robotBackupTimeout, clientBackupTimeout);
|
|
||||||
}
|
|
||||||
else if (myState == STATE_STARTING)
|
|
||||||
{
|
|
||||||
return startingCallOnce(heartbeatTimeout, udpHeartbeatTimeout,
|
|
||||||
robotBackupTimeout, clientBackupTimeout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "%s in bad state, disconnecting",
|
|
||||||
myRobotName.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::startingCallOnce(
|
|
||||||
double heartbeatTimeout, double udpHeartbeatTimeout,
|
|
||||||
double robotBackupTimeout, double clientBackupTimeout)
|
|
||||||
{
|
|
||||||
myClient = new ArClientBase;
|
|
||||||
myClient->enforceProtocolVersion(myEnforceProtocolVersion.c_str(), false);
|
|
||||||
myClient->enforceType(myEnforceType, false);
|
|
||||||
std::string name;
|
|
||||||
name = "ArForwarderClient_" + myRobotName;
|
|
||||||
myClient->setRobotName(name.c_str());
|
|
||||||
|
|
||||||
if (myClient->internalNonBlockingConnectStart("", 0, true, "", "",
|
|
||||||
mySocket) !=
|
|
||||||
ArClientBase::NON_BLOCKING_CONTINUE)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sCould not start connect to switching client %s from %s",
|
|
||||||
myPrefix.c_str(), myRobotName.c_str(),
|
|
||||||
mySocket->getIPString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
myState = STATE_CONNECTING;
|
|
||||||
myLastTcpHeartbeat.setToNow();
|
|
||||||
myLastUdpHeartbeat.setToNow();
|
|
||||||
return callOnce(heartbeatTimeout, udpHeartbeatTimeout,
|
|
||||||
robotBackupTimeout, clientBackupTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::connectingCallOnce(
|
|
||||||
double heartbeatTimeout, double udpHeartbeatTimeout,
|
|
||||||
double robotBackupTimeout, double clientBackupTimeout)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArClientBase::NonBlockingConnectReturn ret;
|
|
||||||
|
|
||||||
if ((ret = myClient->internalNonBlockingConnectContinue()) ==
|
|
||||||
ArClientBase::NON_BLOCKING_CONTINUE)
|
|
||||||
return true;
|
|
||||||
else if (ret == ArClientBase::NON_BLOCKING_FAILED)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sCould not connect to switching client %s from %s",
|
|
||||||
myPrefix.c_str(), myRobotName.c_str(),
|
|
||||||
mySocket->getIPString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (ret == ArClientBase::NON_BLOCKING_CONNECTED)
|
|
||||||
{
|
|
||||||
myState = STATE_GATHERING;
|
|
||||||
myLastTcpHeartbeat.setToNow();
|
|
||||||
myLastUdpHeartbeat.setToNow();
|
|
||||||
return callOnce(heartbeatTimeout, udpHeartbeatTimeout,
|
|
||||||
robotBackupTimeout, clientBackupTimeout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "%sIn unknown state connecting to %s",
|
|
||||||
myPrefix.c_str(), myRobotName.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::gatheringCallOnce(
|
|
||||||
double heartbeatTimeout, double udpHeartbeatTimeout,
|
|
||||||
double robotBackupTimeout, double clientBackupTimeout)
|
|
||||||
{
|
|
||||||
// if we have a heartbeat timeout make sure we've heard the
|
|
||||||
// heartbeat within that range
|
|
||||||
if (heartbeatTimeout >= -.00000001 &&
|
|
||||||
myLastTcpHeartbeat.secSince() >= 5 &&
|
|
||||||
myLastTcpHeartbeat.secSince() / 60.0 > heartbeatTimeout)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sHaven't connected in %g minutes, dropping connection",
|
|
||||||
myPrefix.c_str(), heartbeatTimeout);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!myClient->getReceivedDataList() ||
|
|
||||||
!myClient->getReceivedArgRetList() ||
|
|
||||||
!myClient->getReceivedGroupAndFlagsList())
|
|
||||||
{
|
|
||||||
myClient->loopOnce();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArLog::log(ArLog::Normal, "%Connected to switching client %s from %s",
|
|
||||||
myPrefix.c_str(), myRobotName.c_str(), mySocket->getIPString());
|
|
||||||
//clientBase->logDataList();
|
|
||||||
char serverName[1024];
|
|
||||||
sprintf(serverName, "ArForwarderServer_%s", myRobotName.c_str());
|
|
||||||
myServer = new ArServerBase(false, serverName, false, "", "",
|
|
||||||
false, true,
|
|
||||||
false,
|
|
||||||
false, false);
|
|
||||||
myServer->enforceProtocolVersion(myEnforceProtocolVersion.c_str());
|
|
||||||
// there's no enforce of type here since this is the proxy for MP/ME
|
|
||||||
// and such (robots don't connect here)
|
|
||||||
|
|
||||||
myServer->addClientRemovedCallback(&myClientServerClientRemovedCB);
|
|
||||||
|
|
||||||
ArTime startedOpening;
|
|
||||||
startedOpening.setToNow();
|
|
||||||
int port;
|
|
||||||
bool foundPort;
|
|
||||||
|
|
||||||
std::map<int, ArTime *>::iterator usedIt;
|
|
||||||
// walk through our ports starting at our starting port
|
|
||||||
for (port = myStartingPort, foundPort = false;
|
|
||||||
!foundPort && port < 65536;
|
|
||||||
port++)
|
|
||||||
{
|
|
||||||
// if we've used the port in the last 2 minutes then skip it
|
|
||||||
if ((usedIt = myUsedPorts->find(port)) != myUsedPorts->end() &&
|
|
||||||
(*usedIt).second != NULL &&
|
|
||||||
((*usedIt).second->getSec() == 0 ||
|
|
||||||
(*usedIt).second->secSince() < 120))
|
|
||||||
{
|
|
||||||
|
|
||||||
ArLog::log(ArLog::Verbose, "%sSkipping port %d", myPrefix.c_str(), port);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to open it
|
|
||||||
if (myServer->open(port, myMainServer->getOpenOnIP()))
|
|
||||||
{
|
|
||||||
foundPort = true;
|
|
||||||
myPort = port;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foundPort)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "%s Could not find port",
|
|
||||||
myPrefix.c_str());
|
|
||||||
}
|
|
||||||
myServer->setUserInfo(myMainServer->getUserInfo());
|
|
||||||
|
|
||||||
std::map<unsigned int, ArClientData *>::const_iterator dIt;
|
|
||||||
ArClientData *clientData;
|
|
||||||
|
|
||||||
myServer->addClientRemovedCallback(&myRobotServerClientRemovedCB);
|
|
||||||
|
|
||||||
myClient->addHandler("centralHeartbeat", &myNetCentralHeartbeatCB);
|
|
||||||
myClient->request("centralHeartbeat", 1000);
|
|
||||||
|
|
||||||
if (myClient->dataExists("identSetSelfIdentifier"))
|
|
||||||
{
|
|
||||||
ArNetPacket sending;
|
|
||||||
sending.strToBuf("CentralServer");
|
|
||||||
myClient->requestOnce("identSetSelfIdentifier", &sending);
|
|
||||||
}
|
|
||||||
|
|
||||||
myLastTcpHeartbeat.setToNow();
|
|
||||||
myLastUdpHeartbeat.setToNow();
|
|
||||||
|
|
||||||
for (dIt = myClient->getDataMap()->begin();
|
|
||||||
dIt != myClient->getDataMap()->end();
|
|
||||||
dIt++)
|
|
||||||
{
|
|
||||||
clientData = (*dIt).second;
|
|
||||||
|
|
||||||
if (myMainServer->dataHasFlag(clientData->getName(),
|
|
||||||
"MAIN_SERVER_ONLY"))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sNot forwarding %s since it is MAIN_SERVER_ONLY",
|
|
||||||
myPrefix.c_str(), clientData->getName());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (clientData->hasDataFlag("DO_NOT_FORWARD"))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sNot forwarding %s since it is DO_NOT_FORWARD",
|
|
||||||
myPrefix.c_str(), clientData->getName());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (clientData->hasDataFlag("RETURN_NONE"))
|
|
||||||
{
|
|
||||||
myReturnTypes[clientData->getCommand()] = RETURN_NONE;
|
|
||||||
}
|
|
||||||
else if (clientData->hasDataFlag("RETURN_SINGLE"))
|
|
||||||
{
|
|
||||||
myReturnTypes[clientData->getCommand()] = RETURN_SINGLE;
|
|
||||||
myRequestOnces[clientData->getCommand()] =
|
|
||||||
new std::list<ArServerClient *>;
|
|
||||||
}
|
|
||||||
else if (clientData->hasDataFlag("RETURN_VIDEO"))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sForwarding %s that is RETURN_VIDEO",
|
|
||||||
myPrefix.c_str(), clientData->getName());
|
|
||||||
myReturnTypes[clientData->getCommand()] = RETURN_VIDEO;
|
|
||||||
myRequestOnces[clientData->getCommand()] =
|
|
||||||
new std::list<ArServerClient *>;
|
|
||||||
}
|
|
||||||
else if (clientData->hasDataFlag("RETURN_VIDEO_OPTIM"))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sForwarding %s that is RETURN_VIDEO_OPTIM",
|
|
||||||
myPrefix.c_str(), clientData->getName());
|
|
||||||
myReturnTypes[clientData->getCommand()] = RETURN_VIDEO_OPTIM;
|
|
||||||
myRequestOnces[clientData->getCommand()] =
|
|
||||||
new std::list<ArServerClient *>;
|
|
||||||
}
|
|
||||||
else if (clientData->hasDataFlag("RETURN_UNTIL_EMPTY"))
|
|
||||||
{
|
|
||||||
myReturnTypes[clientData->getCommand()] = RETURN_UNTIL_EMPTY;
|
|
||||||
myRequestOnces[clientData->getCommand()] =
|
|
||||||
new std::list<ArServerClient *>;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (clientData->hasDataFlag("RETURN_COMPLEX"))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sNot forwarding %s since it is a complex return",
|
|
||||||
myPrefix.c_str(), clientData->getName());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sNot forwarding %s since it is an unknown return (data flags %s)",
|
|
||||||
myPrefix.c_str(), clientData->getName(),
|
|
||||||
clientData->getDataFlagsString());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
setLastRequest(clientData->getCommand());
|
|
||||||
setLastBroadcast(clientData->getCommand());
|
|
||||||
|
|
||||||
myServer->addDataAdvanced(
|
|
||||||
clientData->getName(), clientData->getDescription(),
|
|
||||||
NULL, clientData->getArgumentDescription(),
|
|
||||||
clientData->getReturnDescription(), clientData->getCommandGroup(),
|
|
||||||
clientData->getDataFlagsString(), clientData->getCommand(),
|
|
||||||
&myInternalRequestChangedFunctor,
|
|
||||||
&myInternalRequestOnceFunctor);
|
|
||||||
|
|
||||||
myClient->addHandler(clientData->getName(), &myReceiveDataFunctor);
|
|
||||||
}
|
|
||||||
if (myClient->dataExists("centralServerHeartbeat"))
|
|
||||||
{
|
|
||||||
ArNetPacket sending;
|
|
||||||
myRobotHasCentralServerHeartbeat = true;
|
|
||||||
myLastSentCentralServerHeartbeat.setToNow();
|
|
||||||
myClient->requestOnce("centralServerHeartbeat", &sending, true);
|
|
||||||
myClient->requestOnceUdp("centralServerHeartbeat", &sending, true);
|
|
||||||
}
|
|
||||||
myState = STATE_CONNECTED;
|
|
||||||
return callOnce(heartbeatTimeout, udpHeartbeatTimeout,
|
|
||||||
robotBackupTimeout, clientBackupTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::connectedCallOnce(
|
|
||||||
double heartbeatTimeout, double udpHeartbeatTimeout,
|
|
||||||
double robotBackupTimeout, double clientBackupTimeout)
|
|
||||||
{
|
|
||||||
if (!myClient->isConnected())
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "%sLost connection to robot",
|
|
||||||
myPrefix.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
myClient->setBackupTimeout(robotBackupTimeout);
|
|
||||||
myServer->setBackupTimeout(clientBackupTimeout);
|
|
||||||
|
|
||||||
if (myRobotHasCentralServerHeartbeat &&
|
|
||||||
myLastSentCentralServerHeartbeat.mSecSince() >= 1000)
|
|
||||||
{
|
|
||||||
ArNetPacket sending;
|
|
||||||
myLastSentCentralServerHeartbeat.setToNow();
|
|
||||||
myClient->requestOnce("centralServerHeartbeat", &sending, true);
|
|
||||||
myClient->requestOnceUdp("centralServerHeartbeat", &sending, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
myClient->loopOnce();
|
|
||||||
myServer->loopOnce();
|
|
||||||
|
|
||||||
// if we have a heartbeat timeout make sure we've heard the
|
|
||||||
// heartbeat within that range
|
|
||||||
if (heartbeatTimeout >= -.00000001 &&
|
|
||||||
myLastTcpHeartbeat.secSince() >= 5 &&
|
|
||||||
myLastTcpHeartbeat.secSince() / 60.0 >= heartbeatTimeout)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "%sHaven't heard from robot in %g minutes, dropping connection", myPrefix.c_str(), heartbeatTimeout);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we have a heartbeat timeout make sure we've heard the
|
|
||||||
// heartbeat within that range
|
|
||||||
if ((!myClient->isTcpOnlyFromServer() || !myClient->isTcpOnlyToServer()) &&
|
|
||||||
udpHeartbeatTimeout >= -.00000001 &&
|
|
||||||
myLastUdpHeartbeat.secSince() >= 5 &&
|
|
||||||
myLastUdpHeartbeat.secSince() / 60.0 >= udpHeartbeatTimeout)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sSwitching to TCP only since haven't gotten UDP in %g minutes",
|
|
||||||
myPrefix.c_str(), udpHeartbeatTimeout);
|
|
||||||
myClient->setTcpOnlyFromServer();
|
|
||||||
myClient->setTcpOnlyToServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArCentralForwarder::robotServerClientRemoved(ArServerClient *client)
|
|
||||||
{
|
|
||||||
std::map<unsigned int, std::list<ArServerClient *> *>::iterator rIt;
|
|
||||||
std::list<ArServerClient *> *requestList = NULL;
|
|
||||||
std::list<ArServerClient *>::iterator scIt;
|
|
||||||
|
|
||||||
printf("Client disconnected\n");
|
|
||||||
for (rIt = myRequestOnces.begin(); rIt != myRequestOnces.end(); rIt++)
|
|
||||||
{
|
|
||||||
requestList = (*rIt).second;
|
|
||||||
// while we have entries for this client we loop and replace them
|
|
||||||
// with NULLs
|
|
||||||
bool foundOne = true;
|
|
||||||
while (foundOne)
|
|
||||||
{
|
|
||||||
foundOne = false;
|
|
||||||
// see if we found one
|
|
||||||
for (scIt = requestList->begin();
|
|
||||||
!foundOne && scIt != requestList->end();
|
|
||||||
scIt++)
|
|
||||||
{
|
|
||||||
if ((*scIt) == client)
|
|
||||||
{
|
|
||||||
foundOne = true;
|
|
||||||
printf("Got...\n");
|
|
||||||
requestList->insert(scIt, (ArServerClient*)NULL);
|
|
||||||
for (scIt = requestList->begin();
|
|
||||||
scIt != requestList->end();
|
|
||||||
scIt++)
|
|
||||||
{
|
|
||||||
if ((*scIt) == client)
|
|
||||||
{
|
|
||||||
requestList->erase(scIt);
|
|
||||||
printf("Removed request for client %p\n", client);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArCentralForwarder::clientServerClientRemoved(ArServerClient *client)
|
|
||||||
{
|
|
||||||
if (client->getState() != ArServerClient::STATE_DISCONNECTED)
|
|
||||||
myForwarderServerClientRemovedCB->invoke(this, client);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ArCentralForwarder::receiveData(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
ReturnType returnType;
|
|
||||||
std::list<ArServerClient *>::iterator it;
|
|
||||||
ArServerClient *client;
|
|
||||||
|
|
||||||
// chop off the old footer
|
|
||||||
//packet->setLength(packet->getLength() - ArNetPacket::FOOTER_LENGTH);
|
|
||||||
packet->setAddedFooter(true);
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (strcmp(myClient->getName(packet->getCommand(), true),
|
|
||||||
"getPictureCam1") == 0)
|
|
||||||
printf("Got getPictureCam1...\n");
|
|
||||||
*/
|
|
||||||
returnType = getReturnType(packet->getCommand());
|
|
||||||
//printf("Got a packet in for %s %d\n", myClient->getName(packet->getCommand(), true), packet->getCommand());
|
|
||||||
|
|
||||||
// this part is seeing if it came from a request_once, if so we
|
|
||||||
// don't service anything else (so we take care of those things that
|
|
||||||
// only happen once better then the ones that are mixing... but that
|
|
||||||
// should be okay)
|
|
||||||
checkRequestOnces(packet->getCommand());
|
|
||||||
if ((returnType == RETURN_SINGLE || returnType == RETURN_UNTIL_EMPTY) &&
|
|
||||||
(it = myRequestOnces[packet->getCommand()]->begin()) !=
|
|
||||||
myRequestOnces[packet->getCommand()]->end())
|
|
||||||
{
|
|
||||||
//if (returnType == RETURN_UNTIL_EMPTY)
|
|
||||||
//printf("Got a packet for %s with length %d %d\n", myClient->getName(packet->getCommand(), true), packet->getDataLength(), packet->getLength());
|
|
||||||
|
|
||||||
client = (*it);
|
|
||||||
if (client != NULL)
|
|
||||||
{
|
|
||||||
if (packet->getPacketSource() == ArNetPacket::TCP)
|
|
||||||
client->sendPacketTcp(packet);
|
|
||||||
else if (packet->getPacketSource() == ArNetPacket::UDP)
|
|
||||||
client->sendPacketUdp(packet);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
client->sendPacketTcp(packet);
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sDon't know what type of packet %s is (%d)",
|
|
||||||
myPrefix.c_str(),
|
|
||||||
myClient->getName(packet->getCommand(), true),
|
|
||||||
packet->getPacketSource());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((returnType == RETURN_UNTIL_EMPTY && packet->getDataLength() == 0) ||
|
|
||||||
returnType == RETURN_SINGLE)
|
|
||||||
{
|
|
||||||
//if (returnType == RETURN_UNTIL_EMPTY)
|
|
||||||
//printf("Got final packet for for %s\n", myClient->getName(packet->getCommand(), true));
|
|
||||||
myRequestOnces[packet->getCommand()]->pop_front();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (returnType == RETURN_VIDEO)
|
|
||||||
{
|
|
||||||
// what we do here is send it to the ones that have requested it
|
|
||||||
// but aren't listening for the broadcast... then we broadcast it
|
|
||||||
// to everyone whose listening... this should ensure that everyone
|
|
||||||
// just gets the packet once as often as we see it...
|
|
||||||
|
|
||||||
while ((it = myRequestOnces[packet->getCommand()]->begin()) !=
|
|
||||||
myRequestOnces[packet->getCommand()]->end())
|
|
||||||
{
|
|
||||||
//printf("Sent a single return_single_and_broadcast for %s\n", myClient->getName(packet->getCommand(), true));
|
|
||||||
client = (*it);
|
|
||||||
if (client != NULL && client->getFrequency(packet->getCommand()) == -2)
|
|
||||||
{
|
|
||||||
if (packet->getPacketSource() == ArNetPacket::TCP)
|
|
||||||
client->sendPacketTcp(packet);
|
|
||||||
else if (packet->getPacketSource() == ArNetPacket::UDP)
|
|
||||||
client->sendPacketUdp(packet);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
client->sendPacketTcp(packet);
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sDon't know what type of packet %s is (%d)",
|
|
||||||
myPrefix.c_str(),
|
|
||||||
myClient->getName(packet->getCommand(), true),
|
|
||||||
packet->getPacketSource());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myRequestOnces[packet->getCommand()]->pop_front();
|
|
||||||
}
|
|
||||||
//printf("Broadcast return_single_and_broadcast for %s\n", myClient->getName(packet->getCommand(), true));
|
|
||||||
myLastBroadcast[packet->getCommand()]->setToNow();
|
|
||||||
if (packet->getPacketSource() == ArNetPacket::TCP)
|
|
||||||
{
|
|
||||||
myServer->broadcastPacketTcpByCommand(packet, packet->getCommand());
|
|
||||||
}
|
|
||||||
else if (packet->getPacketSource() == ArNetPacket::UDP)
|
|
||||||
{
|
|
||||||
myServer->broadcastPacketUdpByCommand(packet, packet->getCommand());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
myServer->broadcastPacketTcpByCommand(packet, packet->getCommand());
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sDon't know what type of packet %s is (%d)",
|
|
||||||
myPrefix.c_str(),
|
|
||||||
myClient->getName(packet->getCommand(), true),
|
|
||||||
packet->getPacketSource());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (returnType == RETURN_VIDEO_OPTIM)
|
|
||||||
{
|
|
||||||
// what we do here is send it to the ones that have requested it
|
|
||||||
while ((it = myRequestOnces[packet->getCommand()]->begin()) !=
|
|
||||||
myRequestOnces[packet->getCommand()]->end())
|
|
||||||
{
|
|
||||||
client = (*it);
|
|
||||||
/*
|
|
||||||
ArLog::log(ArLog::Normal, "%sSent a return_video_optim for %s to %s",
|
|
||||||
myPrefix.c_str(),
|
|
||||||
myClient->getName(packet->getCommand(), true),
|
|
||||||
client->getIPString());
|
|
||||||
*/
|
|
||||||
if (client != NULL)
|
|
||||||
{
|
|
||||||
if (packet->getPacketSource() == ArNetPacket::TCP)
|
|
||||||
client->sendPacketTcp(packet);
|
|
||||||
else if (packet->getPacketSource() == ArNetPacket::UDP)
|
|
||||||
client->sendPacketUdp(packet);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
client->sendPacketTcp(packet);
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sDon't know what type of packet %s is (%d)",
|
|
||||||
myPrefix.c_str(),
|
|
||||||
myClient->getName(packet->getCommand(), true),
|
|
||||||
packet->getPacketSource());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myRequestOnces[packet->getCommand()]->pop_front();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
myLastBroadcast[packet->getCommand()]->setToNow();
|
|
||||||
if (packet->getPacketSource() == ArNetPacket::TCP)
|
|
||||||
{
|
|
||||||
myServer->broadcastPacketTcpByCommand(packet, packet->getCommand());
|
|
||||||
}
|
|
||||||
else if (packet->getPacketSource() == ArNetPacket::UDP)
|
|
||||||
{
|
|
||||||
myServer->broadcastPacketUdpByCommand(packet, packet->getCommand());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
myServer->broadcastPacketTcpByCommand(packet, packet->getCommand());
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sDon't know what type of packet %s is (%d)",
|
|
||||||
myPrefix.c_str(),
|
|
||||||
myClient->getName(packet->getCommand(), true),
|
|
||||||
packet->getPacketSource());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArCentralForwarder::internalRequestChanged(long interval,
|
|
||||||
unsigned int command)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
if (strcmp(myClient->getName(command, true),
|
|
||||||
"getPictureCam1") == 0)
|
|
||||||
printf("Changed getPictureCam1 to %d...\n", interval);
|
|
||||||
*/
|
|
||||||
if (interval == -2)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Verbose, "%sStopping request for %s",
|
|
||||||
myPrefix.c_str(), myClient->getName(command, true));
|
|
||||||
myClient->requestStopByCommand(command);
|
|
||||||
setLastRequest(command);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ReturnType returnType;
|
|
||||||
|
|
||||||
returnType = getReturnType(command);
|
|
||||||
if (returnType == RETURN_VIDEO && interval != -1)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Verbose, "%sIgnoring a RETURN_VIDEO attempted request of %s at %d interval since RETURN_VIDEOs cannot request at an interval",
|
|
||||||
myPrefix.c_str(), myClient->getName(command, true), interval);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (returnType == RETURN_VIDEO_OPTIM && interval != -1)
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Verbose, "%sIgnoring a RETURN_VIDEO_OPTIM attempted request of %s at %d interval since RETURN_VIDEOs cannot request at an interval",
|
|
||||||
myPrefix.c_str(), myClient->getName(command, true), interval);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArLog::log(ArLog::Verbose, "%sRequesting %s at interval of %ld",
|
|
||||||
myPrefix.c_str(), myClient->getName(command, true), interval);
|
|
||||||
myClient->requestByCommand(command, interval);
|
|
||||||
setLastRequest(command);
|
|
||||||
// if the interval is -1 then also requestOnce it so that anyone
|
|
||||||
// connecting after the first connection can actually get data too
|
|
||||||
myClient->requestOnceByCommand(command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ArCentralForwarder::internalRequestOnce(
|
|
||||||
ArServerClient *client, ArNetPacket *packet, bool tcp)
|
|
||||||
{
|
|
||||||
ReturnType returnType = RETURN_NONE;
|
|
||||||
|
|
||||||
returnType = getReturnType(packet->getCommand());
|
|
||||||
|
|
||||||
// chop off the footer
|
|
||||||
packet->setAddedFooter(true);
|
|
||||||
/*
|
|
||||||
if (strcmp(myClient->getName(packet->getCommand(), true),
|
|
||||||
"getPictureCam1") == 0)
|
|
||||||
printf("Request once for getPictureCam1...\n");
|
|
||||||
*/
|
|
||||||
// if its video and the last broadcast or request was very recently
|
|
||||||
// then ignore it so we don't wind up using up our wireless
|
|
||||||
// bandwidth
|
|
||||||
// MPL taking this out since it may be causing some problems
|
|
||||||
/*
|
|
||||||
if (returnType == RETURN_VIDEO &&
|
|
||||||
(myLastBroadcast[packet->getCommand()]->mSecSince() < 25 ||
|
|
||||||
myLastRequest[packet->getCommand()]->mSecSince() < 25))
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal, "Ignoring a RETURN_VIDEO of %s since request or broadcast was recent", myClient->getName(packet->getCommand(), true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// if its a type where we keep track then put it into the list
|
|
||||||
if (returnType == RETURN_SINGLE || returnType == RETURN_UNTIL_EMPTY ||
|
|
||||||
returnType == RETURN_VIDEO || returnType == RETURN_VIDEO_OPTIM)
|
|
||||||
{
|
|
||||||
//if (returnType == RETURN_UNTIL_EMPTY)
|
|
||||||
//printf("Trying to request once %s\n", myClient->getName(packet->getCommand(), true));
|
|
||||||
checkRequestOnces(packet->getCommand());
|
|
||||||
myRequestOnces[packet->getCommand()]->push_back(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ret;
|
|
||||||
ArLog::log(ArLog::Verbose, "%sRequesting %s once",
|
|
||||||
myPrefix.c_str(), myClient->getName(packet->getCommand()));
|
|
||||||
if (tcp)
|
|
||||||
ret = myClient->requestOnceByCommand(packet->getCommand(), packet);
|
|
||||||
else
|
|
||||||
ret = myClient->requestOnceByCommandUdp(packet->getCommand(), packet);
|
|
||||||
|
|
||||||
setLastRequest(packet->getCommand());
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AREXPORT void ArCentralForwarder::netCentralHeartbeat(ArNetPacket *packet)
|
|
||||||
{
|
|
||||||
if (packet->getPacketSource() == ArNetPacket::TCP)
|
|
||||||
myLastTcpHeartbeat.setToNow();
|
|
||||||
else if (packet->getPacketSource() == ArNetPacket::UDP)
|
|
||||||
myLastUdpHeartbeat.setToNow();
|
|
||||||
else
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"%sGot unknown packet source for heartbeat packet",
|
|
||||||
myPrefix.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::addHandler(
|
|
||||||
const char *name, ArFunctor1 <ArNetPacket *> *functor)
|
|
||||||
{
|
|
||||||
if (myClient != NULL)
|
|
||||||
{
|
|
||||||
return myClient->addHandler(name, functor);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"ArCentralForwarder::%s::addHandler: Tried to call while client was still NULL",
|
|
||||||
getRobotName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::remHandler(const char *name, ArFunctor1<ArNetPacket *> *functor)
|
|
||||||
{
|
|
||||||
if (myClient != NULL)
|
|
||||||
{
|
|
||||||
return myClient->remHandler(name, functor);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"ArCentralForwarder::%s::remHandler: Tried to call while client was still NULL",
|
|
||||||
getRobotName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::request(const char *name, long mSec)
|
|
||||||
{
|
|
||||||
if (myServer != NULL)
|
|
||||||
{
|
|
||||||
return myServer->internalSetDefaultFrequency(name, mSec);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"ArCentralForwarder::%s::remHandler: Tried to call while server was still NULL",
|
|
||||||
getRobotName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::requestOnce(const char *name,
|
|
||||||
ArNetPacket *packet,
|
|
||||||
bool quiet)
|
|
||||||
{
|
|
||||||
if (myClient != NULL)
|
|
||||||
{
|
|
||||||
unsigned int commandNum = myClient->findCommandFromName(name);
|
|
||||||
if (commandNum == 0)
|
|
||||||
{
|
|
||||||
if (!quiet)
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"ArCentralForwarder::%s::requestOnce: Can't find commandNum for %s",
|
|
||||||
getRobotName(), name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//return myClient->requestOnce(name, packet, quiet);
|
|
||||||
if (packet != NULL)
|
|
||||||
{
|
|
||||||
packet->setCommand(commandNum);
|
|
||||||
packet->finalizePacket();
|
|
||||||
return internalRequestOnce(NULL, packet, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArNetPacket tempPacket;
|
|
||||||
tempPacket.setCommand(commandNum);
|
|
||||||
tempPacket.finalizePacket();
|
|
||||||
return internalRequestOnce(NULL, &tempPacket, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!quiet)
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"ArCentralForwarder::%s::requestOnce: Tried to call (for %s) while client was still NULL",
|
|
||||||
getRobotName(), name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::requestOnceUdp(const char *name,
|
|
||||||
ArNetPacket *packet,
|
|
||||||
bool quiet)
|
|
||||||
{
|
|
||||||
if (myClient != NULL)
|
|
||||||
{
|
|
||||||
unsigned int commandNum = myClient->findCommandFromName(name);
|
|
||||||
if (commandNum == 0)
|
|
||||||
{
|
|
||||||
if (!quiet)
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"ArCentralForwarder::%s::requestOnce: Can't find commandNum for %s",
|
|
||||||
getRobotName(), name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//return myClient->requestOnceUdp(name, packet, quiet);
|
|
||||||
if (packet != NULL)
|
|
||||||
{
|
|
||||||
packet->setCommand(commandNum);
|
|
||||||
packet->finalizePacket();
|
|
||||||
return internalRequestOnce(NULL, packet, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArNetPacket tempPacket;
|
|
||||||
tempPacket.setCommand(commandNum);
|
|
||||||
tempPacket.finalizePacket();
|
|
||||||
return internalRequestOnce(NULL, &tempPacket, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!quiet)
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"ArCentralForwarder::%s::requestOnce: Tried to call (for %s) while client was still NULL",
|
|
||||||
getRobotName(), name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::requestOnceWithString(const char *name, const char *str)
|
|
||||||
{
|
|
||||||
ArNetPacket tempPacket;
|
|
||||||
tempPacket.strToBuf(str);
|
|
||||||
|
|
||||||
return requestOnce(name, &tempPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
AREXPORT bool ArCentralForwarder::dataExists(const char *name)
|
|
||||||
{
|
|
||||||
if (myClient != NULL)
|
|
||||||
{
|
|
||||||
return myClient->dataExists(name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ArLog::log(ArLog::Normal,
|
|
||||||
"ArCentralForwarder::%s::dataExists: Tried to call while client was still NULL",
|
|
||||||
getRobotName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ArCentralForwarder::ReturnType ArCentralForwarder::getReturnType(int command)
|
|
||||||
{
|
|
||||||
if (myReturnTypes.find(command) != myReturnTypes.end())
|
|
||||||
return myReturnTypes[command];
|
|
||||||
else
|
|
||||||
return RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArCentralForwarder::checkRequestOnces(unsigned int command)
|
|
||||||
{
|
|
||||||
if (myRequestOnces.find(command) == myRequestOnces.end())
|
|
||||||
myRequestOnces[command] = new std::list<ArServerClient *>;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArCentralForwarder::setLastRequest(unsigned int command)
|
|
||||||
{
|
|
||||||
if (myLastRequest.find(command) == myLastRequest.end())
|
|
||||||
myLastRequest[command] = new ArTime;
|
|
||||||
myLastRequest[command]->setToNow();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArCentralForwarder::setLastBroadcast(unsigned int command)
|
|
||||||
{
|
|
||||||
if (myLastBroadcast.find(command) == myLastBroadcast.end())
|
|
||||||
myLastBroadcast[command] = new ArTime;
|
|
||||||
myLastBroadcast[command]->setToNow();
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user