[Jderobot-admin] jderobot-r1086 - in trunk/src/stable/components/visualHFSM: . gui popups
bmenendez en jderobot.org
bmenendez en jderobot.org
Sab Nov 2 20:50:33 CET 2013
Author: bmenendez
Date: 2013-11-02 20:50:32 +0100 (Sat, 02 Nov 2013)
New Revision: 1086
Added:
trunk/src/stable/components/visualHFSM/allinterfaces.txt
trunk/src/stable/components/visualHFSM/getinterfaces.sh
trunk/src/stable/components/visualHFSM/gui/additional_libraries.glade
trunk/src/stable/components/visualHFSM/iceinterface.cpp
trunk/src/stable/components/visualHFSM/iceinterface.h
trunk/src/stable/components/visualHFSM/popups/librariesdialog.cpp
trunk/src/stable/components/visualHFSM/popups/librariesdialog.h
Removed:
trunk/src/stable/components/visualHFSM/tipos.h
Modified:
trunk/src/stable/components/visualHFSM/CMakeLists.txt
trunk/src/stable/components/visualHFSM/generate.cpp
trunk/src/stable/components/visualHFSM/generate.h
trunk/src/stable/components/visualHFSM/gui/configfile.glade
trunk/src/stable/components/visualHFSM/gui/main_gui.glade
trunk/src/stable/components/visualHFSM/guinode.cpp
trunk/src/stable/components/visualHFSM/guisubautomata.cpp
trunk/src/stable/components/visualHFSM/guisubautomata.h
trunk/src/stable/components/visualHFSM/guitransition.cpp
trunk/src/stable/components/visualHFSM/popups/configfiledialog.cpp
trunk/src/stable/components/visualHFSM/popups/configfiledialog.h
trunk/src/stable/components/visualHFSM/popups/renamedialog.cpp
trunk/src/stable/components/visualHFSM/popups/renamedialog.h
trunk/src/stable/components/visualHFSM/savefile.cpp
trunk/src/stable/components/visualHFSM/savefile.h
trunk/src/stable/components/visualHFSM/visualhfsm.cpp
trunk/src/stable/components/visualHFSM/visualhfsm.h
trunk/src/stable/components/visualHFSM/xmlparser.cpp
trunk/src/stable/components/visualHFSM/xmlparser.h
Log:
#93 Latest version of VisualHFSM. It includes the following improvements:
Better system of ICE interfaces additioning. Now, the user will have to enter
a name (of the server interface), an IP, a port and an interface type (Camera,
Pose3DMotors, ...). The types are dynamically generated from the files under
/usr/local/include/jderobot/slice
Now, before to generate the C++ code, it checks:
- No repeated ICE interfaces.
- No empty state names.
- No repeated state names.
- No empty transition types.
- No empty iteration time for a subautomata.
- No empty subautomatas.
When changing a state name, the treeview updates its information.
There is now the chance of add headers (for external libraries).
Fixed a bug in copying a node.
There are no old files (of the oldest version of VisualHFSM).
Modified: trunk/src/stable/components/visualHFSM/CMakeLists.txt
===================================================================
--- trunk/src/stable/components/visualHFSM/CMakeLists.txt 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/CMakeLists.txt 2013-11-02 19:50:32 UTC (rev 1086)
@@ -1,9 +1,31 @@
IF (goocanvasmm_INCLUDE_DIRS)
-SET( SOURCE_FILES_VISUALHFSM point.cpp node.cpp transition.cpp guinode.cpp subautomata.cpp guitransition.cpp guisubautomata.cpp generate.cpp popups/configfiledialog.cpp popups/editnodedialog.cpp popups/edittransitiondialog.cpp popups/funvardialog.cpp popups/importdialog.cpp popups/loadfiledialog.cpp popups/renamedialog.cpp popups/renametransitiondialog.cpp popups/savefiledialog.cpp popups/timerdialog.cpp savefile.cpp xmlparser.cpp visualhfsm.cpp main.cpp )
+SET( SOURCE_FILES_VISUALHFSM
+ iceinterface.cpp
+ point.cpp
+ node.cpp
+ transition.cpp
+ guinode.cpp
+ subautomata.cpp
+ guitransition.cpp
+ guisubautomata.cpp
+ generate.cpp
+ popups/configfiledialog.cpp
+ popups/editnodedialog.cpp
+ popups/edittransitiondialog.cpp
+ popups/funvardialog.cpp
+ popups/librariesdialog.cpp
+ popups/loadfiledialog.cpp
+ popups/renamedialog.cpp
+ popups/renametransitiondialog.cpp
+ popups/savefiledialog.cpp
+ popups/timerdialog.cpp
+ savefile.cpp
+ xmlparser.cpp
+ visualhfsm.cpp
+ main.cpp
+)
-#SET( CMAKE_CXX_FLAGS "-g -Wall -fpermissive" ) # Opciones para el compilador
-
include_directories (
${INTERFACES_CPP_DIR}
${LIBS_DIR}
Added: trunk/src/stable/components/visualHFSM/allinterfaces.txt
===================================================================
--- trunk/src/stable/components/visualHFSM/allinterfaces.txt (rev 0)
+++ trunk/src/stable/components/visualHFSM/allinterfaces.txt 2013-11-02 19:50:32 UTC (rev 1086)
@@ -0,0 +1,26 @@
+BodyEncoders bodyencoders
+BodyMotors bodymotors
+BodyMovements bodymovements
+Camera camera
+Encoders encoders
+ImageConsumer image
+ImageProvider image
+JointMotor jointmotor
+KinectLeds kinectleds
+Laser laser
+Motors motors
+NaoFollowBall naofollowball
+NaoMotions naomotions
+pointCloud pointcloud
+Pose3DEncoders pose3dencoders
+Pose3D pose3d
+Pose3DMotors pose3dmotors
+PTEncoders ptencoders
+PTMotors ptmotors
+remoteCloud remoteCloud
+remoteConfig remoteConfig
+remoteView remoteView
+replayControl replayControl
+Sonars sonars
+VarColor varcolor
+wiiMote wiimote
Modified: trunk/src/stable/components/visualHFSM/generate.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/generate.cpp 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/generate.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -25,12 +25,16 @@
*************************************************************/
Generate::Generate ( std::list<SubAutomata> subautomataList, std::string cpppath,
std::string cfgpath, std::string cmakepath,
- std::string configfile ) {
+ std::list<IceInterface>* listInterfaces,
+ std::map<std::string, std::string> mapInterfacesHeader,
+ std::list<std::string> listLibraries ) {
this->subautomataList = subautomataList;
this->path = cpppath;
this->cfgpath = cfgpath;
this->cmakepath = cmakepath;
- this->configfile = configfile;
+ this->listInterfaces = listInterfaces;
+ this->mapInterfacesHeader = mapInterfacesHeader;
+ this->listLibraries = listLibraries;
this->mapTab[T_ZERO] = std::string();
this->mapTab[T_ONE] = std::string("\t");
@@ -62,9 +66,7 @@
this->fs.open(this->cfgpath.c_str(), std::fstream::out);
if (this->fs.is_open()) {
- this->fs << this->configfile << std::endl;
- this->fs.flush();
- // this->generateCfg();
+ this->generateCfg();
this->fs.close();
}
@@ -84,25 +86,23 @@
}
void Generate::generateGenericHeaders () {
- this->fs << "#include <iostream>" << std::endl;
- this->fs << "#include <stdio.h>" << std::endl;
- this->fs << std::endl;
this->fs << "#include <Ice/Ice.h>" << std::endl;
this->fs << "#include <IceUtil/IceUtil.h>" << std::endl;
this->fs << std::endl;
+ for ( std::list<std::string>::iterator listLibsIterator = this->listLibraries.begin();
+ listLibsIterator != this->listLibraries.end(); listLibsIterator++ )
+ this->fs << "#include <" << *listLibsIterator << ">" << std::endl;
+ this->fs << std::endl;
this->fs.flush();
}
void Generate::generateSpecificHeaders () {
- for ( std::list<SubAutomata>::iterator subListIterator = this->subautomataList.begin();
- subListIterator != this->subautomataList.end(); subListIterator++ ) {
- std::list<std::string>* interfacesList = subListIterator->getInterfaces();
- for ( std::list<std::string>::iterator intListIterator = interfacesList->begin();
- intListIterator != interfacesList->end(); intListIterator++ )
- this->fs << "#include " << *intListIterator << std::endl;
- this->fs << std::endl;
- this->fs.flush();
- }
+ for ( std::list<IceInterface>::iterator listInterfacesIterator = this->listInterfaces->begin();
+ listInterfacesIterator != this->listInterfaces->end(); listInterfacesIterator++ )
+ this->fs << "#include <jderobot/" << this->mapInterfacesHeader[listInterfacesIterator->getInterface()] << ".h>" << std::endl;
+
+ this->fs << std::endl;
+ this->fs.flush();
}
void Generate::generateEnums () {
@@ -167,20 +167,9 @@
this->fs << std::endl;
this->fs.flush();
- this->fs << "jderobot::CameraPrx cameraprx;" << std::endl;
- this->fs << "jderobot::MotorsPrx motorsprx;" << std::endl;
- this->fs << "jderobot::NaoMotionsPrx motions;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx head;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx leftshoulder;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx rightshoulder;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx leftelbow;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx rightelbow;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx lefthip;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx righthip;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx leftknee;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx rightknee;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx leftankle;" << std::endl;
- this->fs << "jderobot::Pose3DMotorsPrx rightankle;" << std::endl;
+ for ( std::list<IceInterface>::iterator listInterfacesIterator = this->listInterfaces->begin();
+ listInterfacesIterator != this->listInterfaces->end(); listInterfacesIterator++ )
+ this->fs << "jderobot::" << listInterfacesIterator->getInterface() << "Prx " << listInterfacesIterator->getName() << "prx;" << std::endl;
this->fs << std::endl;
this->fs.flush();
}
@@ -385,151 +374,21 @@
this->fs << "\t\tic = Ice::initialize(argc, argv);" << std::endl;
this->fs << std::endl;
- this->fs << "\t\t// Contact to camera" << std::endl;
- this->fs << "\t\tIce::ObjectPrx camera = ic->propertyToProxy(\"comp.Camera.Proxy\");" << std::endl;
- this->fs << "\t\tif (camera == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with camera\";" << std::endl;
- this->fs << "\t\tcameraprx = jderobot::CameraPrx::checkedCast(camera);" << std::endl;
- this->fs << "\t\tif (cameraprx == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.Camera.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Camera connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
+ for ( std::list<IceInterface>::iterator listInterfacesIterator = this->listInterfaces->begin();
+ listInterfacesIterator != this->listInterfaces->end(); listInterfacesIterator++ ) {
+ this->fs << "\t\t// Contact to " << listInterfacesIterator->getName() << std::endl;
+ this->fs << "\t\tIce::ObjectPrx " << listInterfacesIterator->getName() << " = ic->propertyToProxy(\"automata." << listInterfacesIterator->getName() << ".Proxy\");" << std::endl;
+ this->fs << "\t\tif (" << listInterfacesIterator->getName() << " == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Could not create proxy with " << listInterfacesIterator->getName() << "\";" << std::endl;
+ this->fs << "\t\t" << listInterfacesIterator->getName() << "prx = jderobot::" << listInterfacesIterator->getInterface() << "Prx::checkedCast(" << listInterfacesIterator->getName() << ");" << std::endl;
+ this->fs << "\t\tif (" << listInterfacesIterator->getName() << "prx == 0)" << std::endl;
+ this->fs << "\t\t\tthrow \"Invalid proxy automata." << listInterfacesIterator->getName() << ".Proxy\";" << std::endl;
+ this->fs << "\t\tstd::cout << \"" << listInterfacesIterator->getName() << " connected\" << std::endl;" << std::endl;
+ this->fs << std::endl;
+ }
- this->fs << "\t\t// Contact to motors (for walking)" << std::endl;
- this->fs << "\t\tIce::ObjectPrx motors = ic->propertyToProxy(\"comp.Motors.Proxy\");" << std::endl;
- this->fs << "\t\tif (motors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with motors\";" << std::endl;
- this->fs << "\t\tmotorsprx = jderobot::MotorsPrx::checkedCast(motors);" << std::endl;
- this->fs << "\t\tif (motorsprx == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.Motors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Motors connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
this->fs.flush();
- this->fs << "\t\t// Contact to motors (for different actions)" << std::endl;
- this->fs << "\t\tIce::ObjectPrx motionsPrx = ic->propertyToProxy(\"comp.Motions.Proxy\");" << std::endl;
- this->fs << "\t\tif (motionsPrx == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with motions\";" << std::endl;
- this->fs << "\t\tmotions = jderobot::NaoMotionsPrx::checkedCast(motionsPrx);" << std::endl;
- this->fs << "\t\tif (motions == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.Motions.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Motions connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs << "\t\t// Contact to head motors" << std::endl;
- this->fs << "\t\tIce::ObjectPrx headmotors = ic->propertyToProxy(\"comp.HeadMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (headmotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with head motors\";" << std::endl;
- this->fs << "\t\thead = jderobot::Pose3DMotorsPrx::checkedCast(headmotors);" << std::endl;
- this->fs << "\t\tif (head == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.HeadMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Head motors connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs << "\t\t// Contact to shoulders motors" << std::endl;
- this->fs << "\t\tIce::ObjectPrx leftshouldermotors = ic->propertyToProxy(\"comp.LeftShoulderMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (leftshouldermotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with left shoulder motors\";" << std::endl;
- this->fs << "\t\tleftshoulder = jderobot::Pose3DMotorsPrx::checkedCast(leftshouldermotors);" << std::endl;
- this->fs << "\t\tif (leftshoulder == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.LeftShoulderMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Left shoulder connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs.flush();
-
- this->fs << "\t\tIce::ObjectPrx rightshouldermotors = ic->propertyToProxy(\"comp.RightShoulderMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (rightshouldermotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with right shoulder motors\";" << std::endl;
- this->fs << "\t\trightshoulder = jderobot::Pose3DMotorsPrx::checkedCast(rightshouldermotors);" << std::endl;
- this->fs << "\t\tif (rightshoulder == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.RightShoulderMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Right shoulder connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs << "\t\t// Contact to elbows motors" << std::endl;
- this->fs << "\t\tIce::ObjectPrx leftelbowmotors = ic->propertyToProxy(\"comp.LeftElbowMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (leftelbowmotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with right elbow motors\";" << std::endl;
- this->fs << "\t\tleftelbow = jderobot::Pose3DMotorsPrx::checkedCast(leftelbowmotors);" << std::endl;
- this->fs << "\t\tif (leftelbow == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.LeftElbowMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Left elbow connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs << "\t\tIce::ObjectPrx rightelbowmotors = ic->propertyToProxy(\"comp.RightElbowMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (rightelbowmotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with right elbow motors\";" << std::endl;
- this->fs << "\t\trightelbow = jderobot::Pose3DMotorsPrx::checkedCast(rightelbowmotors);" << std::endl;
- this->fs << "\t\tif (rightelbow == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.RightElbowMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Right elbow connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs.flush();
-
- this->fs << "\t\t// Contact to hips motors" << std::endl;
- this->fs << "\t\tIce::ObjectPrx lefthipmotors = ic->propertyToProxy(\"comp.LeftHipMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (lefthipmotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with left hip motors\";" << std::endl;
- this->fs << "\t\tlefthip = jderobot::Pose3DMotorsPrx::checkedCast(lefthipmotors);" << std::endl;
- this->fs << "\t\tif (lefthip == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.LeftHipMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Left hip connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs << "\t\tIce::ObjectPrx righthipmotors = ic->propertyToProxy(\"comp.RightHipMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (righthipmotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with right hip motors\";" << std::endl;
- this->fs << "\t\trighthip = jderobot::Pose3DMotorsPrx::checkedCast(righthipmotors);" << std::endl;
- this->fs << "\t\tif (righthip == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.RightHipMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Right hip connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs << "\t\t// Contact to knees motors" << std::endl;
- this->fs << "\t\tIce::ObjectPrx leftkneemotors = ic->propertyToProxy(\"comp.LeftKneeMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (leftkneemotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with left knee motors\";" << std::endl;
- this->fs << "\t\tleftknee = jderobot::Pose3DMotorsPrx::checkedCast(leftkneemotors);" << std::endl;
- this->fs << "\t\tif (leftknee == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.LeftKneeMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Left knee connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs.flush();
-
- this->fs << "\t\tIce::ObjectPrx rightkneemotors = ic->propertyToProxy(\"comp.RightKneeMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (rightkneemotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with right knee motors\";" << std::endl;
- this->fs << "\t\trightknee = jderobot::Pose3DMotorsPrx::checkedCast(rightkneemotors);" << std::endl;
- this->fs << "\t\tif (rightknee == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.RightKneeMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Right knee motors connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs << "\t\t// Contact to ankles motors" << std::endl;
- this->fs << "\t\tIce::ObjectPrx leftanklemotors = ic->propertyToProxy(\"comp.LeftAnkleMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (leftanklemotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with left ankle motors\";" << std::endl;
- this->fs << "\t\tleftankle = jderobot::Pose3DMotorsPrx::checkedCast(leftanklemotors);" << std::endl;
- this->fs << "\t\tif (leftankle == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.LeftAnkleMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Left ankle motors connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs << "\t\tIce::ObjectPrx rightanklemotors = ic->propertyToProxy(\"comp.RightAnkleMotors.Proxy\");" << std::endl;
- this->fs << "\t\tif (rightanklemotors == 0)" << std::endl;
- this->fs << "\t\t\t throw \"Could not create proxy with right ankle motors\";" << std::endl;
- this->fs << "\t\trightankle = jderobot::Pose3DMotorsPrx::checkedCast(rightanklemotors);" << std::endl;
- this->fs << "\t\tif (rightankle == 0)" << std::endl;
- this->fs << "\t\t\tthrow \"Invalid proxy naooperator.RightAnkleMotors.Proxy\";" << std::endl;
- this->fs << "\t\tstd::cout << \"Right ankle motors connected\" << std::endl;" << std::endl;
- this->fs << std::endl;
-
- this->fs.flush();
-
for ( std::list<SubAutomata>::iterator subListIterator = this->subautomataList.begin();
subListIterator != this->subautomataList.end(); subListIterator++ ) {
int id = subListIterator->getId();
@@ -564,19 +423,9 @@
}
void Generate::generateCfg () {
- this->fs << "comp.HeadMotors.Proxy=NeckMotors:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.HeadSpeed.Proxy=NeckSpeed:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.LeftShoulderMotors.Proxy=LeftShoulderMotors:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.RightShoulderMotors.Proxy=RightShoulderMotors:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.LeftElbowMotors.Proxy=LeftElbowMotors:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.RightElbowMotors.Proxy=RightElbowMotors:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.LeftHipMotors.Proxy=LeftHipMotors:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.RightHipMotors.Proxy=RightHipMotors:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.LeftKneeMotors.Proxy=LeftKneeMotors:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.RightKneeMotors.Proxy=RightKneeMotors:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.LeftAnkleMotors.Proxy=LeftAnkleMotors:default -h 192.168.14.113 -p 10000" << std::endl;
- this->fs << "comp.RightAnkleMotors.Proxy=RightAnkleMotors:default -h 192.168.14.113 -p 10000" << std::endl;
-
+ for ( std::list<IceInterface>::iterator listInterfacesIterator = this->listInterfaces->begin();
+ listInterfacesIterator != this->listInterfaces->end(); listInterfacesIterator++ )
+ this->fs << "automata." << listInterfacesIterator->getName() << ".Proxy=" << listInterfacesIterator->getName() << ":default -h " << listInterfacesIterator->getIp() << " -p " << listInterfacesIterator->getPort() << std::endl;
this->fs.flush();
}
Modified: trunk/src/stable/components/visualHFSM/generate.h
===================================================================
--- trunk/src/stable/components/visualHFSM/generate.h 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/generate.h 2013-11-02 19:50:32 UTC (rev 1086)
@@ -26,8 +26,10 @@
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
+#include <algorithm>
#include "subautomata.h"
+#include "iceinterface.h"
typedef enum TabEnum {
T_ZERO,
@@ -44,7 +46,9 @@
// Constructor
Generate ( std::list<SubAutomata> subautomataList, std::string cpppath,
std::string cfgpath, std::string cmakepath,
- std::string configfile );
+ std::list<IceInterface>* listInterfaces,
+ std::map<std::string, std::string> mapInterfacesHeader,
+ std::list<std::string> listLibraries );
// Destructor
virtual ~Generate ();
@@ -54,9 +58,12 @@
private:
std::list<SubAutomata> subautomataList;
- std::string path, cfgpath, cmakepath, configfile;
+ std::string path, cfgpath, cmakepath;
+ std::list<IceInterface>* listInterfaces;
std::fstream fs;
std::map<TabEnum, std::string> mapTab;
+ std::map<std::string, std::string> mapInterfacesHeader;
+ std::list<std::string> listLibraries;
void generateHeaders ();
void generateGenericHeaders ();
Added: trunk/src/stable/components/visualHFSM/getinterfaces.sh
===================================================================
--- trunk/src/stable/components/visualHFSM/getinterfaces.sh (rev 0)
+++ trunk/src/stable/components/visualHFSM/getinterfaces.sh 2013-11-02 19:50:32 UTC (rev 1086)
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+<<LICENSE
+/*
+ * Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+LICENSE
+
+allInterfaces=`egrep -ri interface $1 | awk '{ if ($2 == "interface") print $1 $3 }' | sort`
+for interface in $allInterfaces
+do
+ class=`echo $interface | cut -f1 -d: | cut -f7 -d/ | cut -f1 -d.`
+ theInterface=`echo $interface | cut -f2 -d:`
+ i="$((${#theInterface}-1))"
+ last=${theInterface:$i:1}
+ if [ $last == "{" ]; then
+ echo "${theInterface%?} $class"
+ else
+ echo "$theInterface $class"
+ fi
+done
+
+exit 0
\ No newline at end of file
Property changes on: trunk/src/stable/components/visualHFSM/getinterfaces.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/src/stable/components/visualHFSM/gui/additional_libraries.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/additional_libraries.glade (rev 0)
+++ trunk/src/stable/components/visualHFSM/gui/additional_libraries.glade 2013-11-02 19:50:32 UTC (rev 1086)
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="dialog_additional_libraries">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button_cancel">
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_accept">
+ <property name="label" translatable="yes">Accept</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_homogeneous">True</property>
+ <property name="column_homogeneous">True</property>
+ <child>
+ <object class="GtkLabel" id="label_library_name">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Library name</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_confirm">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Confirm</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_confirm">
+ <property name="label" translatable="yes">Add</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry_name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="placeholder_text">Name</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button_cancel</action-widget>
+ <action-widget response="0">button_accept</action-widget>
+ </action-widgets>
+ </object>
+</interface>
Modified: trunk/src/stable/components/visualHFSM/gui/configfile.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/configfile.glade 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/gui/configfile.glade 2013-11-02 19:50:32 UTC (rev 1086)
@@ -2,13 +2,13 @@
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkDialog" id="dialog_configfile">
- <property name="width_request">640</property>
- <property name="height_request">480</property>
+ <property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
+ <object class="GtkBox" id="dialog-vbox">
+ <property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
@@ -55,28 +55,151 @@
</packing>
</child>
<child>
- <object class="GtkNotebook" id="notebook_configfile">
+ <object class="GtkGrid" id="grid">
<property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="app_paintable">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_homogeneous">True</property>
+ <property name="column_homogeneous">True</property>
<child>
- <object class="GtkTextView" id="textview">
+ <object class="GtkLabel" id="label_name">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Name</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_ip">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">IP</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_port">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Port</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_interface">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Interface</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry_name">
+ <property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="placeholder_text">Name</property>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
</child>
- <child type="tab">
- <object class="GtkLabel" id="label_config">
+ <child>
+ <object class="GtkEntry" id="entry_ip">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="placeholder_text">IP</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry_port">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="placeholder_text">Port</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="combobox_interface">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Configuration</property>
+ <property name="model">liststore1</property>
</object>
<packing>
- <property name="tab_fill">False</property>
+ <property name="left_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label_confirm">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Confirm</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_confirm">
+ <property name="label" translatable="yes">Add</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
@@ -88,4 +211,5 @@
<action-widget response="0">button_accept</action-widget>
</action-widgets>
</object>
+ <object class="GtkListStore" id="liststore1"/>
</interface>
Modified: trunk/src/stable/components/visualHFSM/gui/main_gui.glade
===================================================================
--- trunk/src/stable/components/visualHFSM/gui/main_gui.glade 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/gui/main_gui.glade 2013-11-02 19:50:32 UTC (rev 1086)
@@ -31,6 +31,11 @@
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
+ <object class="GtkImage" id="image15">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-missing-image</property>
+ </object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -61,11 +66,6 @@
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
- <object class="GtkImage" id="image8">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-missing-image</property>
- </object>
<object class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -230,17 +230,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkImageMenuItem" id="imagemenuitem_interfaces">
- <property name="label">_Interfaces</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="image">image8</property>
- <property name="use_stock">False</property>
- </object>
- </child>
- <child>
<object class="GtkImageMenuItem" id="imagemenuitem_timer">
<property name="label">_Timer</property>
<property name="use_action_appearance">False</property>
@@ -277,6 +266,17 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
+ <object class="GtkImageMenuItem" id="imagemenuitem_libraries">
+ <property name="label">Additional _libraries</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="image">image15</property>
+ <property name="use_stock">False</property>
+ </object>
+ </child>
+ <child>
<object class="GtkImageMenuItem" id="imagemenuitem_configfile">
<property name="label">Config _file</property>
<property name="use_action_appearance">False</property>
Modified: trunk/src/stable/components/visualHFSM/guinode.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/guinode.cpp 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/guinode.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -139,7 +139,8 @@
}
bool GuiNode::hasThisItem ( const Glib::RefPtr<Goocanvas::Item>& item ) {
- return ((this->item == item) || (this->itemInitial == item) || (this->itemText == item));
+ Glib::RefPtr<Goocanvas::Item> myItem = item;
+ return ((this->item == myItem) || (this->itemInitial == myItem) || (this->itemText == myItem));
}
void GuiNode::hide () {
Modified: trunk/src/stable/components/visualHFSM/guisubautomata.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/guisubautomata.cpp 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/guisubautomata.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -48,10 +48,6 @@
this->variables = variables;
}
-void GuiSubautomata::setInterfaces ( std::list<std::string>& interfaces ) {
- this->interfaces = interfaces;
-}
-
void GuiSubautomata::setNodeList ( std::list<GuiNode>* list ) {
this->nodeList.clear();
for ( std::list<GuiNode>::iterator nodeListIterator = list->begin();
@@ -66,6 +62,16 @@
this->transitionList.push_back(*transListIterator);
}
+void GuiSubautomata::setToZero ( int idChild ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (nodeListIterator->getIdSubautomataSon() != idChild) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != this->nodeList.end())
+ nodeListIterator->setIdSubautomataSon(0);
+}
+
/*************************************************************
* GETTERS
*************************************************************/
@@ -89,10 +95,6 @@
return this->variables;
}
-std::list<std::string>* GuiSubautomata::getInterfaces () {
- return &this->interfaces;
-}
-
std::list<GuiNode>* GuiSubautomata::getListGuiNodes () {
return &this->nodeList;
}
@@ -101,6 +103,7 @@
return &this->transitionList;
}
+// Get all GuiTransitions with the specified item
std::list<GuiTransition> GuiSubautomata::getAllGuiTransitionsWith (
Glib::RefPtr<Goocanvas::Item> item ) {
std::list<GuiTransition> guiTransitionList;
@@ -115,6 +118,7 @@
return guiTransitionList;
}
+// Get all GuiTransitions with the specified ID
std::list<GuiTransition> GuiSubautomata::getAllGuiTransitionsWith ( int id ) {
std::list<GuiTransition> guiTransitionList;
@@ -129,6 +133,7 @@
return guiTransitionList;
}
+// Get the GuiNode* to the specified item
GuiNode* GuiSubautomata::getGuiNode ( Glib::RefPtr<Goocanvas::Item> item ) {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
while ( (!nodeListIterator->hasThisItem(item)) &&
@@ -141,6 +146,7 @@
return NULL;
}
+// Get the GuiTransition* to the specified item
GuiTransition* GuiSubautomata::getGuiTransition ( Glib::RefPtr<Goocanvas::Item> item ) {
std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
while ( (!nodeTransIterator->hasThisItem(item)) &&
@@ -153,6 +159,7 @@
return NULL;
}
+// Get the point associated to the item, both states and transitions
Point GuiSubautomata::getPoint ( Glib::RefPtr<Goocanvas::Item> item ) {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
while ( (!nodeListIterator->hasThisItem(item)) &&
@@ -173,6 +180,7 @@
/*************************************************************
* ANOTHER FUNCTIONS
*************************************************************/
+// Hide all states and transitions
void GuiSubautomata::hideAll () {
if (DEBUG)
std::cout << BEGIN_GREEN << GUISUB << "Hiding (" << this->id << "). Node list size: " << this->nodeList.size() << END_COLOR << std::endl;
@@ -190,6 +198,7 @@
}
}
+// Show all the states and transitions
void GuiSubautomata::showAll () {
if (DEBUG)
std::cout << BEGIN_GREEN << GUISUB << "Showing (" << this->id << "). Node list size: " << this->nodeList.size() << END_COLOR << std::endl;
@@ -197,7 +206,6 @@
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
while ( nodeListIterator != this->nodeList.end() ) {
nodeListIterator->show();
-// nodeListIterator->isVisible();
nodeListIterator++;
}
@@ -208,6 +216,7 @@
}
}
+// Remove all the states and transitions
void GuiSubautomata::removeAll () {
if (DEBUG)
std::cout << BEGIN_GREEN << GUISUB << "Removing (" << this->id << "). Node list size: " << this->nodeList.size() << END_COLOR << std::endl;
@@ -216,31 +225,45 @@
this->transitionList.clear();
}
-// Is node list empty?
-bool GuiSubautomata::isNodeListEmpty () {
- return this->nodeList.empty();
-}
+// Check if it is all ok
+bool GuiSubautomata::checkAll () {
+ for ( std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ nodeListIterator != this->nodeList.end(); nodeListIterator++ ) {
+ // The name is not empty
+ if (nodeListIterator->getName().compare("") == 0)
+ return false;
-bool GuiSubautomata::findInterface ( std::string interface ) {
- bool found = false;
+ // There are no repeated names
+ std::list<GuiNode>::iterator aux = nodeListIterator;
+ aux++;
+ for ( std::list<GuiNode>::iterator second = aux;
+ second != this->nodeList.end(); second++ ) {
+ if (nodeListIterator->getName().compare(second->getName()) == 0)
+ return false;
+ }
+ }
- std::list<std::string>::iterator interfacesIterator = this->interfaces.begin();
- while ( (!found) && (interfacesIterator != this->interfaces.end()) ) {
- std::size_t pos = interfacesIterator->find(interface);
- found = (pos != std::string::npos);
- interfacesIterator++;
+ // All the transitions have a code
+ for ( std::list<GuiTransition>::iterator transListIterator = this->transitionList.begin();
+ transListIterator != this->transitionList.end(); transListIterator++ ) {
+ if (transListIterator->getCodeTrans().compare("") == 0)
+ return false;
}
- return found;
+ return true;
}
+// Is node list empty?
+bool GuiSubautomata::isNodeListEmpty () {
+ return this->nodeList.empty();
+}
+
void GuiSubautomata::newGuiNode ( int id, int idSubautomataSon, float x, float y ) {
GuiNode gnode(id, idSubautomataSon, x, y);
this->nodeList.push_back(gnode);
-// delete gnode;
}
-// Removes the node with the Goocanvas::Item 'item'
+// Remove the node with the Goocanvas::Item 'item'
void GuiSubautomata::removeGuiNode ( Glib::RefPtr<Goocanvas::Item> item ) {
this->removeGuiTransitionsWith(item);
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
@@ -262,7 +285,7 @@
}
}
-// Removes the node with the id 'id'
+// Remove the node with the id 'id'
void GuiSubautomata::removeGuiNode ( int id ) {
this->removeGuiTransitionsWith(id);
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
@@ -284,7 +307,7 @@
}
}
-// Creates a new GuiTransition
+// Create a new GuiTransition
void GuiSubautomata::newGuiTransition ( Point origin, Point final, int id ) {
GuiTransition gtransition(origin, final, id);
this->transitionList.push_back(gtransition);
@@ -295,6 +318,7 @@
this->transitionList.push_back(gtransition);
}
+// Remove a GuiTransition with the specified item
void GuiSubautomata::removeGuiTransitionsWith ( Glib::RefPtr<Goocanvas::Item> item ) {
std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
while (nodeTransIterator != this->transitionList.end()) {
@@ -306,6 +330,7 @@
}
}
+// Remove a GuiTransition with the specified ID
void GuiSubautomata::removeGuiTransitionsWith ( int id ) {
std::list<GuiTransition>::iterator nodeTransIterator = this->transitionList.begin();
while (nodeTransIterator != this->transitionList.end()) {
@@ -318,6 +343,7 @@
}
}
+// Copy a subautomata
GuiSubautomata GuiSubautomata::copy () {
std::list<GuiNode> gnodelist;
for ( std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
@@ -333,7 +359,6 @@
gsubautomata.setFunctions(std::string(this->functions));
gsubautomata.setTime(std::string(this->timing));
gsubautomata.setVariables(std::string(this->variables));
- gsubautomata.setInterfaces(this->interfaces);
gsubautomata.setNodeList(&gnodelist);
gsubautomata.setTransList(>ranslist);
@@ -347,7 +372,7 @@
/*************************************************************
* SETTERS FOR NODES
*************************************************************/
-// Sets the items for a node with the Goocanvas::Item 'item'
+// Set the items for a node with the Goocanvas::Item 'item'
void GuiSubautomata::setGuiNodeItems ( const Glib::RefPtr<Goocanvas::Item>& item,
Glib::RefPtr<Goocanvas::Item> selectedItem,
Glib::RefPtr<Goocanvas::Item> textItem ) {
@@ -356,6 +381,7 @@
nodeListIterator->setItems(item, selectedItem, textItem);
}
+// Set the ID of the subautomata son of the specified item
void GuiSubautomata::setIdSubautomataSon ( int id, const Glib::RefPtr<Goocanvas::Item>& item ) {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
while ( (!nodeListIterator->hasThisItem(item)) &&
@@ -405,6 +431,19 @@
return nodeListIterator->getText();
}
+std::string GuiSubautomata::getGuiNodeName ( const Glib::RefPtr<Goocanvas::Item>& item ) {
+ std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
+ while ( (!nodeListIterator->hasThisItem(item)) &&
+ (nodeListIterator != this->nodeList.end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator == this->nodeList.end())
+ std::cout << "en el end!!!" << std::endl;
+ std::cout << "returning " << nodeListIterator->getName() << std::endl;
+
+ return nodeListIterator->getName();
+}
+
std::string GuiSubautomata::getLastGuiNodeName () {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.end();
nodeListIterator--;
@@ -420,7 +459,7 @@
return nodeListIterator->getItem();
}
-int GuiSubautomata::getGuinodeId ( Glib::RefPtr<Goocanvas::Item> item ) {
+int GuiSubautomata::getGuinodeId ( const Glib::RefPtr<Goocanvas::Item>& item ) {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
while ( (!nodeListIterator->hasThisItem(item)) &&
(nodeListIterator != this->nodeList.end()) )
@@ -448,7 +487,7 @@
/*************************************************************
* ANOTHER FUNCTIONS FOR NODES
*************************************************************/
-// Changes the node width with the Goocanvas::Item 'item'
+// Change the node width with the Goocanvas::Item 'item'
void GuiSubautomata::changeGuiNodeWidth ( const Glib::RefPtr<Goocanvas::Item>& item, float width ) {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
while ( (!nodeListIterator->hasThisItem(item)) &&
@@ -468,7 +507,7 @@
nodeListIterator->setAsInitial(false);
}
-// Edits the node with the Goocanvas::Item 'item'
+// Edit the node with the Goocanvas::Item 'item'
void GuiSubautomata::editGuiNode ( Glib::RefPtr<Goocanvas::Item> item ) {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
while ( (!nodeListIterator->hasThisItem(item)) && (nodeListIterator != this->nodeList.end()) )
@@ -483,7 +522,7 @@
}
}
-// Marks the node with the Goocanvas::Item 'item' as initial
+// Mark the node with the Goocanvas::Item 'item' as initial
// If there is another node marked as initial, it first removes that mark
void GuiSubautomata::markGuiNodeAsInitial ( Glib::RefPtr<Goocanvas::Item> item ) {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
@@ -504,7 +543,7 @@
}
}
-// Moves the node (all its items)
+// Move the node (all its items)
void GuiSubautomata::moveGuiNode ( const Glib::RefPtr<Goocanvas::Item>& item,
double dx, double dy ) {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
@@ -516,7 +555,7 @@
nodeListIterator->moveItems(dx, dy);
}
-// Renames the node with the Goocanvas::Item 'item'
+// Rename the node with the Goocanvas::Item 'item'
void GuiSubautomata::renameGuiNode ( Glib::RefPtr<Goocanvas::Item> item ) {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
while ( (!nodeListIterator->hasThisItem(item)) && (nodeListIterator != this->nodeList.end()) )
@@ -654,7 +693,7 @@
}
}
-// Moves the transitions of the item (all its items)
+// Move the transitions of the item (all its items)
void GuiSubautomata::moveGuiTransition ( const Glib::RefPtr<Goocanvas::Item>& item ) {
std::list<GuiNode>::iterator nodeListIterator = this->nodeList.begin();
while ( (!nodeListIterator->hasThisItem(item)) &&
Modified: trunk/src/stable/components/visualHFSM/guisubautomata.h
===================================================================
--- trunk/src/stable/components/visualHFSM/guisubautomata.h 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/guisubautomata.h 2013-11-02 19:50:32 UTC (rev 1086)
@@ -45,18 +45,18 @@
void setFunctions ( std::string functions );
void setTime ( std::string timing );
void setVariables ( std::string variables );
- void setInterfaces ( std::list<std::string>& interfaces );
void setNodeList ( std::list<GuiNode>* list );
void setTransList ( std::list<GuiTransition>* list );
+ void setToZero ( int idChild );
+
// Getters
int getId ();
int getIdFather ();
std::string getFunctions ();
std::string getTime ();
std::string getVariables ();
- std::list<std::string>* getInterfaces ();
std::list<GuiNode>* getListGuiNodes ();
std::list<GuiTransition>* getListGuiTransitions ();
std::list<GuiTransition> getAllGuiTransitionsWith ( Glib::RefPtr<Goocanvas::Item> item );
@@ -70,8 +70,8 @@
void hideAll ();
void showAll ();
void removeAll ();
+ bool checkAll ();
bool isNodeListEmpty ();
- bool findInterface ( std::string interface );
void newGuiNode ( int id, int idSubautomataSon, float x, float y );
void removeGuiNode ( Glib::RefPtr<Goocanvas::Item> item );
void removeGuiNode ( int id );
@@ -97,11 +97,12 @@
Glib::RefPtr<Goocanvas::EllipseModel> getLastEllipseInit ();
Glib::RefPtr<Goocanvas::TextModel> getLastTextNode ();
+ std::string getGuiNodeName ( const Glib::RefPtr<Goocanvas::Item>& item );
std::string getLastGuiNodeName ();
int getLastGuiNodeIdFatherState ();
Glib::RefPtr<Goocanvas::Item> getGuiNodeItem ( int id );
- int getGuinodeId ( Glib::RefPtr<Goocanvas::Item> item );
+ int getGuinodeId ( const Glib::RefPtr<Goocanvas::Item>& item );
int getFirstIdNode ();
@@ -148,7 +149,6 @@
// Data structure
int id, idFather;
std::string timing, variables, functions, config;
- std::list<std::string> interfaces;
std::list<GuiNode> nodeList;
std::list<GuiTransition> transitionList;
}; // Class GuiSubautomata
Modified: trunk/src/stable/components/visualHFSM/guitransition.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/guitransition.cpp 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/guitransition.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -343,9 +343,6 @@
Point origin = leftpoint.calculateGoodArrowPosition(this->point);
Point final = rightpoint.calculateGoodArrowPosition(this->point);
-
-// std::cout << "point.x: " << this->point.getX() << std::endl;
-// std::cout << "point.y: " << this->point.getY() << std::endl;
this->moveLeftItem(0, origin.getX(), origin.getY());
this->moveLeftItem(1, this->point.getX(), this->point.getY());
Added: trunk/src/stable/components/visualHFSM/iceinterface.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/iceinterface.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/iceinterface.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "iceinterface.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+IceInterface::IceInterface () {}
+
+IceInterface::IceInterface ( std::string name, std::string ip, std::string port, std::string interface ) {
+ this->name = name;
+ this->ip = ip;
+ this->port = port;
+ this->interface = interface;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+IceInterface::~IceInterface () {}
+
+/*************************************************************
+ * SETTERS
+ *************************************************************/
+void IceInterface::setAll ( std::string name, std::string ip, std::string port, std::string interface ) {
+ this->name = name;
+ this->ip = ip;
+ this->port = port;
+ this->interface = interface;
+}
+
+void IceInterface::setName ( std::string name ) {
+ this->name = name;
+}
+
+void IceInterface::setIp ( std::string ip ) {
+ this->ip = ip;
+}
+
+void IceInterface::setPort ( std::string port ) {
+ this->port = port;
+}
+
+void IceInterface::setInterface ( std::string interface ) {
+ this->interface = interface;
+}
+
+/*************************************************************
+ * GETTERS
+ *************************************************************/
+std::string IceInterface::getName () {
+ return this->name;
+}
+
+std::string IceInterface::getIp () {
+ return this->ip;
+}
+
+std::string IceInterface::getPort () {
+ return this->port;
+}
+
+std::string IceInterface::getInterface () {
+ return this->interface;
+}
+
+/*************************************************************
+ * ANOTHER FUNCTIONS
+ *************************************************************/
+bool IceInterface::equals ( IceInterface* iceinterface ) {
+ return (this->name.compare(iceinterface->getName()) == 0);
+}
+
+bool IceInterface::equals ( std::string name, std::string ip,
+ std::string port, std::string interface ) {
+ return ( (this->name.compare(name) == 0) && (this->ip.compare(ip) == 0) &&
+ (this->port.compare(port) == 0) && (this->interface.compare(interface) == 0) );
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/iceinterface.h
===================================================================
--- trunk/src/stable/components/visualHFSM/iceinterface.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/iceinterface.h 2013-11-02 19:50:32 UTC (rev 1086)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef ICEINTERFACE_H
+#define ICEINTERFACE_H
+
+#include <iostream>
+#include <stdio.h>
+
+class IceInterface {
+public:
+ // Constructor
+ IceInterface ();
+ IceInterface ( std::string name, std::string ip, std::string port, std::string interface );
+
+ // Destructor
+ virtual ~IceInterface ();
+
+ // Setters
+ void setAll ( std::string name, std::string ip, std::string port, std::string interface );
+ void setName ( std::string name );
+ void setIp ( std::string ip );
+ void setPort ( std::string port );
+ void setInterface ( std::string interface );
+
+ // Getters
+ std::string getName ();
+ std::string getIp ();
+ std::string getPort ();
+ std::string getInterface ();
+
+ // Another functions
+ bool equals ( IceInterface* iceinterface );
+ bool equals ( std::string name, std::string ip, std::string port, std::string interface );
+
+private:
+ std::string name, ip, port, interface;
+};
+
+#endif // ICEINTERFACE_H
\ No newline at end of file
Modified: trunk/src/stable/components/visualHFSM/popups/configfiledialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/configfiledialog.cpp 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/popups/configfiledialog.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -23,8 +23,10 @@
/*************************************************************
* CONSTRUCTOR
*************************************************************/
-ConfigFileDialog::ConfigFileDialog ( std::string config ) {
- this->configfile = std::string(config);
+ConfigFileDialog::ConfigFileDialog ( std::list<IceInterface>& listInterfaces, std::map<std::string, std::string> mapInterfacesHeader ) {
+ this->listInterfaces = listInterfaces;
+ this->mapInterfacesHeader = mapInterfacesHeader;
+ this->row = 2;
}
/*************************************************************
@@ -55,15 +57,52 @@
if (fine) {
refBuilder->get_widget("dialog_configfile", this->dialog);
- refBuilder->get_widget("textview", this->textview);
+ refBuilder->get_widget("grid", this->grid);
+ refBuilder->get_widget("entry_name", this->entry_name);
+ refBuilder->get_widget("entry_ip", this->entry_ip);
+ refBuilder->get_widget("entry_port", this->entry_port);
+ refBuilder->get_widget("combobox_interface", this->combobox_interface);
+ refBuilder->get_widget("button_confirm", this->button_confirm);
refBuilder->get_widget("button_accept", this->button_accept);
refBuilder->get_widget("button_cancel", this->button_cancel);
- Glib::RefPtr<Gtk::TextBuffer> textbufferConfig = Gtk::TextBuffer::create();
- textbufferConfig->set_text(this->configfile);
- this->textview->set_buffer(textbufferConfig);
+ this->refTreeModel = Gtk::ListStore::create(this->m_Columns);
+ this->combobox_interface->set_model(this->refTreeModel);
+ Gtk::TreeModel::Row row;
+ for ( std::map<std::string, std::string>::iterator mapIterator = this->mapInterfacesHeader.begin();
+ mapIterator != this->mapInterfacesHeader.end(); mapIterator++ ) {
+ row = *(this->refTreeModel->append());
+ row[m_Columns.m_col_name] = mapIterator->first;
+ }
+
+ this->combobox_interface->pack_start(m_Columns.m_col_name);
+
+ for ( std::list<IceInterface>::iterator listInterfaceIterator = this->listInterfaces.begin();
+ listInterfaceIterator != this->listInterfaces.end(); listInterfaceIterator++ ) {
+ Gtk::Label* label_name = Gtk::manage(new Gtk::Label(listInterfaceIterator->getName()));
+ Gtk::Label* label_ip = Gtk::manage(new Gtk::Label(listInterfaceIterator->getIp()));
+ Gtk::Label* label_port = Gtk::manage(new Gtk::Label(listInterfaceIterator->getPort()));
+ Gtk::Label* label_interface = Gtk::manage(new Gtk::Label(listInterfaceIterator->getInterface()));
+ Gtk::Button* button = Gtk::manage(new Gtk::Button("Delete"));
+
+ button->signal_clicked().connect(sigc::bind(
+ sigc::mem_fun(this, &ConfigFileDialog::on_button_delete), this->row));
+
+ this->grid->attach(*label_name, 0, this->row, 1, 1);
+ this->grid->attach(*label_ip, 1, this->row, 1, 1);
+ this->grid->attach(*label_port, 2, this->row, 1, 1);
+ this->grid->attach(*label_interface, 3, this->row, 1, 1);
+ this->grid->attach(*button, 4, this->row, 1, 1);
+
+ this->row++;
+ }
+
+ this->grid->show_all_children();
+
+ this->button_confirm->signal_clicked().connect(sigc::mem_fun(this,
+ &ConfigFileDialog::on_button_confirm));
this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
&ConfigFileDialog::on_button_accept));
this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
@@ -76,10 +115,61 @@
/*************************************************************
* PRIVATE METHODS
*************************************************************/
+void ConfigFileDialog::on_button_confirm () {
+ Glib::ustring name;
+ Gtk::TreeModel::iterator iter = this->combobox_interface->get_active();
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ name = row[m_Columns.m_col_name];
+ } else
+ std::cout << "Invalid iter" << std::endl;
+
+ IceInterface iceinterface(std::string(this->entry_name->get_text()),
+ std::string(this->entry_ip->get_text()),
+ std::string(this->entry_port->get_text()),
+ std::string(name));
+ this->listInterfaces.push_back(iceinterface);
+
+ Gtk::Label* label_name = Gtk::manage(new Gtk::Label(this->entry_name->get_text()));
+ Gtk::Label* label_ip = Gtk::manage(new Gtk::Label(this->entry_ip->get_text()));
+ Gtk::Label* label_port = Gtk::manage(new Gtk::Label(this->entry_port->get_text()));
+ Gtk::Label* label_interface = Gtk::manage(new Gtk::Label(name));
+ Gtk::Button* button = Gtk::manage(new Gtk::Button("Delete"));
+
+ button->signal_clicked().connect(sigc::bind(
+ sigc::mem_fun(this, &ConfigFileDialog::on_button_delete), this->row));
+
+ this->grid->attach(*label_name, 0, this->row, 1, 1);
+ this->grid->attach(*label_ip, 1, this->row, 1, 1);
+ this->grid->attach(*label_port, 2, this->row, 1, 1);
+ this->grid->attach(*label_interface, 3, this->row, 1, 1);
+ this->grid->attach(*button, 4, this->row, 1, 1);
+
+ this->grid->show_all_children();
+
+ this->row++;
+}
+
+void ConfigFileDialog::on_button_delete ( int row ) {
+ std::map<int, std::string> mapNames;
+ for ( int i = 0; i < 5; i++ ) {
+ if (i != 4)
+ mapNames[i] = std::string(((Gtk::Label*)this->grid->get_child_at(i, row))->get_text());
+ this->grid->remove(*this->grid->get_child_at(i, row));
+ }
+
+ std::list<IceInterface>::iterator listInterfacesIterator = this->listInterfaces.begin();
+ while ( (!listInterfacesIterator->equals(mapNames[0], mapNames[1], mapNames[2], mapNames[3])) &&
+ (listInterfacesIterator != this->listInterfaces.end()) )
+ listInterfacesIterator++;
+
+ if (listInterfacesIterator != this->listInterfaces.end())
+ this->listInterfaces.erase(listInterfacesIterator);
+}
+
void ConfigFileDialog::on_button_accept () {
- this->configfile = this->textview->get_buffer()->get_text();
delete this->dialog;
- this->m_signal.emit(this->configfile);
+ this->m_signal.emit(this->listInterfaces);
}
void ConfigFileDialog::on_button_cancel () {
Modified: trunk/src/stable/components/visualHFSM/popups/configfiledialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/configfiledialog.h 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/popups/configfiledialog.h 2013-11-02 19:50:32 UTC (rev 1086)
@@ -23,16 +23,19 @@
#include <iostream>
#include <stdio.h>
+#include <fstream>
+#include <sstream>
#include <gtkmm-3.0/gtkmm.h>
#include <sigc++/sigc++.h>
#include "../common.h"
+#include "../iceinterface.h"
// Definition of this class
class ConfigFileDialog {
public:
// Constructor
- ConfigFileDialog ( std::string config );
+ ConfigFileDialog ( std::list<IceInterface>& listInterfaces, std::map<std::string, std::string> mapInterfacesHeader );
// Destructor
virtual ~ConfigFileDialog ();
@@ -41,19 +44,34 @@
void init ();
//signal accessor:
- typedef sigc::signal<void, std::string> type_signal;
+ typedef sigc::signal<void, std::list<IceInterface>& > type_signal;
type_signal signal_config ();
private:
// Data structure
Gtk::Dialog* dialog;
- Gtk::Button* button_accept;
- Gtk::Button* button_cancel;
- Gtk::TextView *textview;
+ Gtk::Button *button_accept, *button_cancel, *button_confirm;
+ Gtk::Grid* grid;
+ Gtk::Entry *entry_name, *entry_ip, *entry_port;
+ Gtk::ComboBox* combobox_interface;
- std::string configfile;
+ int row;
+ std::list<IceInterface> listInterfaces;
+ std::map<std::string, std::string> mapInterfacesHeader;
+
+ class ModelColumns : public Gtk::TreeModel::ColumnRecord {
+ public:
+ ModelColumns () { add(m_col_name); }
+
+ Gtk::TreeModelColumn<Glib::ustring> m_col_name;
+ };
+ ModelColumns m_Columns;
+
+ Glib::RefPtr<Gtk::ListStore> refTreeModel;
// Private methods
+ void on_button_confirm ();
+ void on_button_delete ( int row );
void on_button_accept ();
void on_button_cancel ();
Added: trunk/src/stable/components/visualHFSM/popups/librariesdialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/librariesdialog.cpp (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/librariesdialog.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#include "librariesdialog.h"
+
+/*************************************************************
+ * CONSTRUCTOR
+ *************************************************************/
+LibrariesDialog::LibrariesDialog ( std::list<std::string> listLibraries ) {
+ this->listLibraries = listLibraries;
+ this->row = 2;
+}
+
+/*************************************************************
+ * DESTRUCTOR
+ *************************************************************/
+LibrariesDialog::~LibrariesDialog () {}
+
+/*************************************************************
+ * POPUP INITIALIZER
+ *************************************************************/
+void LibrariesDialog::init () {
+ bool fine = true;
+ // Load the GtkBuilder file and instantiate its widgets:
+ Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create();
+ try {
+ refBuilder->add_from_file("gui/additional_libraries.glade");
+ } catch (const Glib::FileError& ex) {
+ std::cerr << BEGIN_RED << "FileError: " << ex.what() << END_COLOR << std::endl;
+ fine = false;
+ } catch(const Glib::MarkupError& ex) {
+ std::cerr << BEGIN_RED << "MarkupError: " << ex.what() << END_COLOR << std::endl;
+ fine = false;
+ } catch(const Gtk::BuilderError& ex) {
+ std::cerr << BEGIN_RED << "BuilderError: " << ex.what() << END_COLOR << std::endl;
+ fine = false;
+ }
+
+ if (fine) {
+ refBuilder->get_widget("dialog_additional_libraries", this->dialog);
+
+ refBuilder->get_widget("grid", this->grid);
+ refBuilder->get_widget("entry_name", this->entry_name);
+ refBuilder->get_widget("button_confirm", this->button_confirm);
+
+ refBuilder->get_widget("button_accept", this->button_accept);
+ refBuilder->get_widget("button_cancel", this->button_cancel);
+
+ for ( std::list<std::string>::iterator listLibrariesIterator = this->listLibraries.begin();
+ listLibrariesIterator != this->listLibraries.end(); listLibrariesIterator++ ) {
+ Gtk::Label* label_name = Gtk::manage(new Gtk::Label(*listLibrariesIterator));
+ Gtk::Button* button = Gtk::manage(new Gtk::Button("Delete"));
+
+ button->signal_clicked().connect(sigc::bind(
+ sigc::mem_fun(this, &LibrariesDialog::on_button_delete), this->row));
+
+ this->grid->attach(*label_name, 0, this->row, 1, 1);
+ this->grid->attach(*button, 1, this->row, 1, 1);
+
+ this->row++;
+ }
+
+ this->grid->show_all_children();
+
+ this->button_confirm->signal_clicked().connect(sigc::mem_fun(this,
+ &LibrariesDialog::on_button_confirm));
+ this->button_accept->signal_clicked().connect(sigc::mem_fun(this,
+ &LibrariesDialog::on_button_accept));
+ this->button_cancel->signal_clicked().connect(sigc::mem_fun(this,
+ &LibrariesDialog::on_button_cancel));
+
+ this->dialog->show_now();
+ }
+}
+
+/*************************************************************
+ * PRIVATE METHODS
+ *************************************************************/
+void LibrariesDialog::on_button_confirm () {
+ this->listLibraries.push_back(this->entry_name->get_text());
+
+ Gtk::Label* label_name = Gtk::manage(new Gtk::Label(this->entry_name->get_text()));
+ Gtk::Button* button = Gtk::manage(new Gtk::Button("Delete"));
+
+ button->signal_clicked().connect(sigc::bind(
+ sigc::mem_fun(this, &LibrariesDialog::on_button_delete), this->row));
+
+ this->grid->attach(*label_name, 0, this->row, 1, 1);
+ this->grid->attach(*button, 1, this->row, 1, 1);
+
+ this->grid->show_all_children();
+
+ this->row++;
+}
+
+void LibrariesDialog::on_button_delete ( int row ) {
+ std::string label(((Gtk::Label*)this->grid->get_child_at(0, row))->get_text());
+ std::list<std::string>::iterator listLibrariesIterator = this->listLibraries.begin();
+ while ( (listLibrariesIterator != this->listLibraries.end()) &&
+ (listLibrariesIterator->compare(label) == 0) )
+ listLibrariesIterator++;
+
+ if (listLibrariesIterator != this->listLibraries.end())
+ this->listLibraries.erase(listLibrariesIterator);
+
+ for (int i = 0; i < 2; i++)
+ this->grid->remove(*this->grid->get_child_at(i, row));
+}
+
+void LibrariesDialog::on_button_accept () {
+ delete this->dialog;
+ this->m_signal.emit(this->listLibraries);
+}
+
+void LibrariesDialog::on_button_cancel () {
+ delete this->dialog;
+}
+
+LibrariesDialog::type_signal LibrariesDialog::signal_libraries () {
+ return m_signal;
+}
\ No newline at end of file
Added: trunk/src/stable/components/visualHFSM/popups/librariesdialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/librariesdialog.h (rev 0)
+++ trunk/src/stable/components/visualHFSM/popups/librariesdialog.h 2013-11-02 19:50:32 UTC (rev 1086)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors : Borja Menéndez <borjamonserrano en gmail.com>
+ *
+ */
+
+#ifndef LIBRARIESDIALOG_H
+#define LIBRARIESDIALOG_H
+
+#include <iostream>
+#include <stdio.h>
+#include <fstream>
+#include <sstream>
+#include <gtkmm-3.0/gtkmm.h>
+#include <sigc++/sigc++.h>
+
+#include "../common.h"
+
+// Definition of this class
+class LibrariesDialog {
+public:
+ // Constructor
+ LibrariesDialog ( std::list<std::string> listLibraries );
+
+ // Destructor
+ virtual ~LibrariesDialog ();
+
+ // Popup initializer
+ void init ();
+
+ // signal accessor:
+ typedef sigc::signal<void, std::list<std::string> > type_signal;
+ type_signal signal_libraries ();
+
+private:
+ // Data structure
+ Gtk::Dialog* dialog;
+ Gtk::Button *button_accept, *button_cancel, *button_confirm;
+ Gtk::Grid* grid;
+ Gtk::Entry* entry_name;
+
+ int row;
+ std::list<std::string> listLibraries;
+
+ // Private methods
+ void on_button_confirm ();
+ void on_button_delete ( int row );
+ void on_button_accept ();
+ void on_button_cancel ();
+
+ type_signal m_signal;
+};
+
+#endif // LIBRARIESDIALOG_H
\ No newline at end of file
Modified: trunk/src/stable/components/visualHFSM/popups/renamedialog.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/renamedialog.cpp 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/popups/renamedialog.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -77,7 +77,10 @@
*************************************************************/
void RenameDialog::on_button_accept () {
this->gnode->changeText(this->entry_text->get_text());
+ int id = this->gnode->getId();
+ std::string name = this->gnode->getName();
delete this->dialog;
+ this->m_signal.emit(id, name);
}
void RenameDialog::on_button_cancel () {
@@ -89,4 +92,8 @@
this->on_button_accept();
return true;
+}
+
+RenameDialog::type_signal RenameDialog::signal_change_node () {
+ return m_signal;
}
\ No newline at end of file
Modified: trunk/src/stable/components/visualHFSM/popups/renamedialog.h
===================================================================
--- trunk/src/stable/components/visualHFSM/popups/renamedialog.h 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/popups/renamedialog.h 2013-11-02 19:50:32 UTC (rev 1086)
@@ -21,6 +21,8 @@
#ifndef RENAMEDIALOG_H
#define RENAMEDIALOG_H
+#include <sigc++/sigc++.h>
+
#include "../guinode.h"
// Definition of this class
@@ -35,6 +37,10 @@
// Popup initializer
void init ();
+ // signal accessor:
+ typedef sigc::signal<void, int, std::string> type_signal;
+ type_signal signal_change_node ();
+
protected:
// Data structure
GuiNode* gnode;
@@ -47,6 +53,8 @@
void on_button_accept ();
void on_button_cancel ();
bool on_key_released ( GdkEventKey* event );
+
+ type_signal m_signal;
};
#endif // RENAMEDIALOG_H
\ No newline at end of file
Modified: trunk/src/stable/components/visualHFSM/savefile.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/savefile.cpp 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/savefile.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -23,10 +23,13 @@
/*************************************************************
* CONSTRUCTOR
*************************************************************/
-SaveFile::SaveFile ( std::string filepath, std::list<GuiSubautomata>* subautomataList, std::string config ) {
+SaveFile::SaveFile ( std::string filepath, std::list<GuiSubautomata>* subautomataList,
+ std::list<IceInterface>& listInterfaces,
+ std::list<std::string> listLibraries ) {
this->filepath = std::string(filepath);
this->subautomataList = subautomataList;
- this->config = std::string(config);
+ this->listInterfaces = listInterfaces;
+ this->listLibraries = listLibraries;
}
/*************************************************************
@@ -132,27 +135,41 @@
nodeTransChild->set_child_text(guiTransIterator->getCodeTrans());
}
- xmlpp::Element* nodeLibs = nodeSubautomata->add_child("libraries");
- std::list<std::string>* listLibs = subListIterator->getInterfaces();
- for ( std::list<std::string>::iterator listLibsIterator = listLibs->begin();
- listLibsIterator != listLibs->end(); listLibsIterator++ ) {
- xmlpp::Element* nodelib = nodeLibs->add_child("lib");
- nodelib->set_child_text(*listLibsIterator);
- }
+ xmlpp::Element* nodeChildSubautomata = nodeSubautomata->add_child("iteration_time");
+ nodeChildSubautomata->set_child_text(subListIterator->getTime());
- xmlpp::Element* nodeTiming = nodeSubautomata->add_child("iteration_time");
- nodeTiming->set_child_text(subListIterator->getTime());
+ nodeChildSubautomata = nodeSubautomata->add_child("variables");
+ nodeChildSubautomata->set_child_text(subListIterator->getVariables());
- xmlpp::Element* nodeVariables = nodeSubautomata->add_child("variables");
- nodeVariables->set_child_text(subListIterator->getVariables());
+ nodeChildSubautomata = nodeSubautomata->add_child("functions");
+ nodeChildSubautomata->set_child_text(subListIterator->getFunctions());
+ }
- xmlpp::Element* nodeFunctions = nodeSubautomata->add_child("functions");
- nodeFunctions->set_child_text(subListIterator->getFunctions());
+ xmlpp::Element* nodeLibs = nodeRoot->add_child("libraries");
+ for ( std::list<std::string>::iterator listLibsIterator = this->listLibraries.begin();
+ listLibsIterator != this->listLibraries.end(); listLibsIterator++ ) {
+ xmlpp::Element* nodelib = nodeLibs->add_child("lib");
+ nodelib->set_child_text(*listLibsIterator);
}
xmlpp::Element* nodeConfig = nodeRoot->add_child("config");
- nodeConfig->set_child_text(this->config);
+ for ( std::list<IceInterface>::iterator listInterfacesIterator = this->listInterfaces.begin();
+ listInterfacesIterator != this->listInterfaces.end(); listInterfacesIterator++ ) {
+ xmlpp::Element* nodeIceInterface = nodeConfig->add_child("iceinterface");
+ xmlpp::Element* nodeConfigChild = nodeIceInterface->add_child("nameinterface");
+ nodeConfigChild->set_child_text(listInterfacesIterator->getName());
+
+ nodeConfigChild = nodeIceInterface->add_child("ip");
+ nodeConfigChild->set_child_text(listInterfacesIterator->getIp());
+
+ nodeConfigChild = nodeIceInterface->add_child("port");
+ nodeConfigChild->set_child_text(listInterfacesIterator->getPort());
+
+ nodeConfigChild = nodeIceInterface->add_child("interface");
+ nodeConfigChild->set_child_text(listInterfacesIterator->getInterface());
+ }
+
document.write_to_file(this->filepath, "UTF-8");
#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
Modified: trunk/src/stable/components/visualHFSM/savefile.h
===================================================================
--- trunk/src/stable/components/visualHFSM/savefile.h 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/savefile.h 2013-11-02 19:50:32 UTC (rev 1086)
@@ -24,12 +24,14 @@
#include <libxml++/libxml++.h>
#include "guisubautomata.h"
+#include "iceinterface.h"
// Definition of this class
class SaveFile {
public:
// Constructor
- SaveFile ( std::string filepath, std::list<GuiSubautomata>* subautomataList, std::string config );
+ SaveFile ( std::string filepath, std::list<GuiSubautomata>* subautomataList,
+ std::list<IceInterface>& listInterfaces, std::list<std::string> listLibraries );
// Destructor
virtual ~SaveFile ();
@@ -39,8 +41,10 @@
private:
// Data structure
- std::string filepath, config;
+ std::string filepath;
+ std::list<IceInterface> listInterfaces;
std::list<GuiSubautomata>* subautomataList;
+ std::list<std::string> listLibraries;
};
#endif // SAVEFILE_H
\ No newline at end of file
Deleted: trunk/src/stable/components/visualHFSM/tipos.h
===================================================================
--- trunk/src/stable/components/visualHFSM/tipos.h 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/tipos.h 2013-11-02 19:50:32 UTC (rev 1086)
@@ -1,100 +0,0 @@
-#ifndef TIPOS_H
-#define TIPOS_H
-
-#include <libgnomecanvas/libgnomecanvas.h>
-#include <list>
-#include <string>
-using namespace std;
-
-typedef struct punto {
- double x;
- double y;
-} punto;
-
-typedef struct recta {
- double A;
- double B;
- double C;
-} recta;
-
-
-typedef struct tipoNodo {
-
- GnomeCanvasItem * item;
- GnomeCanvasItem * estado_inicial;
-// int origenX, origenY; // Punto (x,y) donde se dibujara en el canvas
-// int destinoX, destinoY; // Punto (x,y) donde se dibujara en el canvas
- string nombre; // Nombre del nodo. "" por defecto
- string codigo; // Codigo del estado
- GnomeCanvasItem * item_nombre; // item que muestra el nombre del estado
- list <GnomeCanvasItem *> listaAdyacentes; // Para estados -- Lista de lineas adyacentes
- int idHijo; //Id. que indica el subautomata dentro de la lista de subautomatas que se corresponde con el hijo de este estado
-} tNodo;
-
-typedef struct tipoTransicion {
- //int id;
- GnomeCanvasItem * item; // Item que representa la transición. Está formado a su vez por 3 item: 2 líneas y un punto de acción en la unión de ambas (box).
- // Posicion 0 inicio recta, posicion 1 final recta, posicion 2 box.
- //int origenX, origenY;
- //int destinoX, destinoY;
- //double pMedioX, pMedioY; // Posición del punto de acción de la transición.
- GnomeCanvasItem * origen; // Nodo origen
- GnomeCanvasItem * destino; // Nodo destino
- string nombre; // Nombre de la transicion. "" por defecto
- GnomeCanvasItem * item_nombre; // Item del nombre de la transición.
- //GnomeCanvasItem * orientacion; // Triangulo flecha
- string codigo;
- int tiempo;
-} tTransicion;
-
-extern list <tNodo> ListaElementos;
-extern list <tTransicion> ListaTransiciones;
-
-typedef struct transicion_aux { // Transiciones temporales. Usadas para pintar las transiciones despues de cargar un fichero.
- GnomeCanvasItem *origen;
- GnomeCanvasItem *destino;
- int origen_xml;
- int destino_id;
- int tiempo;
- string codigo;
- string nombre;
- GnomeCanvasItem *item;
-} transicion_aux;
-
-typedef struct importar {
- bool laser;
- bool motor;
- bool radar;
- bool encoders;
- bool lat_lon;
- bool camara;
- bool ptencoders;
-} importar;
-
-
-typedef enum TYPE_VENTANA {
- NOMBRAR,
- EDITAR,
- CODIGO,
- LIBRERIAS,
- TIMER
-}tVentana;
-
-typedef struct nodoVentana {
- GnomeCanvasItem * item; // item correspondiente a la ventana
- tVentana tipo; // Nombre del nodo. "" por defecto
- GtkWidget *ventana; // Ventana
-} nVentana;
-
-typedef struct tSubAut {
- list <tNodo> ListaElementosSub;
- list <tTransicion> ListaTransicionesSub;
- int tiempoIteracionSub;
- string variablesSub;
- string funcionesSub;
- importar impSub;
- int idSub;
- int idPadre;
-} tSubAut;
-
-#endif
Modified: trunk/src/stable/components/visualHFSM/visualhfsm.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/visualhfsm.cpp 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/visualhfsm.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -36,9 +36,9 @@
refBuilder->get_widget("imagemenuitem_quit", this->imagemenuitem_quit);
refBuilder->get_widget("imagemenuitem_state", this->imagemenuitem_state);
refBuilder->get_widget("imagemenuitem_transition", this->imagemenuitem_transition);
- refBuilder->get_widget("imagemenuitem_interfaces", this->imagemenuitem_interfaces);
refBuilder->get_widget("imagemenuitem_timer", this->imagemenuitem_timer);
refBuilder->get_widget("imagemenuitem_variables", this->imagemenuitem_variables);
+ refBuilder->get_widget("imagemenuitem_libraries", this->imagemenuitem_libraries);
refBuilder->get_widget("imagemenuitem_configfile", this->imagemenuitem_configfile);
refBuilder->get_widget("imagemenuitem_generatecode", this->imagemenuitem_generatecode);
refBuilder->get_widget("imagemenuitem_compile", this->imagemenuitem_compile);
@@ -66,12 +66,12 @@
sigc::mem_fun(*this, &VisualHFSM::on_menubar_clicked_state));
this->imagemenuitem_transition->signal_activate().connect(
sigc::mem_fun(*this, &VisualHFSM::on_menubar_clicked_transition));
- this->imagemenuitem_interfaces->signal_activate().connect(
- sigc::mem_fun(*this, &VisualHFSM::on_menubar_clicked_interfaces));
this->imagemenuitem_timer->signal_activate().connect(
sigc::mem_fun(*this, &VisualHFSM::on_menubar_clicked_timer));
this->imagemenuitem_variables->signal_activate().connect(
sigc::mem_fun(*this, &VisualHFSM::on_menubar_clicked_variables));
+ this->imagemenuitem_libraries->signal_activate().connect(
+ sigc::mem_fun(*this, &VisualHFSM::on_menubar_clicked_libraries));
this->imagemenuitem_configfile->signal_activate().connect(
sigc::mem_fun(*this, &VisualHFSM::on_menubar_clicked_configfile));
this->imagemenuitem_generatecode->signal_activate().connect(
@@ -130,7 +130,23 @@
this->idguinode = 1;
this->idguitransition = 1;
- this->createConfigFile();
+ system("./getinterfaces.sh /usr/local/include/jderobot/slice > allinterfaces.txt");
+ std::ifstream infile("allinterfaces.txt");
+ std::string line;
+ while ( std::getline(infile, line) ) {
+ std::string buff;
+ std::string interface;
+ std::stringstream ss(line);
+ int i = 0;
+ while (ss >> buff) {
+ if (i == 0) { // getting the interface
+ interface = std::string(buff);
+ } else { // getting the file header
+ this->mapInterfacesHeader[interface] = buff;
+ }
+ i++;
+ }
+ }
}
/*************************************************************
@@ -139,8 +155,82 @@
VisualHFSM::~VisualHFSM () {}
/*************************************************************
+ * METHODS FOR SIGNALS
+ *************************************************************/
+// Save the automata in the specified path
+void VisualHFSM::on_save_file ( std::string path ) {
+ if (this->lastButton == SAVE_AS) {
+ std::string str(".xml");
+ if (!this->hasEnding(path, str))
+ this->filepath = std::string(path + str);
+ else
+ this->filepath = std::string(path);
+
+ delete this->sfdialog;
+ }
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Saving file... " << this->filepath << END_COLOR << std::endl;
+
+ SaveFile savefile(this->filepath, &this->subautomataList, this->listInterfaces, this->listLibraries);
+ savefile.init();
+}
+
+// Load the specified file
+void VisualHFSM::on_load_file ( std::string path ) {
+ this->filepath = std::string(path);
+
+ delete this->lfdialog;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Loading file... " << this->filepath << END_COLOR << std::endl;
+
+ try {
+ MySaxParser parser;
+ parser.set_substitute_entities(true);
+ parser.parse_file(filepath);
+
+ this->listInterfaces = parser.getConfigFile();
+
+ this->removeAllGui();
+ if (!this->loadSubautomata(parser.getListSubautomata()))
+ std::cout << BEGIN_RED << VISUAL << "ERROR loading subautomata" << END_COLOR << std::endl;
+ } catch ( const xmlpp::exception& ex ) {
+ std::cout << "libxml++ exception: " << ex.what() << std::endl;
+ }
+}
+
+// Receive a list of interfaces for the automata
+void VisualHFSM::on_config_text ( std::list<IceInterface>& listInterfaces ) {
+ this->listInterfaces = listInterfaces;
+ delete this->cfdialog;
+}
+
+// Receive a list of libraries for the automata
+void VisualHFSM::on_additional_libraries ( std::list<std::string> listLibraries ) {
+ this->listLibraries = listLibraries;
+ delete this->ldialog;
+}
+
+// Receive the signal of name changed in a state for changing it in the treeview
+void VisualHFSM::on_change_node_name ( int id, std::string name ) {
+ typedef Gtk::TreeModel::Children type_children;
+ type_children children = this->refTreeModel->children();
+ type_children::iterator childrenIterator = children.begin();
+ while ( childrenIterator != children.end() ) {
+ Gtk::TreeModel::Row row = *childrenIterator;
+ if (row[m_Columns.m_col_id] == id) {
+ row[m_Columns.m_col_name] = name;
+ break;
+ } else
+ childrenIterator++;
+ }
+}
+
+/*************************************************************
* INTERNAL METHODS
*************************************************************/
+// Create a popup menu for transitions
void VisualHFSM::create_menu_transition () {
this->actionGroupTransition = Gtk::ActionGroup::create();
this->actionGroupTransition->add(Gtk::Action::create("ContextMenu", "Context Menu"));
@@ -175,6 +265,7 @@
g_warning("menu not found");
}
+// Create a popup menu for states
void VisualHFSM::create_menu_item () {
this->actionGroupItem = Gtk::ActionGroup::create();
this->actionGroupItem->add(Gtk::Action::create("ContextMenu", "Context Menu"));
@@ -214,6 +305,7 @@
g_warning("menu not found");
}
+// Create a popup menu for paste states in the canvas
void VisualHFSM::create_menu_paste () {
this->actionGroupPaste = Gtk::ActionGroup::create();
this->actionGroupPaste->add(Gtk::Action::create("ContextMenu", "Context Menu"));
@@ -242,21 +334,20 @@
g_warning("menu paste not found");
}
+// Create a new state, receiving the ID of the subautomata son
void VisualHFSM::create_new_state ( int idSubautomataSon ) {
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "Creating state with ID: " << this->idguinode << END_COLOR << std::endl;
-
this->currentSubautomata->newGuiNode(this->idguinode, idSubautomataSon,
this->event_x, this->event_y);
- std::string nameNode = this->currentSubautomata->getLastGuiNodeName();
if (this->currentSubautomata->getId() == 1) {
Gtk::TreeModel::Row row = *(refTreeModel->append());
row[m_Columns.m_col_id] = this->idguinode;
- row[m_Columns.m_col_name] = nameNode;
+ row[m_Columns.m_col_name] = this->nameNode;
} else {
- this->fillTreeView(nameNode, refTreeModel->children(),
+ this->fillTreeView(this->nameNode, refTreeModel->children(),
this->getIdNodeInSubautomata(this->currentSubautomata->getIdFather()));
}
@@ -278,6 +369,7 @@
std::cout << BEGIN_GREEN << VISUAL << "Done!" << END_COLOR << std::endl;
}
+// Create a new transition between 'item' and 'lastItem'
void VisualHFSM::create_new_transition ( const Glib::RefPtr<Goocanvas::Item>& item ) {
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "Creating transition" << END_COLOR << std::endl;
@@ -319,6 +411,7 @@
std::cout << BEGIN_GREEN << VISUAL << "Done!" << END_COLOR << std::endl;
}
+// Create a new transition when loading an xml file
void VisualHFSM::create_new_transition ( Point origin, Point final, Point midpoint, int idTransition ) {
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "Creating transition" << END_COLOR << std::endl;
@@ -354,20 +447,19 @@
}
/*************************************************************
- * METHODS FOR SIGNALS
- *************************************************************/
-
-/*************************************************************
* OF THE MENUS (TRANSITIONS)
*************************************************************/
+// Rename the selected transition
void VisualHFSM::on_menu_transition_rename () {
this->currentSubautomata->renameGuiTransition(this->selectedItem);
}
+// Edit the selected transition
void VisualHFSM::on_menu_transition_edit () {
this->currentSubautomata->editGuiTransition(this->selectedItem);
}
+// Remove the selected transition
void VisualHFSM::on_menu_transition_remove () {
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "Removing transition..." << END_COLOR << std::endl;
@@ -390,28 +482,47 @@
/*************************************************************
* OF THE MENUS (STATES)
*************************************************************/
+// Rename a state
void VisualHFSM::on_menu_state_rename () {
this->copyPressed = false;
- this->currentSubautomata->renameGuiNode(this->selectedItem);
+ std::list<GuiNode>* listGuinodes = this->currentSubautomata->getListGuiNodes();
+ std::list<GuiNode>::iterator nodeListIterator = listGuinodes->begin();
+ while ( (!nodeListIterator->hasThisItem(this->selectedItem)) &&
+ (nodeListIterator != listGuinodes->end()) )
+ nodeListIterator++;
+
+ if (nodeListIterator != listGuinodes->end()) {
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << GUISUB << "Renaming node" << END_COLOR << std::endl;
+
+ this->rdialog = new RenameDialog(&*nodeListIterator);
+ this->rdialog->init();
+ this->rdialog->signal_change_node().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_change_node_name));
+ }
}
+// Edit the code of a state
void VisualHFSM::on_menu_state_edit () {
this->copyPressed = false;
this->currentSubautomata->editGuiNode(this->selectedItem);
}
+// Mark the state as initial
void VisualHFSM::on_menu_state_markasinitial () {
this->copyPressed = false;
this->currentSubautomata->markGuiNodeAsInitial(this->selectedItem);
}
+// Just put the 'copyPressed' variable to true
void VisualHFSM::on_menu_state_copy () {
this->copyPressed = true;
}
+// Remove a state
void VisualHFSM::on_menu_state_remove () {
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "Removing state..." << END_COLOR << std::endl;
@@ -430,20 +541,63 @@
}
}
+// Paste a state
void VisualHFSM::on_menu_canvas_paste () {
this->copyPressed = true;
-
+ GuiNode* gnode = this->currentSubautomata->getGuiNode(this->selectedItem);
+ this->nameNode = gnode->getName();
this->create_new_state(0);
+ this->currentSubautomata->setNameLastGuiNode(this->nameNode);
+ this->currentSubautomata->setCodeLastGuiNode(gnode->getCode());
this->idguinode++;
}
/*************************************************************
* OF THE TREEVIEW
*************************************************************/
+// Fills the treeview with a new state
+bool VisualHFSM::fillTreeView ( std::string nameNode, Gtk::TreeModel::Children child, int idNodeFather ) {
+ bool cont = true;
+ Gtk::TreeModel::Children::iterator iter = child.begin();
+ while ( cont && (iter != child.end()) ) {
+ Gtk::TreeModel::Row therow = *iter;
+ if (therow[m_Columns.m_col_id] == idNodeFather) {
+ Gtk::TreeModel::Row row = *(refTreeModel->append(therow.children()));
+ row[m_Columns.m_col_id] = this->idguinode;
+ row[m_Columns.m_col_name] = nameNode;
+ cont = false;
+ } else {
+ cont = this->fillTreeView(nameNode, therow.children(), idNodeFather);
+ iter++;
+ }
+ }
+ return cont;
+}
+
+// Remove from the treeview
+bool VisualHFSM::removeFromTreeView ( int id, Gtk::TreeModel::Children child ) {
+ bool cont = true;
+ Gtk::TreeModel::Children::iterator iter = child.begin();
+ while ( cont && (iter != child.end()) ) {
+ Gtk::TreeModel::Row therow = *iter;
+ if (therow[m_Columns.m_col_id] == id) {
+ refTreeModel->erase(therow);
+ cont = false;
+ } else {
+ cont = this->removeFromTreeView(id, therow.children());
+ iter++;
+ }
+ }
+
+ return cont;
+}
+
/*************************************************************
* OF THE SCHEMA
*************************************************************/
+// Schema events: create an state, goes up to the subautomata father
+// and shows the popup menu paste
bool VisualHFSM::on_schema_event ( GdkEvent* event ) {
if ((event->button.x != 0) && (event->button.y != 0)) {
this->event_x = event->button.x;
@@ -452,6 +606,7 @@
if ((lastButton == STATE) && (event->type == GDK_BUTTON_RELEASE)
&& (event->button.button == 1)) { // create an state
+ this->nameNode = std::string("state");
this->create_new_state(0);
this->idguinode++;
} else if ((event->button.button == 2) && (event->type == GDK_BUTTON_RELEASE)) {
@@ -468,6 +623,7 @@
return false;
}
+// Method called when an item is created, both states and transitions
void VisualHFSM::on_item_created ( const Glib::RefPtr<Goocanvas::Item>& item,
const Glib::RefPtr<Goocanvas::ItemModel>& /* model */) {
if (this->state == NORMAL) {
@@ -554,6 +710,8 @@
}
}
+// Button press events: goes deep to the subautomata child
+// or shows the popup menu for a state
bool VisualHFSM::on_item_button_press_event ( const Glib::RefPtr<Goocanvas::Item>& item,
GdkEventButton* event ) {
if ((event->button == 1) && item) {
@@ -603,6 +761,7 @@
return false;
}
+// Release events: reset the drag and create a new transition (just in case)
bool VisualHFSM::on_item_button_release_event ( const Glib::RefPtr<Goocanvas::Item>& item,
GdkEventButton* event) {
if ((event->button == 1)) {
@@ -627,6 +786,7 @@
return false;
}
+// Notify event to move a state
bool VisualHFSM::on_item_motion_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
GdkEventMotion* event) {
if (item && dragging && (item == dragging)) {
@@ -640,6 +800,7 @@
return false;
}
+// Notify event when entering a state (change the state's width)
bool VisualHFSM::on_item_enter_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
GdkEventCrossing* event) {
if (item) {
@@ -656,6 +817,7 @@
return false;
}
+// Notify event when leaving a state (change the state's width)
bool VisualHFSM::on_item_leave_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
GdkEventCrossing* event) {
if (item) {
@@ -668,6 +830,7 @@
return false;
}
+// Button press event for: start dragging or show the popup menu transition
bool VisualHFSM::on_transition_button_press_event ( const Glib::RefPtr<Goocanvas::Item>& item,
GdkEventButton* event ) {
if ((event->button == 1) && item && (event->type == GDK_BUTTON_PRESS)) {
@@ -690,6 +853,7 @@
return false;
}
+// Release events: reset the drag
bool VisualHFSM::on_transition_button_release_event ( const Glib::RefPtr<Goocanvas::Item>& item,
GdkEventButton* event) {
if (event->button == 1)
@@ -698,6 +862,7 @@
return false;
}
+// Notify event to move a transition
bool VisualHFSM::on_transition_motion_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
GdkEventMotion* event) {
if (item && dragging && (item == dragging)) {
@@ -710,6 +875,7 @@
return false;
}
+// Notify event when entering a transition (change the transition's width)
bool VisualHFSM::on_transition_enter_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
GdkEventCrossing* event) {
if (item) {
@@ -724,6 +890,7 @@
return false;
}
+// Notify event when leaving a transition (change the transition's width)
bool VisualHFSM::on_transition_leave_notify_event ( const Glib::RefPtr<Goocanvas::Item>& item,
GdkEventCrossing* event) {
if (item) {
@@ -739,11 +906,15 @@
/*************************************************************
* OF THE MENU
*************************************************************/
+// New automata, remove all
+// TODO: remove the treeview
void VisualHFSM::on_menubar_clicked_new () {
this->removeAllGui();
this->removeAllSubautomata();
+ this->filepath = std::string("");
}
+// Open an automata previously saved
void VisualHFSM::on_menubar_clicked_open () {
lastButton = OPEN;
@@ -756,6 +927,7 @@
&VisualHFSM::on_load_file));
}
+// Save an automata
void VisualHFSM::on_menubar_clicked_save () {
lastButton = SAVE;
@@ -768,6 +940,7 @@
this->on_save_file(this->filepath);
}
+// Save as (if you want to change the name and/or location)
void VisualHFSM::on_menubar_clicked_save_as () {
lastButton = SAVE_AS;
@@ -780,10 +953,12 @@
&VisualHFSM::on_save_file));
}
+// Close the application
void VisualHFSM::on_menubar_clicked_quit () {
this->hide(); // hide() will cause main::run() to end
}
+// New state to be generated
void VisualHFSM::on_menubar_clicked_state () {
lastButton = STATE;
@@ -791,6 +966,7 @@
std::cout << BEGIN_GREEN << VISUAL << "Create a state?" << END_COLOR << std::endl;
}
+// New transition to be generated
void VisualHFSM::on_menubar_clicked_transition () {
lastButton = TRANSITION;
transitionsCounter = 0;
@@ -799,16 +975,7 @@
std::cout << BEGIN_GREEN << VISUAL << "Create a transition?" << END_COLOR << std::endl;
}
-void VisualHFSM::on_menubar_clicked_interfaces () {
- lastButton = INTERFACES;
-
- if (DEBUG)
- std::cout << BEGIN_GREEN << VISUAL << "Import interfaces" << END_COLOR << std::endl;
-
- ImportDialog* idialog = new ImportDialog(this->currentSubautomata);
- idialog->init();
-}
-
+// Insert the timer for this automata
void VisualHFSM::on_menubar_clicked_timer () {
lastButton = TIMER;
@@ -819,6 +986,7 @@
tdialog->init();
}
+// Insert variables and functions for this automata
void VisualHFSM::on_menubar_clicked_variables () {
lastButton = VARIABLES;
@@ -829,46 +997,76 @@
fvdialog->init();
}
+// Insert libraries for the project
+void VisualHFSM::on_menubar_clicked_libraries () {
+ lastButton = LIBRARIES;
+
+ if (DEBUG)
+ std::cout << BEGIN_GREEN << VISUAL << "Additional libraries for this automata" << END_COLOR << std::endl;
+
+ this->ldialog = new LibrariesDialog(this->listLibraries);
+ this->ldialog->init();
+ this->ldialog->signal_libraries().connect(sigc::mem_fun(this,
+ &VisualHFSM::on_additional_libraries));
+}
+
+// Create a new config file for the project
void VisualHFSM::on_menubar_clicked_configfile () {
lastButton = VARIABLES;
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "Config file for this automata" << END_COLOR << std::endl;
- this->cfdialog = new ConfigFileDialog(this->configfile);
+ this->cfdialog = new ConfigFileDialog(this->listInterfaces, this->mapInterfacesHeader);
this->cfdialog->init();
this->cfdialog->signal_config().connect(sigc::mem_fun(this,
&VisualHFSM::on_config_text));
}
+// Generate the code for the project
void VisualHFSM::on_menubar_clicked_generate_code () {
lastButton = GENERATE_CODE;
- if (this->filepath.compare(std::string("")) != 0) {
+ if (this->filepath.compare(std::string("")) != 0) { // if it is not saved, save it please!
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "Generating code..." << END_COLOR << std::endl;
- MySaxParser parser;
- parser.set_substitute_entities(true);
- parser.parse_file(this->filepath);
+ if (this->checkAll()) { // all ok!
+ SaveFile savefile(this->filepath, &this->subautomataList, this->listInterfaces, this->listLibraries);
+ savefile.init();
- std::string cpppath(this->filepath);
- std::string cfgpath(this->filepath);
- std::string cmakepath(this->filepath);
- if ( (this->replace(cpppath, std::string(".xml"), std::string(".cpp"))) &&
- (this->replace(cfgpath, std::string(".xml"), std::string(".cfg"))) &&
- (this->replaceFile(cmakepath, std::string("/"), std::string("CMakeLists.txt"))) ) {
- Generate generate(parser.getListSubautomata(), cpppath, cfgpath, cmakepath, this->configfile);
- generate.init();
- } else {
- std::cout << BEGIN_GREEN << VISUAL << "Impossible to generate code" << END_COLOR << std::endl;
+ MySaxParser parser;
+ parser.set_substitute_entities(true);
+ parser.parse_file(this->filepath);
+ this->listLibraries = parser.getListLibs();
+
+ std::string cpppath(this->filepath);
+ std::string cfgpath(this->filepath);
+ std::string cmakepath(this->filepath);
+ if ( (this->replace(cpppath, std::string(".xml"), std::string(".cpp"))) &&
+ (this->replace(cfgpath, std::string(".xml"), std::string(".cfg"))) &&
+ (this->replaceFile(cmakepath, std::string("/"), std::string("CMakeLists.txt"))) ) {
+ Generate generate(parser.getListSubautomata(), cpppath, cfgpath, cmakepath,
+ &(this->listInterfaces), this->mapInterfacesHeader, this->listLibraries);
+ generate.init();
+ } else {
+ std::cout << BEGIN_GREEN << VISUAL << "Impossible to generate code" << END_COLOR << std::endl;
+ }
+ } else { // show problems
+ std::cout << BEGIN_RED << VISUAL << "There are some empty important fields that cannot be empty. Possibilities:" << END_COLOR << std::endl;
+ std::cout << BEGIN_RED << VISUAL << "- Node names" << END_COLOR << std::endl;
+ std::cout << BEGIN_RED << VISUAL << "- Transition names and mode of transition" << END_COLOR << std::endl;
+ std::cout << BEGIN_RED << VISUAL << "- Repeated interfaces" << END_COLOR << std::endl;
+ std::cout << BEGIN_RED << VISUAL << "- Iteration time for each subautomata" << END_COLOR << std::endl;
}
+
} else {
std::cout << BEGIN_YELLOW << VISUAL << "You must save the project first" << END_COLOR << std::endl;
}
}
+// Compile the project
void VisualHFSM::on_menubar_clicked_compile () {
lastButton = COMPILE;
@@ -877,7 +1075,8 @@
struct stat buffer;
- if ( (this->filepath.compare(std::string("")) != 0) && (stat (cpppath.c_str(), &buffer) == 0) ) {
+ if ( (this->filepath.compare(std::string("")) != 0) &&
+ (stat (cpppath.c_str(), &buffer) == 0) ) { // check the .xml and .cpp files
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "Starting compilation..." << END_COLOR << std::endl;
@@ -909,6 +1108,8 @@
}
+// About
+// TODO: generate it
void VisualHFSM::on_menubar_clicked_about () {
lastButton = COMPILE;
@@ -916,6 +1117,7 @@
std::cout << BEGIN_GREEN << VISUAL << "About" << END_COLOR << std::endl;
}
+// Goes up to the upper level of the automata (pressing the middle button of the mouse)
void VisualHFSM::on_menubar_clicked_up () { // Deprecated
lastButton = UP;
@@ -927,7 +1129,19 @@
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "It is ok to get the father" << END_COLOR << std::endl;
- this->currentSubautomata->hideAll();
+ if (this->currentSubautomata->isNodeListEmpty()) {
+ guisub->setToZero(this->currentSubautomata->getId());
+ std::list<GuiSubautomata>::iterator listGuisubIterator = this->subautomataList.begin();
+ while ( (listGuisubIterator->getId() != this->currentSubautomata->getId()) &&
+ (listGuisubIterator != this->subautomataList.end()) )
+ listGuisubIterator++;
+
+ if (listGuisubIterator != this->subautomataList.end())
+ this->subautomataList.erase(listGuisubIterator);
+ } else {
+ this->currentSubautomata->hideAll();
+ }
+
guisub->showAll();
this->currentSubautomata = guisub;
@@ -939,53 +1153,7 @@
/*************************************************************
* IN GENERAL
*************************************************************/
-void VisualHFSM::on_save_file ( std::string path ) {
- if (this->lastButton == SAVE_AS) {
- std::string str(".xml");
- if (!this->hasEnding(path, str))
- this->filepath = std::string(path + str);
- else
- this->filepath = std::string(path);
-
- delete this->sfdialog;
- }
-
- if (DEBUG)
- std::cout << BEGIN_GREEN << VISUAL << "Saving file... " << this->filepath << END_COLOR << std::endl;
-
- SaveFile savefile(this->filepath, &this->subautomataList, this->configfile);
- savefile.init();
-}
-
-void VisualHFSM::on_load_file ( std::string path ) {
- this->filepath = std::string(path);
-
- delete this->lfdialog;
-
- if (DEBUG)
- std::cout << BEGIN_GREEN << VISUAL << "Loading file... " << this->filepath << END_COLOR << std::endl;
-
- try {
- MySaxParser parser;
- parser.set_substitute_entities(true);
- parser.parse_file(filepath);
-
- this->configfile = parser.getConfigFile();
-
- this->removeAllGui();
- if (!this->loadSubautomata(parser.getListSubautomata()))
- std::cout << BEGIN_RED << VISUAL << "ERROR loading subautomata" << END_COLOR << std::endl;
- } catch ( const xmlpp::exception& ex ) {
- std::cout << "libxml++ exception: " << ex.what() << std::endl;
- }
-}
-
-void VisualHFSM::on_config_text ( std::string config ) {
- this->configfile = std::string(config);
-
- delete this->cfdialog;
-}
-
+// Get a specified subautomata
GuiSubautomata* VisualHFSM::getSubautomata ( int idSubautomata ) {
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "Getting subautomata with ID: " << idSubautomata << END_COLOR << std::endl;
@@ -1001,6 +1169,7 @@
return NULL;
}
+// Get a specified subautomata with an idFather
GuiSubautomata* VisualHFSM::getSubautomataWithIdFather ( int idFather ) {
if (DEBUG)
std::cout << BEGIN_GREEN << VISUAL << "Getting subautomata with ID father: " << idFather << END_COLOR << std::endl;
@@ -1016,6 +1185,7 @@
return NULL;
}
+// Load a subautomata
int VisualHFSM::loadSubautomata ( std::list<SubAutomata> subList ) {
this->removeAllSubautomata();
std::list<SubAutomata>::iterator subListIterator = subList.begin();
@@ -1031,7 +1201,6 @@
this->currentSubautomata->setFunctions(subListIterator->getFunctions());
this->currentSubautomata->setTime(subListIterator->getTime());
this->currentSubautomata->setVariables(subListIterator->getVariables());
- this->currentSubautomata->setInterfaces(*(subListIterator->getInterfaces()));
std::list<Node> nodeList = subListIterator->getNodeList();
std::list<Node>::iterator nodeListIterator = nodeList.begin();
@@ -1041,6 +1210,7 @@
this->event_x = nodePoint->getX();
this->event_y = nodePoint->getY();
this->idguinode = idNode;
+ this->nameNode = std::string(nodeListIterator->getName());
this->create_new_state(nodeListIterator->getIdSubautomataSon());
this->currentSubautomata->setIsInitialLastGuiNode(nodeListIterator->isInitial());
this->currentSubautomata->setNameLastGuiNode(nodeListIterator->getName());
@@ -1082,6 +1252,7 @@
return 1;
}
+// Remove the GUI
void VisualHFSM::removeAllGui () {
for ( std::list<GuiSubautomata>::iterator subListIterator = this->subautomataList.begin();
subListIterator != this->subautomataList.end(); subListIterator++ ) {
@@ -1104,6 +1275,7 @@
}
}
+// Remove all subautomata
void VisualHFSM::removeAllSubautomata () {
for ( std::list<GuiSubautomata>::iterator subListIterator = this->subautomataList.begin();
subListIterator != this->subautomataList.end(); subListIterator++ )
@@ -1112,71 +1284,7 @@
this->subautomataList.clear();
}
-bool VisualHFSM::hasEnding ( std::string const &fullString, std::string const &ending ) {
- if (fullString.length() >= ending.length()) {
- return (0 == fullString.compare (fullString.length() - ending.length(),
- ending.length(), ending));
- } else {
- return false;
- }
-}
-
-bool VisualHFSM::replaceFile ( std::string& str, const std::string& character, std::string to ) {
- size_t last_pos = str.find_last_of(character);
- if (last_pos == std::string::npos)
- return false;
-
- str.replace(last_pos + 1, std::string::npos, to);
-
- return true;
-}
-
-bool VisualHFSM::replace ( std::string& str, const std::string& from, const std::string& to) {
- size_t start_pos = str.find(from);
- if (start_pos == std::string::npos)
- return false;
-
- str.replace(start_pos, from.length(), to);
-
- return true;
-}
-
-bool VisualHFSM::fillTreeView ( std::string nameNode, Gtk::TreeModel::Children child, int idNodeFather ) {
- bool cont = true;
- Gtk::TreeModel::Children::iterator iter = child.begin();
- while ( cont && (iter != child.end()) ) {
- Gtk::TreeModel::Row therow = *iter;
- if (therow[m_Columns.m_col_id] == idNodeFather) {
- Gtk::TreeModel::Row row = *(refTreeModel->append(therow.children()));
- row[m_Columns.m_col_id] = this->idguinode;
- row[m_Columns.m_col_name] = nameNode;
- cont = false;
- } else {
- cont = this->fillTreeView(nameNode, therow.children(), idNodeFather);
- iter++;
- }
- }
-
- return cont;
-}
-
-bool VisualHFSM::removeFromTreeView ( int id, Gtk::TreeModel::Children child ) {
- bool cont = true;
- Gtk::TreeModel::Children::iterator iter = child.begin();
- while ( cont && (iter != child.end()) ) {
- Gtk::TreeModel::Row therow = *iter;
- if (therow[m_Columns.m_col_id] == id) {
- refTreeModel->erase(therow);
- cont = false;
- } else {
- cont = this->removeFromTreeView(id, therow.children());
- iter++;
- }
- }
-
- return cont;
-}
-
+// Get an ID of a node with a specified subautomata
int VisualHFSM::getIdNodeInSubautomata ( int subautomataId ) {
std::list<GuiSubautomata>::iterator subListIterator = this->subautomataList.begin();
while ( (subListIterator->getId() != subautomataId) &&
@@ -1192,20 +1300,26 @@
return guiNodeListIterator->getId();
}
-void VisualHFSM::removeRecursively ( GuiSubautomata* guisub, GuiNode* gnode ) {
- int idSubautomataSon = gnode->getIdSubautomataSon();
- if (idSubautomataSon != 0) {
- GuiSubautomata* subautomata = this->getSubautomata(idSubautomataSon);
- std::list<GuiNode> guiNodeList = *(subautomata->getListGuiNodes());
- for ( std::list<GuiNode>::iterator guiNodeListIterator = guiNodeList.begin();
- guiNodeListIterator != guiNodeList.end(); guiNodeListIterator++ ) {
- this->removeRecursively(subautomata, &*guiNodeListIterator);
+// Get an ID of a subautomata with a scpecified node
+int VisualHFSM::getIdSubautomataWithNode ( int idNode ) {
+ int id = 0;
+ std::list<GuiSubautomata>::iterator subListIterator = this->subautomataList.begin();
+ while ( (id == 0) && (subListIterator != this->subautomataList.end()) ) {
+ std::list<GuiNode>* nodeList = subListIterator->getListGuiNodes();
+ std::list<GuiNode>::iterator nodeListIterator = nodeList->begin();
+ while ( (id == 0) && (nodeListIterator != nodeList->end()) ) {
+ if (nodeListIterator->getId() == idNode)
+ id = subListIterator->getId();
+ else
+ nodeListIterator++;
}
+ subListIterator++;
}
-
- this->remove(guisub, gnode);
+
+ return id;
}
+// Remove a node and its associated transitions
void VisualHFSM::remove ( GuiSubautomata* guisub, GuiNode* gnode ) {
root->remove_child(root->find_child(gnode->getEllipse()));
root->remove_child(root->find_child(gnode->getEllipseInitial()));
@@ -1226,35 +1340,87 @@
guisub->removeGuiNode(gnode->getId());
}
-int VisualHFSM::getIdSubautomataWithNode ( int idNode ) {
- int id = 0;
- std::list<GuiSubautomata>::iterator subListIterator = this->subautomataList.begin();
- while ( (id == 0) && (subListIterator != this->subautomataList.end()) ) {
- std::list<GuiNode>* nodeList = subListIterator->getListGuiNodes();
- std::list<GuiNode>::iterator nodeListIterator = nodeList->begin();
- while ( (id == 0) && (nodeListIterator != nodeList->end()) ) {
- if (nodeListIterator->getId() == idNode)
- id = subListIterator->getId();
- else
- nodeListIterator++;
+// Removes a node recursively (including its subautomata children)
+void VisualHFSM::removeRecursively ( GuiSubautomata* guisub, GuiNode* gnode ) {
+ int idSubautomataSon = gnode->getIdSubautomataSon();
+ if (idSubautomataSon != 0) {
+ GuiSubautomata* subautomata = this->getSubautomata(idSubautomataSon);
+ std::list<GuiNode> guiNodeList = *(subautomata->getListGuiNodes());
+ for ( std::list<GuiNode>::iterator guiNodeListIterator = guiNodeList.begin();
+ guiNodeListIterator != guiNodeList.end(); guiNodeListIterator++ ) {
+ this->removeRecursively(subautomata, &*guiNodeListIterator);
}
- subListIterator++;
}
+
+ this->remove(guisub, gnode);
+}
- return id;
+// Check if a string has the specified ending (usually for .xml endings)
+bool VisualHFSM::hasEnding ( std::string const &fullString, std::string const &ending ) {
+ if (fullString.length() >= ending.length()) {
+ return (0 == fullString.compare (fullString.length() - ending.length(),
+ ending.length(), ending));
+ } else {
+ return false;
+ }
}
-void VisualHFSM::createConfigFile () {
- this->configfile += "comp.HeadMotors.Proxy=NeckMotors:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.HeadSpeed.Proxy=NeckSpeed:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.LeftShoulderMotors.Proxy=LeftShoulderMotors:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.RightShoulderMotors.Proxy=RightShoulderMotors:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.LeftElbowMotors.Proxy=LeftElbowMotors:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.RightElbowMotors.Proxy=RightElbowMotors:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.LeftHipMotors.Proxy=LeftHipMotors:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.RightHipMotors.Proxy=RightHipMotors:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.LeftKneeMotors.Proxy=LeftKneeMotors:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.RightKneeMotors.Proxy=RightKneeMotors:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.LeftAnkleMotors.Proxy=LeftAnkleMotors:default -h 192.168.14.113 -p 10000\r\n";
- this->configfile += "comp.RightAnkleMotors.Proxy=RightAnkleMotors:default -h 192.168.14.113 -p 10000\r\n";
+// Replace in the 'str', 'from' to 'to'
+bool VisualHFSM::replace ( std::string& str, const std::string& from, const std::string& to) {
+ size_t start_pos = str.find(from);
+ if (start_pos == std::string::npos)
+ return false;
+
+ str.replace(start_pos, from.length(), to);
+
+ return true;
+}
+
+// Replace in 'str', 'character' to 'to'
+bool VisualHFSM::replaceFile ( std::string& str, const std::string& character, std::string to ) {
+ size_t last_pos = str.find_last_of(character);
+ if (last_pos == std::string::npos)
+ return false;
+
+ str.replace(last_pos + 1, std::string::npos, to);
+
+ return true;
+}
+
+// Check if it is all ok
+bool VisualHFSM::checkAll () {
+ // The interfaces are all different
+ for ( std::list<IceInterface>::iterator first = this->listInterfaces.begin();
+ first != this->listInterfaces.end(); first++ ) {
+ std::list<IceInterface>::iterator aux = first;
+ aux++;
+ for ( std::list<IceInterface>::iterator second = aux;
+ second != this->listInterfaces.end(); second++ ) {
+ if (first->equals(&*second))
+ return false;
+ }
+ }
+
+ std::list<GuiSubautomata>::iterator subautomataListIterator = this->subautomataList.begin();
+ while ( subautomataListIterator != this->subautomataList.end() ) {
+ // If there are no empty automatons
+ if ( subautomataListIterator->isNodeListEmpty() &&
+ (this->currentSubautomata->getId() != subautomataListIterator->getId()) ) {
+ GuiSubautomata* gsub = this->getSubautomata(subautomataListIterator->getIdFather());
+ gsub->setToZero(subautomataListIterator->getId());
+ subautomataListIterator = this->subautomataList.erase(subautomataListIterator);
+ } else {
+ // The subautomata is all ok
+ if ( !subautomataListIterator->checkAll() )
+ return false;
+
+ // The timing for the automata is not empty
+ if (subautomataListIterator->getTime().compare("") == 0)
+ return false;
+
+ subautomataListIterator++;
+ }
+ }
+
+ return true;
}
\ No newline at end of file
Modified: trunk/src/stable/components/visualHFSM/visualhfsm.h
===================================================================
--- trunk/src/stable/components/visualHFSM/visualhfsm.h 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/visualhfsm.h 2013-11-02 19:50:32 UTC (rev 1086)
@@ -32,9 +32,10 @@
#include "savefile.h"
#include "generate.h"
#include "guisubautomata.h"
+#include "iceinterface.h"
#include "popups/configfiledialog.h"
#include "popups/funvardialog.h"
-#include "popups/importdialog.h"
+#include "popups/librariesdialog.h"
#include "popups/loadfiledialog.h"
#include "popups/timerdialog.h"
#include "popups/savefiledialog.h"
@@ -46,9 +47,9 @@
SAVE,
SAVE_AS,
OPEN,
- INTERFACES,
TIMER,
VARIABLES,
+ LIBRARIES,
GENERATE_CODE,
COMPILE,
ANY
@@ -77,7 +78,9 @@
// Methods for signals from save and load files
void on_save_file ( std::string path );
void on_load_file ( std::string path );
- void on_config_text ( std::string config );
+ void on_config_text ( std::list<IceInterface>& listInterfaces );
+ void on_additional_libraries ( std::list<std::string> listLibraries );
+ void on_change_node_name ( int id, std::string name );
private:
Glib::RefPtr<Gtk::Builder> refBuilder;
@@ -86,7 +89,7 @@
Gtk::ImageMenuItem *imagemenuitem_new, *imagemenuitem_open, *imagemenuitem_save;
Gtk::ImageMenuItem *imagemenuitem_saveas, *imagemenuitem_quit;
Gtk::ImageMenuItem *imagemenuitem_state, *imagemenuitem_transition;
- Gtk::ImageMenuItem *imagemenuitem_interfaces, *imagemenuitem_timer, *imagemenuitem_variables;
+ Gtk::ImageMenuItem *imagemenuitem_timer, *imagemenuitem_variables, *imagemenuitem_libraries;
Gtk::ImageMenuItem *imagemenuitem_configfile, *imagemenuitem_generatecode;
Gtk::ImageMenuItem *imagemenuitem_compile, *imagemenuitem_about;
@@ -152,11 +155,18 @@
std::list <GuiSubautomata> subautomataList;
GuiSubautomata* currentSubautomata;
+ std::string nameNode;
+
// For files (load and save)
- std::string filepath, configfile;
+ std::string filepath;
+ std::list<IceInterface> listInterfaces;
+ std::map<std::string, std::string> mapInterfacesHeader;
+ std::list<std::string> listLibraries;
SaveFileDialog* sfdialog;
LoadFileDialog* lfdialog;
ConfigFileDialog* cfdialog;
+ LibrariesDialog* ldialog;
+ RenameDialog* rdialog;
Button lastButton;
@@ -185,6 +195,8 @@
void on_menu_canvas_paste ();
// Of the treeview
+ bool fillTreeView ( std::string nameNode, Gtk::TreeModel::Children child, int idNodeFather );
+ bool removeFromTreeView ( int id, Gtk::TreeModel::Children child );
// Of the schema
bool on_schema_event ( GdkEvent* event );
@@ -223,6 +235,7 @@
void on_menubar_clicked_interfaces ();
void on_menubar_clicked_timer ();
void on_menubar_clicked_variables ();
+ void on_menubar_clicked_libraries ();
void on_menubar_clicked_configfile ();
void on_menubar_clicked_generate_code ();
void on_menubar_clicked_compile ();
@@ -236,20 +249,18 @@
int loadSubautomata ( std::list<SubAutomata> subautomataList );
void removeAllGui ();
void removeAllSubautomata ();
- bool hasEnding ( std::string const &fullString, std::string const &ending );
- bool replaceFile ( std::string& str, const std::string& character, std::string to );
- bool replace ( std::string& str, const std::string& from, const std::string& to );
- bool fillTreeView ( std::string nameNode, Gtk::TreeModel::Children child, int idNodeFather );
- bool removeFromTreeView ( int id, Gtk::TreeModel::Children child );
int getIdNodeInSubautomata ( int subautomataId );
+ int getIdSubautomataWithNode ( int idNode );
+ void remove ( GuiSubautomata* guisub, GuiNode* gnode );
void removeRecursively ( GuiSubautomata* guisub, GuiNode* gnode );
- void remove ( GuiSubautomata* guisub, GuiNode* gnode );
- int getIdSubautomataWithNode ( int idNode );
+ bool hasEnding ( std::string const &fullString, std::string const &ending );
+ bool replace ( std::string& str, const std::string& from, const std::string& to );
+ bool replaceFile ( std::string& str, const std::string& character, std::string to );
- void createConfigFile ();
+ bool checkAll ();
}; // Class VisualHFSM
#endif // VISUALHFSM_H
Modified: trunk/src/stable/components/visualHFSM/xmlparser.cpp
===================================================================
--- trunk/src/stable/components/visualHFSM/xmlparser.cpp 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/xmlparser.cpp 2013-11-02 19:50:32 UTC (rev 1086)
@@ -42,6 +42,11 @@
this->mapStringValues["variables"] = E_VARS;
this->mapStringValues["functions"] = E_FUNCTIONS;
this->mapStringValues["config"] = E_CONFIGFILE;
+ this->mapStringValues["iceinterface"] = E_ICEINTERFACE;
+ this->mapStringValues["nameinterface"] = E_INTERFACENAME;
+ this->mapStringValues["ip"] = E_INTERFACEIP;
+ this->mapStringValues["port"] = E_INTERFACEPORT;
+ this->mapStringValues["interface"] = E_INTERFACEINTERFACE;
}
/*************************************************************
@@ -56,10 +61,14 @@
return this->subautomataList;
}
-std::string MySaxParser::getConfigFile () {
- return this->configfile;
+std::list<IceInterface>& MySaxParser::getConfigFile () {
+ return this->listConfig;
}
+std::list<std::string> MySaxParser::getListLibs () {
+ return this->listLibraries;
+}
+
/*************************************************************
* OVERRIDES
*************************************************************/
@@ -163,6 +172,7 @@
}
case E_LIBRARIES:
this->option = E_LIBRARIES;
+ this->listLibraries.clear();
break;
case E_LIB:
this->option = E_LIB;
@@ -181,6 +191,22 @@
case E_CONFIGFILE:
this->option = E_CONFIGFILE;
break;
+ case E_ICEINTERFACE:
+ this->iceinterface = new IceInterface();
+ this->option = E_ICEINTERFACE;
+ break;
+ case E_INTERFACENAME:
+ this->option = E_INTERFACENAME;
+ break;
+ case E_INTERFACEIP:
+ this->option = E_INTERFACEIP;
+ break;
+ case E_INTERFACEPORT:
+ this->option = E_INTERFACEPORT;
+ break;
+ case E_INTERFACEINTERFACE:
+ this->option = E_INTERFACEINTERFACE;
+ break;
default:
break;
}
@@ -202,16 +228,13 @@
this->transition->setTrans(this->type, this->code);
break;
case E_LIB:
- this->listInterfaces.push_back(this->code);
+ this->listLibraries.push_back(this->code);
break;
- case E_LIBRARIES:
- this->subautomata->setInterfaces(this->listInterfaces);
- this->listInterfaces.clear();
- break;
case E_FUNCTIONS:
this->subautomata->setFunctions(this->code);
break;
- case E_CONFIGFILE:
+ case E_ICEINTERFACE:
+ this->listConfig.push_back(*this->iceinterface);
break;
default:
break;
@@ -289,9 +312,25 @@
break;
}
case E_CONFIGFILE: {
- this->configfile += text;
+// this->configfile += text;
break;
}
+ case E_INTERFACENAME: {
+ this->iceinterface->setName(text);
+ break;
+ }
+ case E_INTERFACEIP: {
+ this->iceinterface->setIp(text);
+ break;
+ }
+ case E_INTERFACEPORT: {
+ this->iceinterface->setPort(text);
+ break;
+ }
+ case E_INTERFACEINTERFACE: {
+ this->iceinterface->setInterface(text);
+ break;
+ }
default:
break;
}
Modified: trunk/src/stable/components/visualHFSM/xmlparser.h
===================================================================
--- trunk/src/stable/components/visualHFSM/xmlparser.h 2013-10-31 14:46:25 UTC (rev 1085)
+++ trunk/src/stable/components/visualHFSM/xmlparser.h 2013-11-02 19:50:32 UTC (rev 1086)
@@ -31,6 +31,7 @@
#include "node.h"
#include "transition.h"
#include "subautomata.h"
+#include "iceinterface.h"
typedef enum Element {
E_VISUALHFSM,
@@ -50,7 +51,12 @@
E_ITERATION,
E_VARS,
E_FUNCTIONS,
- E_CONFIGFILE
+ E_CONFIGFILE,
+ E_ICEINTERFACE,
+ E_INTERFACENAME,
+ E_INTERFACEIP,
+ E_INTERFACEPORT,
+ E_INTERFACEINTERFACE
} Element;
// Definition of this class
@@ -64,7 +70,8 @@
// Getters
std::list<SubAutomata> getListSubautomata ();
- std::string getConfigFile ();
+ std::list<IceInterface>& getConfigFile ();
+ std::list<std::string> getListLibs ();
protected:
// Overrides:
@@ -83,7 +90,8 @@
// Data structure
std::list <SubAutomata> subautomataList;
std::map<std::string, Element> mapStringValues;
- std::string configfile;
+ std::list<IceInterface> listConfig;
+ std::list<std::string> listLibraries;
bool state;
float x;
@@ -95,8 +103,8 @@
Transition* transition;
Node* node;
Point* point;
+ IceInterface* iceinterface;
- std::list<std::string> listInterfaces;
std::string code;
// Private functions
More information about the Jderobot-admin
mailing list