dfsm-devel Mailing List for dFSM Distributed Finite State Machine
Status: Beta
Brought to you by:
amoreno
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(16) |
Jun
(3) |
Jul
(18) |
Aug
(12) |
Sep
(9) |
Oct
(4) |
Nov
(1) |
Dec
(27) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(4) |
Feb
|
Mar
(35) |
Apr
(13) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <ben...@id...> - 2004-05-22 12:26:05
|
Dear Open Source developer I am doing a research project on "Fun and Software Development" in which I kindly invite you to participate. You will find the online survey under http://fasd.ethz.ch/qsf/. The questionnaire consists of 53 questions and you will need about 15 minutes to complete it. With the FASD project (Fun and Software Development) we want to define the motivational significance of fun when software developers decide to engage in Open Source projects. What is special about our research project is that a similar survey is planned with software developers in commercial firms. This procedure allows the immediate comparison between the involved individuals and the conditions of production of these two development models. Thus we hope to obtain substantial new insights to the phenomenon of Open Source Development. With many thanks for your participation, Benno Luthiger PS: The results of the survey will be published under http://www.isu.unizh.ch/fuehrung/blprojects/FASD/. We have set up the mailing list fa...@we... for this study. Please see http://fasd.ethz.ch/qsf/mailinglist_en.html for registration to this mailing list. _______________________________________________________________________ Benno Luthiger Swiss Federal Institute of Technology Zurich 8092 Zurich Mail: benno.luthiger(at)id.ethz.ch _______________________________________________________________________ |
|
From: Andreu M. <am...@us...> - 2004-05-19 15:24:08
|
Update of /cvsroot/dfsm/dFSM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29508 Modified Files: Makefile README Log Message: Add Spread acknowledgment Index: README =================================================================== RCS file: /cvsroot/dfsm/dFSM/README,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** README 7 Apr 2004 03:44:26 -0000 1.5 --- README 19 May 2004 15:23:57 -0000 1.6 *************** *** 39,42 **** --- 39,44 ---- shared library and is licensed under the GNU LESSER GENERAL PUBLIC LICENSE. + This product uses software developed by Spread Concepts LLC for use in the Spread toolkit. For more information about Spread, see http://www.spread.org. + ================================ Features (See references [2] and [3]) Index: Makefile =================================================================== RCS file: /cvsroot/dfsm/dFSM/Makefile,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Makefile 7 Apr 2004 03:44:26 -0000 1.13 --- Makefile 19 May 2004 15:23:56 -0000 1.14 *************** *** 2,6 **** # Uncomment to have Spread support ! # gcs=SPREAD ifeq ($(gcs),SPREAD) --- 2,6 ---- # Uncomment to have Spread support ! gcs=SPREAD ifeq ($(gcs),SPREAD) |
|
From: Andreu M. <am...@us...> - 2004-04-07 03:57:22
|
Update of /cvsroot/dfsm/dFSM/src/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23396/src/utils Modified Files: Makefile Log Message: Add Spread Group Communication System support Index: Makefile =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/utils/Makefile,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Makefile 17 Mar 2004 21:59:51 -0000 1.12 --- Makefile 7 Apr 2004 03:44:27 -0000 1.13 *************** *** 1,7 **** INCLUDEDIR= -I ../../include LIBDIR= -L ../../lib ! LIBRARIES= -lpthread -lstdc++ -ldfsm -lposixwrap -linitparser LIBDEPENDS= ../../lib/libdfsm.so ! CPPFLAGS= -g -DPIC -fPIC CXX= g++ SRC:= $(wildcard *.cpp) --- 1,7 ---- INCLUDEDIR= -I ../../include LIBDIR= -L ../../lib ! LIBRARIES= -lpthread -lstdc++ -ldfsm -lposixwrap -linitparser $(GCSLIBS) LIBDEPENDS= ../../lib/libdfsm.so ! CPPFLAGS= -g -DPIC -fPIC $(GCSFLAGS) CXX= g++ SRC:= $(wildcard *.cpp) |
|
From: Andreu M. <am...@us...> - 2004-04-07 03:57:22
|
Update of /cvsroot/dfsm/dFSM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23396 Modified Files: Makefile README Log Message: Add Spread Group Communication System support Index: README =================================================================== RCS file: /cvsroot/dfsm/dFSM/README,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** README 11 May 2003 19:37:32 -0000 1.4 --- README 7 Apr 2004 03:44:26 -0000 1.5 *************** *** 4,8 **** http://dfsm.sourceforge.net http://www.sourceforge.net/projects/dfsm - http://dfsm.euss.es The Distributed Finite State Machine Project (dFSM Project) aims to develop a --- 4,7 ---- *************** *** 57,60 **** --- 56,63 ---- transition code) and "events server"(To receive events) 12. Multilevel log system. + 13. Timer service + 14. Monitor tool + 15. Supervisor tool for launch ans supervise automatas + 16. Add support for Spread Group Communication System ================================ *************** *** 69,71 **** http://www.omg.org. [5] R.J. Wieringa. 2003. Design Methods for Reactive Systems, Yourdon, ! Statemate and the UML, Morgan \ No newline at end of file --- 72,82 ---- http://www.omg.org. [5] R.J. Wieringa. 2003. Design Methods for Reactive Systems, Yourdon, ! Statemate and the UML, Morgan ! ! ================================ ! Spread group communication system support ! ================================ ! 1. Install Spread (http://www.spread.org) (Devian: apt-get install spread) ! 2. Uncomment line "gcs=SPREAD" in main Makefile ! 3. Compile the dFSM ! 4. Run test examples, now communicate between them with spread Index: Makefile =================================================================== RCS file: /cvsroot/dfsm/dFSM/Makefile,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Makefile 11 Dec 2003 06:08:49 -0000 1.12 --- Makefile 7 Apr 2004 03:44:26 -0000 1.13 *************** *** 1,4 **** --- 1,16 ---- # Makefile for dfsm + # Uncomment to have Spread support + # gcs=SPREAD + + ifeq ($(gcs),SPREAD) + export GCSLIBS=-lspread + export GCSFLAGS=-DSPREAD + else + export GCSLIBS= + export GCSFLAGS= + endif + + ifndef prefix prefix:=/usr |
|
From: Andreu M. <am...@us...> - 2004-04-07 03:57:22
|
Update of /cvsroot/dfsm/dFSM/src/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23396/src/libdfsm Modified Files: Makefile Added Files: tspread.cpp Log Message: Add Spread Group Communication System support Index: Makefile =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/Makefile,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Makefile 17 Mar 2004 21:59:50 -0000 1.15 --- Makefile 7 Apr 2004 03:44:27 -0000 1.16 *************** *** 3,7 **** LIBNAME= libdfsm LDOPTIONS=-O2 ! CPPFLAGS= -g -Wall -fPIC -DPIC CXX= g++ SRC:= $(wildcard *.cpp) --- 3,7 ---- LIBNAME= libdfsm LDOPTIONS=-O2 ! CPPFLAGS= -g -Wall -fPIC -DPIC $(GCSFLAGS) CXX= g++ SRC:= $(wildcard *.cpp) *************** *** 35,37 **** clean: ! @rm -f *.so *.o *.d --- 35,37 ---- clean: ! @rm -f *.so *.o *.d --- NEW FILE: tspread.cpp --- /*************************************************************************** tspread.cpp - <to do description> ------------------- begin : 05/april/2003 copyright : (C) 2003 by Andreu Moreno email : am...@eu... ***************************************************************************/ /*************************************************************************** * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ***************************************************************************/ /* * * $Author: amoreno $ * $Revision: 1.1 $ * $Log: tspread.cpp,v $ * Revision 1.1 2004/04/07 03:44:27 amoreno * Add Spread Group Communication System support * * Revision 1.7 2004/01/02 08:04:19 amoreno * * */ #ifdef SPREAD #include "libdfsm/tspread.h" #include "libdfsm/tfsm.h" #include "libdfsm/tfsm_monitor_sensor.h" #include <stdio.h> mailbox tSpread::Mbox; /**< Spread Id connection */ tEvent *tSpread::ev; /**< Event handler */ /** * Configure Group Communication System * * @param ev Event List * @return True if ok */ bool tSpread::init(tEvent *_ev) { int ret; sp_time timeout; timeout.sec = CONNECT_TIMEOUT; timeout.usec = 0; ev = _ev; sprintf( User, "" ); sprintf( Spread_name, "4803@localhost"); ret = SP_connect_timeout( Spread_name, User, 0, 1, &Mbox, Private_group, timeout ); if( ret != ACCEPT_SESSION ) { SP_error( ret ); SP_disconnect( Mbox ); return false; } E_init(); E_attach_fd( Mbox, READ_FD, &tSpread::receive, 0, NULL, HIGH_PRIORITY ); return true; } /** * Join group associated to event id_msg * * * @param id_msg Message id. * @return true if OK */ bool tSpread::join(u_int16_t id_msg) { int ret; char group[80]; sprintf(group, "%i", id_msg); ret = SP_join( Mbox, group ); if( ret < 0 ) { SP_error( ret ); return false; }else { return true; } } /** * Leave group associated to event id_msg * * * @param id_msg Message id. * @return true if OK */ bool tSpread::leave(u_int16_t id_msg) { int ret; char group[80]; sprintf(group, "%i", id_msg); ret = SP_leave( Mbox, group ); if( ret < 0 ) { SP_error( ret ); return false; }else { return true; } } /** * Send a message to other machines using Group Communication System * A list of machines is subscribed to a message id (id_msg). When this function is invoked a message * of id_msg kind is sended to every subscribed machine. * * @param id_msg Message id. * @param data Extra data * @param len Length data * @return Bytes sended */ int tSpread::send(u_int16_t id_msg, const char *data, u_int16_t len) { int ret; char group[80]; sprintf(group, "%i", id_msg); // SAFE_MESS: in order to achieve global consistency, it is needed total order and safe message delivery ret= SP_multicast( Mbox, SAFE_MESS, group, 1, len, data ); if( ret < 0 ) { SP_error( ret ); return -1; }else { monitor_push_send_event(id_msg); return ret; } } /** * Receive message callback * */ void tSpread::receive(int fd, int code, void *data) { static char mess[102400]; char sender[MAX_GROUP_NAME]; char target_groups[100][MAX_GROUP_NAME]; int num_groups; int service_type; int16 mess_type; int endian_mismatch; int ret; tEvent::Event event; service_type = 0; ret = SP_receive( tSpread::Mbox, &service_type, sender, 100, &num_groups, target_groups, &mess_type, &endian_mismatch, sizeof(mess), mess ); //printf("\n========Missatge rebut=======: service_type: %x\n", service_type); //printf("\n========Missatge rebut=======: target_groups:: %s\n", target_groups[0]); if( ret < 0 ) { if ( (ret == GROUPS_TOO_SHORT) || (ret == BUFFER_TOO_SHORT) ) { printf("\n========Buffers or Groups too Short=======\n"); } } if (ret < 0 ) { SP_error( ret ); } if( Is_regular_mess( service_type ) ) { mess[ret] = 0; /*printf("message from %s, of type %d, (endian %d) to %d groups \n(%d bytes): %s\n", sender, mess_type, endian_mismatch, num_groups, ret, mess ); */ event.size = ret; event.id_msg = atoi(target_groups[0]); FSMLOGr(2)<<"-----------------------------"<<endl; FSMLOGr(2)<<"Received event: "<<event.id_msg<<endl; FSMLOGr(3)<<"Received "<< ret <<" data bytes from "<< sender <<endl; event.data = NULL; if (event.size > 0) { event.data=new unsigned char[event.size] ; memcpy(event.data, mess, event.size); } tSpread::ev->add_event(event); monitor_push_receive_event(event.id_msg); } } /** * Get connection identification * * @param id identification **/ void tSpread::getid(char *id) { id = Private_group; } /** * Main loop * Handle events * */ void tSpread::mainloop(void) { E_handle_events(); } #endif |
|
From: Andreu M. <am...@us...> - 2004-04-07 03:57:22
|
Update of /cvsroot/dfsm/dFSM/include/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23396/include/libdfsm Modified Files: tinput.h Added Files: tgcs.h tinput_gcs.h tspread.h Log Message: Add Spread Group Communication System support --- NEW FILE: tinput_gcs.h --- /*************************************************************************** tinput_gcs.h - <to do description> ------------------- begin : 10/mar/2004 copyright : (C) 2003 by Andreu Moreno email : am...@eu... ***************************************************************************/ /*************************************************************************** * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ***************************************************************************/ /* * * $Author: amoreno $ * $Revision: 1.1 $ * $Log: tinput_gcs.h,v $ * Revision 1.1 2004/04/07 03:44:27 amoreno * Add Spread Group Communication System support * * * * */ #ifndef CINPUT_GCS_H #define CINPUT_GCS_H #include <iostream> #include <string> #include <vector> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <errno.h> #include <dirent.h> #include <signal.h> //#include <asm/msr.h> #include <sys/stat.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/un.h> #include <sstream> #include <fstream> #include "libdfsm/tevent.h" #include "libposixwrap/tcondition_variable.h" #include "libdfsm/tfsm.h" #include "libdfsm/sm_route_table.h" #ifdef SPREAD #include "libdfsm/tspread.h" #endif using namespace std; #define SOCKET_DIR "/tmp/fsm" #define MAX_PACKET_SIZE 512 /** * Input_gcs Class. Class used to send events and contains the thread that waits registered input events * * T can be tSpread or tEnsemble (Not implemented yet) */ template <class T> class tInput_gcs : public T { public: /** * Class constructor */ tInput_gcs () { initialized = false; } /** * Class destructor */ ~tInput_gcs() {} /** * Initilize with automatic Machine identification * * @return True if OK */ bool init() { tInput_gcs::socket_name = tInput_gcs::reserve_socket_server(); initialized = true; return true; } /** * Initilize * * @param machine_id Machine identification. * @return True if OK */ bool init(u_int16_t machine_id) { ostringstream ost; check_socket_dir(); ost << machine_id; socket_name = ost.str(); //sprintf (socket_name.c_str(), "%d", machine_id); initialized = true; return true; } /** * Send a message to other machines * A list of machines is subscribed to a message id (id_msg). When this function is invoked a message * of id_msg kind is sended to every subscribed machine. * * @param id_msg Message id. * @param data Extra data * @param len Length data * @return Bytes sended */ int send(u_int16_t id_msg, char *data, u_int16_t len) { if (!initialized) { //FSMLOG(0) << "ERROR!: TInput not initialized." << endl; cout << "ERROR!: TInput not initialized." << endl; return 0; } //FSMLOG(2) <<"Sending event "<<id_msg<<endl; //cout <<"Sending event "<<id_msg<<endl; return T::send(id_msg, data, len); } /** * Send a message to a machines - NOT IMPLEMENTED YET * * @param machine Machine id to send the message. * @param id_msg Message id. * @param data Extra data * @param len Length data * @return Bytes sended */ int send_to(u_int16_t machine, u_int16_t id_msg, const char *data, u_int16_t len){ cout << "ERROR!: tInput_gcs::send_to not supported with Spread." << endl; return -1; } /** * Register message * Subscribe to a id_msg list of machines that want to receive id_msg king of messages. * * @param id_msg Message id. */ void register_msg(u_int16_t id_msg) {T::join(id_msg);} /** * Opens a socket at SOCKET_DIR * Each machine opens a socket to stablish peer to peer comunications with other machines * This function also spawns a new thread that listens in the socket. * * @param ev pointer to event object (to insert received messages) * @param cv pointer to condition variable */ void run() { if (!initialized) { //FSMLOG(0) << "ERROR!: TInput not initialized." << endl; cout << "ERROR!: TInput not initialized." << endl; return; } T::mainloop(); } /** * Get socket name. * Socket name is equal to FSM id. * * @return Socket name */ string get_socket_name() { if (!initialized) { //FSMLOG(0) << "ERROR!: TInput not initialized." << endl; cout << "ERROR!: TInput not initialized." << endl; return 0; } return tInput_gcs::socket_name; } /** * Unregister machine * Deletes socket and unsubscribes machine from messsage lists * */ void unregister_machine(u_int16_t sn) {} void set_event_handler(tEvent *handler) { ev=handler; T::init(ev); } protected: tEvent *ev; private: string socket_name; /**< Socket name */ bool initialized; /**< initilized flag */ void check_socket_dir() { DIR *dirStructP; if((dirStructP = opendir(SOCKET_DIR)) == NULL) { if (errno == ENOENT) { // Doesn't exist mkdir(SOCKET_DIR, 0766); // Create directory } else { // FIXME: Either we don't have access permissions to this dir or a fatal error // has ocurred. We should throw a very big exception here and maybe exit. // exit(1); } } } /** * Finds the first avalable id in SOCKET_DIR * */ string reserve_socket_server() { // ---------------------------------------------------------------- // machine id = socket_name // ---------------------------------------------------------------- DIR *dirStructP; dirent *direntp; char *n; bool digit, used_sockets[MAX_MACHINE]; u_int16_t i; for(i=0; i < MAX_MACHINE; i++) used_sockets[i]=false; if((dirStructP = opendir(SOCKET_DIR)) != NULL) { // Search a free socket while((direntp = readdir(dirStructP)) != NULL) { n = direntp->d_name; for (register char *i=n;*i;++i) { if (isdigit(*i)) digit=1; else { digit=0; break; } } if (!digit)continue; used_sockets[atoi(n)]=true; } closedir(dirStructP); } else { if (errno == ENOENT) { // Doesn't exist mkdir(SOCKET_DIR, 0766); // Create directory } else { // FIXME: Either we don't have access permissions to this dir or a fatal error // has ocurred. We should throw a very big exception here and maybe exit. // exit(1); } } // Find first available for(i=0; i < MAX_MACHINE; i++) if(!used_sockets[i]) break; if (i >= (MAX_MACHINE)) { //FSMLOG(0) << "Max. number of FSM is " << MAX_MACHINE<< endl; // FIXME: We should throw a fatal exception and exit. exit(1); } char *socket_path=new char[104]; // This isn't a memory leak coz tFSM class uses this pointer. So it is responsible of it. char tmp[5]; strncpy(socket_path,SOCKET_DIR,99); // 99 = 104 - 5 104 is the maximum length of a unix socket path UNP sprintf(tmp,"/%d",i); strncat(socket_path,tmp,5); // There won't be more than 999 machines // Create file ofstream fs (socket_path, ofstream::out | ofstream::trunc); fs.close(); //FSMLOG(3) <<"SN:"<< socket_path << " CNT: "<<i<<endl ; sprintf (socket_path,"%d",i); return socket_path ; } }; #endif //CINPUT_GCS_H Index: tinput.h =================================================================== RCS file: /cvsroot/dfsm/dFSM/include/libdfsm/tinput.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tinput.h 3 Apr 2004 06:32:01 -0000 1.17 --- tinput.h 7 Apr 2004 03:44:27 -0000 1.18 *************** *** 32,35 **** --- 32,38 ---- * $Revision$ * $Log$ + * Revision 1.18 2004/04/07 03:44:27 amoreno + * Add Spread Group Communication System support + * * Revision 1.17 2004/04/03 06:32:01 amoreno * Add support for manual and automatic state machine identification *************** *** 109,112 **** --- 112,119 ---- #include "libposixwrap/tthread.h" + #if defined SPREAD + #include "libdfsm/tinput_gcs.h" + #endif + using namespace std; *************** *** 232,240 **** --- 239,256 ---- ~tInput_service(){}; void run(){ thread_input.start(); }; + #if defined SPREAD + tInput_gcs<tSpread> *get_pointer(){ return thread_input.pointer(); }; + #else tInput *get_pointer(){ return thread_input.pointer(); }; + #endif protected: private: + #if defined SPREAD + tThread <tInput_gcs<tSpread> > thread_input ; + tInput_gcs<tSpread> *tInputp ; + #else tThread <tInput> thread_input ; tInput *tInputp ; + #endif }; #define tinput_service tInput_service::getInstance() --- NEW FILE: tspread.h --- /*************************************************************************** tspread.h - <to do description> ------------------- begin : 03/march/2004 copyright : (C) 2004 by Andreu Moreno email : am...@eu... ***************************************************************************/ /*************************************************************************** * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ***************************************************************************/ /* * * $Author: amoreno $ * $Revision: 1.1 $ * $Log: tspread.h,v $ * Revision 1.1 2004/04/07 03:44:27 amoreno * Add Spread Group Communication System support * * Revision 1.10 2004/01/02 08:04:18 amoreno * */ #ifdef SPREAD #ifndef TSPREAD_H #define TSPREAD_H #include "libdfsm/tgcs.h" #include <sp.h> #define CONNECT_TIMEOUT 5 /** * Class tgcs. Group Communication System for dFSM */ class tSpread : public tGcs { public: /** * Configure Group Communication System * * @param ev Event List * @return True if ok */ bool init(tEvent *ev); /** * Join group associated to event id_msg * * * @param id_msg Message id. * @return true if OK */ bool join(u_int16_t id_msg); /** * Leave group associated to event id_msg * * * @param id_msg Message id. * @return true if OK */ bool leave(u_int16_t id_msg); /** * Send a message to other machines using Group Communication System * A list of machines is subscribed to a message id (id_msg). When this function is invoked a message * of id_msg kind is sended to every subscribed machine. * * @param id_msg Message id. * @param data Extra data * @param len Length data * @return Bytes sended */ int send(u_int16_t id_msg, const char *data=0,u_int16_t len=0); /** * Receive message callback * * @param fd fd. * @param code code * @param data data */ static void receive(int fd, int code, void *data); /** * Get connection identification * * @param id identification */ void getid(char *id); /** * Main loop * Handle events * * */ void mainloop(void); private: static mailbox Mbox; /**< Spread Id connection */ char User[80]; /**< Private name connection */ char Spread_name[80]; /**< Spread name daemon */ char Private_group[MAX_GROUP_NAME]; /**< Private Group Name */ static tEvent *ev; /**< Event handler */ }; #endif //TSPREAD_H #endif //SPREAD --- NEW FILE: tgcs.h --- /*************************************************************************** tgcs.h - <to do description> ------------------- begin : 03/march/2004 copyright : (C) 2004 by Andreu Moreno email : am...@eu... ***************************************************************************/ /*************************************************************************** * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ***************************************************************************/ /* * * $Author: amoreno $ * $Revision: 1.1 $ * $Log: tgcs.h,v $ * Revision 1.1 2004/04/07 03:44:27 amoreno * Add Spread Group Communication System support * * Revision 1.10 2004/01/02 08:04:18 amoreno * */ #ifndef TGCS_H #define TGCS_H #include <sys/types.h> #include "libdfsm/tevent.h" /** * Class tgcs. Group Communication System for dFSM */ class tGcs { public: virtual ~tGcs(){} /** * Configure Group Communication System * * @param ev Event List * @return True if ok */ virtual bool init(tEvent *ev) = 0; /** * Join group associated to event id_msg * * * @param id_msg Message id. * @return true if OK */ virtual bool join(u_int16_t id_msg) = 0; /** * Leave group associated to event id_msg * * * @param id_msg Message id. * @return true if OK */ virtual bool leave(u_int16_t id_msg) = 0; /** * Send a message to other machines using Group Communication System * A list of machines is subscribed to a message id (id_msg). When this function is invoked a message * of id_msg kind is sended to every subscribed machine. * * @param id_msg Message id. * @param data Extra data * @param len Length data * @return Bytes sended */ virtual int send(u_int16_t id_msg, const char *data=0,u_int16_t len=0) = 0; /** * Main loop * Handle events * * */ virtual void mainloop(void) = 0; }; #endif //TGCS_H |
|
From: Andreu M. <am...@us...> - 2004-04-07 03:57:22
|
Update of /cvsroot/dfsm/dFSM/src/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23396/src/test Modified Files: Makefile Log Message: Add Spread Group Communication System support Index: Makefile =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/test/Makefile,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Makefile 5 Mar 2004 18:41:15 -0000 1.10 --- Makefile 7 Apr 2004 03:44:27 -0000 1.11 *************** *** 1,7 **** INCLUDEDIR= -I ../../include LIBDIR= -L ../../lib ! LIBRARIES= -lpthread -lstdc++ -ldfsm -lposixwrap LIBDEPENDS= ../../lib/libdfsm.so ! CPPFLAGS= -g -fPIC -DPIC CXX= g++ SRC:= $(wildcard *.cpp) --- 1,7 ---- INCLUDEDIR= -I ../../include LIBDIR= -L ../../lib ! LIBRARIES= -lpthread -lstdc++ -ldfsm -lposixwrap $(GCSLIBS) LIBDEPENDS= ../../lib/libdfsm.so ! CPPFLAGS= -g -fPIC -DPIC $(GCSFLAGS) CXX= g++ SRC:= $(wildcard *.cpp) |
|
From: Andreu M. <am...@us...> - 2004-04-06 06:09:39
|
Update of /cvsroot/dfsm/dFSM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3693 Modified Files: VERSION Log Message: VERSION adjust Index: VERSION =================================================================== RCS file: /cvsroot/dfsm/dFSM/VERSION,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VERSION 16 Jul 2003 09:42:56 -0000 1.2 --- VERSION 6 Apr 2004 05:56:54 -0000 1.3 *************** *** 1 **** ! 0.6 --- 1 ---- ! 0.7 |
|
From: Andreu M. <am...@us...> - 2004-04-05 06:32:33
|
Update of /cvsroot/dfsm/dFSM/src/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9140/src/libdfsm Modified Files: sm_lists.cpp sm_route_table.cpp sm_seq.cpp tinput.cpp Log Message: Bug cleaning due to inadequate shared segment initialization Index: sm_lists.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/sm_lists.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sm_lists.cpp 19 Mar 2004 21:05:09 -0000 1.6 --- sm_lists.cpp 5 Apr 2004 06:19:57 -0000 1.7 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.7 2004/04/05 06:19:57 amoreno + * Bug cleaning due to inadequate shared segment initialization + * * Revision 1.6 2004/03/19 21:05:09 jvalduvieco * Prerelease cleanup. *************** *** 77,81 **** key = LISTS_ID_MEMORY_KEY; shared_segment_size = LISTS_TOTAL_SIZE; ! machine = machinep; --- 80,85 ---- key = LISTS_ID_MEMORY_KEY; shared_segment_size = LISTS_TOTAL_SIZE; ! struct shmid_ds buf; ! machine = machinep; *************** *** 92,96 **** } ! if (init && machine == 0) { // If is the first machine, reset to 0 // FIXME: with sockt reutilization, this feature can be dangerous // if a fsm restarts with socket 0 and clean others still runnig fsm's --- 96,102 ---- } ! shmctl(segment_id, IPC_STAT, &buf); ! ! if ((buf.shm_nattch == 1) || (init && machine == 0)) { // If is the first machine, reset to 0 // FIXME: with sockt reutilization, this feature can be dangerous // if a fsm restarts with socket 0 and clean others still runnig fsm's *************** *** 120,125 **** ! if ((init && machine == 0) || (*signature != LISTS_SIGNATURE)) ! // if ((init && machine == 0)) { *signature = LISTS_SIGNATURE; --- 126,130 ---- ! if ((buf.shm_nattch == 1) || (init && machine == 0) || (*signature != LISTS_SIGNATURE)) { *signature = LISTS_SIGNATURE; *************** *** 128,132 **** } ! if ((init && machine == 0)) { --- 133,137 ---- } ! if ((buf.shm_nattch == 1) || (init && machine == 0)) { Index: tinput.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/tinput.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tinput.cpp 3 Apr 2004 06:32:01 -0000 1.23 --- tinput.cpp 5 Apr 2004 06:19:57 -0000 1.24 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.24 2004/04/05 06:19:57 amoreno + * Bug cleaning due to inadequate shared segment initialization + * * Revision 1.23 2004/04/03 06:32:01 amoreno * Add support for manual and automatic state machine identification *************** *** 221,225 **** if(sockfd == -1) { FSMLOG(1) <<"Error creating socket: "<<strerror(errno)<<endl; ! //tInput::unregister_machine((*vns_i)); } // Name the socket, as agreed with the server --- 224,228 ---- if(sockfd == -1) { FSMLOG(1) <<"Error creating socket: "<<strerror(errno)<<endl; ! tInput::unregister_machine((*vns_i)); } // Name the socket, as agreed with the server *************** *** 236,240 **** // Unregister machine (socket), clean exit. FSMLOG(2) <<"Unregistering |"<<address.sun_path<<"|"<<endl; ! //tInput::unregister_machine((*vns_i)); } else --- 239,243 ---- // Unregister machine (socket), clean exit. FSMLOG(2) <<"Unregistering |"<<address.sun_path<<"|"<<endl; ! tInput::unregister_machine((*vns_i)); } else *************** *** 247,251 **** // Unregister machine (socket), clean exit. FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; ! //tInput::unregister_machine((*vns_i)); } else --- 250,254 ---- // Unregister machine (socket), clean exit. FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; ! tInput::unregister_machine((*vns_i)); } else *************** *** 312,316 **** if(sockfd == -1) { FSMLOG(1) <<"Error creating socket: "<<strerror(errno)<<endl; ! //tInput::unregister_machine(machine); } // Name the socket, as agreed with the server --- 315,319 ---- if(sockfd == -1) { FSMLOG(1) <<"Error creating socket: "<<strerror(errno)<<endl; ! tInput::unregister_machine(machine); } // Name the socket, as agreed with the server *************** *** 326,330 **** // Unregister machine (socket), clean exit. FSMLOG(2) <<"Unregistering |"<<address.sun_path<<"|"<<endl; ! //tInput::unregister_machine(machine); } else --- 329,333 ---- // Unregister machine (socket), clean exit. FSMLOG(2) <<"Unregistering |"<<address.sun_path<<"|"<<endl; ! tInput::unregister_machine(machine); } else *************** *** 337,341 **** // Unregister machine (socket), clean exit. FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; ! //tInput::unregister_machine(machine); } else --- 340,344 ---- // Unregister machine (socket), clean exit. FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; ! tInput::unregister_machine(machine); } else Index: sm_route_table.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/sm_route_table.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** sm_route_table.cpp 30 Mar 2004 15:12:31 -0000 1.11 --- sm_route_table.cpp 5 Apr 2004 06:19:57 -0000 1.12 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.12 2004/04/05 06:19:57 amoreno + * Bug cleaning due to inadequate shared segment initialization + * * Revision 1.11 2004/03/30 15:12:31 amoreno * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq *************** *** 86,90 **** tsm_route_table::shared_segment_size = (MAX_MACHINE*MAX_MSG)/8; key_t key; ! key = OUR_ID_MEMORY_KEY; --- 89,94 ---- tsm_route_table::shared_segment_size = (MAX_MACHINE*MAX_MSG)/8; key_t key; ! struct shmid_ds buf; ! key = OUR_ID_MEMORY_KEY; *************** *** 105,109 **** } ! if (init && machine == 0) { // If is the first machine, reset to 0 // FIXME: with sockt reutilization, this feature can be dangerous // if a fsm restarts with socket 0 and clean others still runnig fsm's --- 109,115 ---- } ! shmctl(tsm_route_table::segment_id , IPC_STAT, &buf); // To better control shared segment initialization ! ! if ((buf.shm_nattch == 1) || (init && machine == 0)) { // If is the first machine, reset to 0 // FIXME: with sockt reutilization, this feature can be dangerous // if a fsm restarts with socket 0 and clean others still runnig fsm's Index: sm_seq.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/sm_seq.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sm_seq.cpp 30 Mar 2004 15:12:31 -0000 1.5 --- sm_seq.cpp 5 Apr 2004 06:19:57 -0000 1.6 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.6 2004/04/05 06:19:57 amoreno + * Bug cleaning due to inadequate shared segment initialization + * * Revision 1.5 2004/03/30 15:12:31 amoreno * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq *************** *** 55,58 **** --- 58,62 ---- { tsm_seq::shared_segment_size = 0x1; // One page of shm please. + struct shmid_ds buf; key_t key; *************** *** 75,79 **** } ! if (machine == 1) { // If is the first machine, reset to 0 *(tsm_seq::shared_memory) = 0; } --- 79,85 ---- } ! shmctl(tsm_seq::segment_id, IPC_STAT, &buf); // To better control shared segment initialization ! ! if ((buf.shm_nattch == 1) || ( machine == 0)) { // If is the first machine, reset to 0 *(tsm_seq::shared_memory) = 0; } |
|
From: Andreu M. <am...@us...> - 2004-04-03 06:44:18
|
Update of /cvsroot/dfsm/dFSM/src/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1816/src/test Modified Files: test1.cpp test1.ini test2.cpp test3.cpp test4.ini test4_1.cpp test4_2.cpp test5.cpp Log Message: Add support for manual and automatic state machine identification Index: test1.ini =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/test/test1.ini,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test1.ini 24 Dec 2003 05:36:52 -0000 1.2 --- test1.ini 3 Apr 2004 06:32:01 -0000 1.3 *************** *** 1,4 **** [Automata 1] #Comentari ! command = ./test1 -d 3 -l 3 #Comentari delay = 2 syncevent = 10 --- 1,4 ---- [Automata 1] #Comentari ! command = ./test1 -i 1 -d 3 -l 3 #Comentari delay = 2 syncevent = 10 *************** *** 10,14 **** [Automata 2] #Comentari ! command = ./test1 -d 3 -l 3 #Comentari delay = 2 syncevent = 10 --- 10,14 ---- [Automata 2] #Comentari ! command = ./test1 -i 2 -d 3 -l 3 #Comentari delay = 2 syncevent = 10 Index: test4_2.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/test/test4_2.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test4_2.cpp 29 Aug 2003 22:22:28 -0000 1.9 --- test4_2.cpp 3 Apr 2004 06:32:01 -0000 1.10 *************** *** 26,29 **** --- 26,32 ---- * $Revision$ * $Log$ + * Revision 1.10 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.9 2003/08/29 22:22:28 amoreno * Solved bug with more that 8 machines, add Test5 to create a automate chain and some includes staff *************** *** 51,54 **** --- 54,59 ---- #include "libdfsm/ttransition.h" + #define TEST4_2_MACHINE_ID 2 + #define S1_MSG "State_S1 data" #define S2_MSG "State_S2 data" *************** *** 288,291 **** --- 293,297 ---- cout << " -l : Internal log level of dFSM" << endl; cout << " -d : log level of user states" << endl; + cout << " -i : Machine identification" << endl; cout << endl; } *************** *** 294,298 **** int main (int argc, char* argv[]) { ! int i=0, l=0, d=0; tFSM *fsm; tState *s0, *s1, *s2, *s3, *s4, *s5, *s6, *s7, *s8, *s9; // State pointers. One for each state. --- 300,304 ---- int main (int argc, char* argv[]) { ! int i=0, l=0, d=0, ident=TEST4_2_MACHINE_ID; tFSM *fsm; tState *s0, *s1, *s2, *s3, *s4, *s5, *s6, *s7, *s8, *s9; // State pointers. One for each state. *************** *** 328,331 **** --- 334,344 ---- } + if (argv[i][1] == 'i') + { + sscanf(argv[i+1], "%d", &ident); + i++; + continue; + } + cerr << "Bad parameter: " << argv[i][1] << endl; return -1; *************** *** 334,338 **** ! fsm = new tFSM("Test machine 4_2", l); // We need one tFSM object for each FSM :) LOGINIT; --- 347,351 ---- ! fsm = new tFSM(ident, "Test machine 4_2", l); // We need one tFSM object for each FSM :) LOGINIT; *************** *** 480,482 **** // is invoked state execution does not begin. } - --- 493,494 ---- Index: test4.ini =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/test/test4.ini,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test4.ini 6 Dec 2003 06:04:14 -0000 1.1 --- test4.ini 3 Apr 2004 06:32:01 -0000 1.2 *************** *** 1,6 **** [Automata 1] #Comentari ! command = ./test4_1 -d 3 -l 3 #Comentari delay = 2 [Automata 2] ! command = ./test4_2 -d 3 -l 3 #Comentari delay = 2 --- 1,6 ---- [Automata 1] #Comentari ! command = ./test4_1 -i 1 -d 3 -l 3 #Comentari delay = 2 [Automata 2] ! command = ./test4_2 -i 2 -d 3 -l 3 #Comentari delay = 2 Index: test2.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/test/test2.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test2.cpp 26 Dec 2003 07:13:05 -0000 1.12 --- test2.cpp 3 Apr 2004 06:32:01 -0000 1.13 *************** *** 24,27 **** --- 24,30 ---- * $Revision$ * $Log$ + * Revision 1.13 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.12 2003/12/26 07:13:05 amoreno * Add clear history command *************** *** 60,63 **** --- 63,68 ---- #include "libdfsm/ttransition.h" + #define TEST2_MACHINE_ID 1 + struct tState_ROOT :public tState { void entry_func() *************** *** 272,275 **** --- 277,281 ---- cout << " -l : Internal log level of dFSM" << endl; cout << " -d : log level of user states" << endl; + cout << " -i : Machine identification" << endl; cout << endl; } *************** *** 278,282 **** int main (int argc, char* argv[]) { ! int i=0, l=0, d=0; tFSM *fsm; tState *root,*s0, *s1, *s2, *s3,*s4,*s5,*s6,*s7,*s8,*s9,*s10,*s11,*s12,*s13,*s14; // State pointers. One for each state. --- 284,288 ---- int main (int argc, char* argv[]) { ! int i=0, l=0, d=0, ident=TEST2_MACHINE_ID; tFSM *fsm; tState *root,*s0, *s1, *s2, *s3,*s4,*s5,*s6,*s7,*s8,*s9,*s10,*s11,*s12,*s13,*s14; // State pointers. One for each state. *************** *** 309,312 **** --- 315,325 ---- } + if (argv[i][1] == 'i') + { + sscanf(argv[i+1], "%d", &ident); + i++; + continue; + } + cerr << "Bad parameter: " << argv[i][1] << endl; return -1; *************** *** 315,319 **** ! fsm = new tFSM("Test machine", l); // We need one tFSM object for each FSM :) LOGINIT; --- 328,332 ---- ! fsm = new tFSM(TEST2_MACHINE_ID, "Test machine", l); // We need one tFSM object for each FSM :) LOGINIT; Index: test1.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/test/test1.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test1.cpp 17 Mar 2004 14:43:52 -0000 1.19 --- test1.cpp 3 Apr 2004 06:32:01 -0000 1.20 *************** *** 24,27 **** --- 24,30 ---- * $Revision$ * $Log$ + * Revision 1.20 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.19 2004/03/17 14:43:52 amoreno * Add tInput interface to tInput_service, replace calls to tInput with calls to tInput_service and add sending events to timer. *************** *** 92,95 **** --- 95,99 ---- #include "libdfsm/ttimer_service.h" + #define TEST1_MACHINE_ID 1 struct tState_ROOT :public tState { *************** *** 240,243 **** --- 244,248 ---- cout << " -l : Internal log level of dFSM (default: 3)" << endl; cout << " -d : log level of user states (default: 3)" << endl; + cout << " -i : Machine identification" << endl; cout << endl; } *************** *** 245,249 **** int main (int argc, char* argv[]) { ! int i=0, l=3, d=3; tFSM *fsm; tState *root,*s0, *s1, *s2, *s3, *s4; // State pointers. One for each state. --- 250,254 ---- int main (int argc, char* argv[]) { ! int i=0, l=3, d=3, ident=TEST1_MACHINE_ID; tFSM *fsm; tState *root,*s0, *s1, *s2, *s3, *s4; // State pointers. One for each state. *************** *** 276,279 **** --- 281,291 ---- } + if (argv[i][1] == 'i') + { + sscanf(argv[i+1], "%d", &ident); + i++; + continue; + } + cerr << "Bad parameter: " << argv[i][1] << endl; return -1; *************** *** 282,286 **** ! fsm = new tFSM("Test machine", l); // We need one tFSM object for each FSM :) LOGINIT; --- 294,298 ---- ! fsm = new tFSM(ident, "Test machine", l); // We need one tFSM object for each FSM :) LOGINIT; Index: test3.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/test/test3.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test3.cpp 12 Sep 2003 16:29:13 -0000 1.9 --- test3.cpp 3 Apr 2004 06:32:01 -0000 1.10 *************** *** 25,28 **** --- 25,31 ---- * $Revision$ * $Log$ + * Revision 1.10 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.9 2003/09/12 16:29:13 jvalduvieco * Worked on several aspects: *************** *** 58,61 **** --- 61,66 ---- #include "libdfsm/ttransition.h" + #define TEST3_MACHINE_ID 1 + struct tState_S1 :public tState { void entry_func() *************** *** 208,211 **** --- 213,217 ---- cout << " -l : Internal log level of dFSM" << endl; cout << " -d : log level of user states" << endl; + cout << " -i : Machine identification" << endl; cout << endl; } *************** *** 214,218 **** int main (int argc, char* argv[]) { ! int i=0, l=0, d=0; tFSM *fsm; tState *s1, *s11, *s12, *s111, *s112, *s1121, *s1122; // State pointers. One for each state. --- 220,224 ---- int main (int argc, char* argv[]) { ! int i=0, l=0, d=0, ident=TEST3_MACHINE_ID; tFSM *fsm; tState *s1, *s11, *s12, *s111, *s112, *s1121, *s1122; // State pointers. One for each state. *************** *** 246,249 **** --- 252,262 ---- } + if (argv[i][1] == 'i') + { + sscanf(argv[i+1], "%d", &ident); + i++; + continue; + } + cerr << "Bad parameter: " << argv[i][1] << endl; return -1; *************** *** 252,256 **** ! fsm = new tFSM("Test machine", l); // We need one tFSM object for each FSM :) LOGINIT; --- 265,269 ---- ! fsm = new tFSM(TEST3_MACHINE_ID, "Test machine", l); // We need one tFSM object for each FSM :) LOGINIT; *************** *** 370,374 **** fsm->add_transition(t9); ! clog << "Transition added"<<endl; --- 383,387 ---- fsm->add_transition(t9); ! //clog << "Transition added"<<endl; *************** *** 392,394 **** // is invoked state execution does not begin. } - --- 405,406 ---- Index: test5.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/test/test5.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test5.cpp 29 Aug 2003 22:22:28 -0000 1.1 --- test5.cpp 3 Apr 2004 06:32:01 -0000 1.2 *************** *** 24,27 **** --- 24,30 ---- * $Revision$ * $Log$ + * Revision 1.2 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.1 2003/08/29 22:22:28 amoreno * Solved bug with more that 8 machines, add Test5 to create a automate chain and some includes staff *************** *** 90,93 **** --- 93,97 ---- cout << " -n : Event to send in transition action" << endl; cout << " -f : Event to send in first transition" << endl; + cout << " -i : Machine identification" << endl; cout << endl; } *************** *** 95,99 **** int main (int argc, char* argv[]) { ! int i=0, l=3, d=3; tFSM *fsm; tState *root,*s0; // State pointers. One for each state. --- 99,103 ---- int main (int argc, char* argv[]) { ! int i=0, l=3, d=3, ident=-1; tFSM *fsm; tState *root,*s0; // State pointers. One for each state. *************** *** 145,149 **** continue; } ! cerr << "Bad parameter: " << argv[i][1] << endl; return -1; --- 149,159 ---- continue; } ! if (argv[i][1] == 'i') ! { ! sscanf(argv[i+1], "%d", &ident); ! i++; ! continue; ! } ! cerr << "Bad parameter: " << argv[i][1] << endl; return -1; *************** *** 157,162 **** } ! fsm = new tFSM("Test machine", l); // We need one tFSM object for each FSM :) LOGINIT; --- 167,173 ---- } + if (ident == -1) ident = event; ! fsm = new tFSM(ident, "Test machine", l); // We need one tFSM object for each FSM :) LOGINIT; *************** *** 211,213 **** // is invoked state execution does not begin. } - --- 222,223 ---- Index: test4_1.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/test/test4_1.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test4_1.cpp 11 Mar 2004 13:59:33 -0000 1.10 --- test4_1.cpp 3 Apr 2004 06:32:01 -0000 1.11 *************** *** 26,29 **** --- 26,32 ---- * $Revision$ * $Log$ + * Revision 1.11 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.10 2004/03/11 13:59:33 amoreno * Initialize data pointer and bug cleaning data_run management *************** *** 57,60 **** --- 60,66 ---- * $Revision$ * $Log$ + * Revision 1.11 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.10 2004/03/11 13:59:33 amoreno * Initialize data pointer and bug cleaning data_run management *************** *** 88,91 **** --- 94,99 ---- #include "libdfsm/ttransition.h" + #define TEST4_1_MACHINE_ID 1 + struct tState_S0 :public tState { void entry_func() *************** *** 189,192 **** --- 197,201 ---- cout << " -l : Internal log level of dFSM" << endl; cout << " -d : log level of user states" << endl; + cout << " -i : Machine identification" << endl; cout << endl; } *************** *** 194,198 **** int main (int argc, char* argv[]) { ! int i=0, l=0, d=0; tFSM *fsm; tState *s0, *s1, *s2, *s3, *s4; // State pointers. One for each state. --- 203,207 ---- int main (int argc, char* argv[]) { ! int i=0, l=0, d=0, ident=TEST4_1_MACHINE_ID; tFSM *fsm; tState *s0, *s1, *s2, *s3, *s4; // State pointers. One for each state. *************** *** 226,229 **** --- 235,246 ---- } + if (argv[i][1] == 'i') + { + sscanf(argv[i+1], "%d", &ident); + i++; + continue; + } + + cerr << "Bad parameter: " << argv[i][1] << endl; return -1; *************** *** 231,235 **** } ! fsm = new tFSM("Test machine 4_1", l); // We need one tFSM object for each FSM :) LOGINIT; --- 248,252 ---- } ! fsm = new tFSM(ident, "Test machine 4_1", l); // We need one tFSM object for each FSM :) LOGINIT; |
|
From: Andreu M. <am...@us...> - 2004-04-03 06:44:17
|
Update of /cvsroot/dfsm/dFSM/src/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1816/src/utils Modified Files: dfsm_monitor.cpp send_to.cpp supervisor.cpp Log Message: Add support for manual and automatic state machine identification Index: send_to.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/utils/send_to.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** send_to.cpp 31 Mar 2004 16:42:20 -0000 1.6 --- send_to.cpp 3 Apr 2004 06:32:02 -0000 1.7 *************** *** 25,28 **** --- 25,29 ---- #include "libdfsm/tevent.h" + #define SENDTO_MACHINE_ID 126 int main(int argc, char *argv[]) *************** *** 36,39 **** --- 37,42 ---- return 0; } + + tinputs->init(SENDTO_MACHINE_ID); machine_n=atoi(argv[1]); Index: supervisor.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/utils/supervisor.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** supervisor.cpp 31 Mar 2004 16:42:20 -0000 1.9 --- supervisor.cpp 3 Apr 2004 06:32:02 -0000 1.10 *************** *** 21,24 **** --- 21,27 ---- * $Revision$ * $Log$ + * Revision 1.10 2004/04/03 06:32:02 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.9 2004/03/31 16:42:20 amoreno * Tinput interface supports send and send_to (useful for utilities) and change monitor as service *************** *** 106,109 **** --- 109,113 ---- #define MAXARGV 32 + #define SUPERVISOR_MACHINE_ID 127 struct automata *************** *** 221,224 **** --- 225,230 ---- // Setup Input_service + + tinputs->init(SUPERVISOR_MACHINE_ID); tinputs->set_event_handler(events); tinput_service->run(); Index: dfsm_monitor.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/utils/dfsm_monitor.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dfsm_monitor.cpp 31 Mar 2004 16:42:20 -0000 1.12 --- dfsm_monitor.cpp 3 Apr 2004 06:32:02 -0000 1.13 *************** *** 21,24 **** --- 21,27 ---- * $Revision$ * $Log$ + * Revision 1.13 2004/04/03 06:32:02 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.12 2004/03/31 16:42:20 amoreno * Tinput interface supports send and send_to (useful for utilities) and change monitor as service *************** *** 95,98 **** --- 98,102 ---- #include "libdfsm/tevent.h" + #define MONITOR_MACHINE_ID 126 tEvent *events; *************** *** 374,377 **** --- 378,382 ---- // Setup Input_service tEvent *events = new tEvent(); + tinputs->init(MONITOR_MACHINE_ID); tinputs->set_event_handler(events); //tinput_service->run(); |
|
From: Andreu M. <am...@us...> - 2004-04-03 06:44:16
|
Update of /cvsroot/dfsm/dFSM/src/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1816/src/libdfsm Modified Files: tfsm.cpp tinput.cpp Log Message: Add support for manual and automatic state machine identification Index: tfsm.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/tfsm.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** tfsm.cpp 31 Mar 2004 16:42:20 -0000 1.33 --- tfsm.cpp 3 Apr 2004 06:32:01 -0000 1.34 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.34 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.33 2004/03/31 16:42:20 amoreno * Tinput interface supports send and send_to (useful for utilities) and change monitor as service *************** *** 161,165 **** ! tFSM::tFSM(const char *name, u_int8_t log_level, const char* file) { char buf[6]; --- 164,168 ---- ! tFSM::tFSM(u_int16_t machine_id, const char *name, u_int8_t log_level, const char* file) { char buf[6]; *************** *** 184,187 **** --- 187,192 ---- tFSM::events = new tEvent(); + if (machine_id == MACHINE_ID_AUTO) tinputs->init(); + else tinputs->init(machine_id); tinputs->set_event_handler(tFSM::events); tFSM::transition_rep=new tTransition_rep(); Index: tinput.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/tinput.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tinput.cpp 31 Mar 2004 16:42:20 -0000 1.22 --- tinput.cpp 3 Apr 2004 06:32:01 -0000 1.23 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.23 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.22 2004/03/31 16:42:20 amoreno * Tinput interface supports send and send_to (useful for utilities) and change monitor as service *************** *** 136,143 **** tInput::tInput() { ! tInput::socket_name = tInput::reserve_socket_server(); ! tInput::sm = new tsm_route_table(atoi(tInput::socket_name), true); ! tInput::sm_seq = new tsm_seq(atoi(tInput::socket_name)); ! FSMLOG(3) << "TInput constructor. Socket name: "<<tInput::socket_name<<endl; } tInput::~tInput() --- 139,143 ---- tInput::tInput() { ! initialized = false; } tInput::~tInput() *************** *** 145,148 **** --- 145,169 ---- } + bool tInput::init() + { + tInput::socket_name = tInput::reserve_socket_server(); + tInput::sm = new tsm_route_table(atoi(tInput::socket_name), true); + tInput::sm_seq = new tsm_seq(atoi(tInput::socket_name)); + FSMLOG(3) << "TInput initr. Socket name: "<<tInput::socket_name<<endl; + initialized = true; + return true; + } + + bool tInput::init(u_int16_t machine_id) + { + check_socket_dir(); + tInput::socket_name = new char[10]; + sprintf (tInput::socket_name, "%d", machine_id); + tInput::sm = new tsm_route_table(machine_id, true); + tInput::sm_seq = new tsm_seq(machine_id); + FSMLOG(3) << "TInput init. Machine id: "<<machine_id<<endl; + initialized = true; + return true; + } // This is a BSAD. Maybe we should put a wrapper method and make this one private. *************** *** 157,160 **** --- 178,187 ---- char *ptr; + if (!initialized) + { + FSMLOG(0) << "ERROR!: TInput not initialized." << endl; + return 0; + } + if (sizeof(msg)>MAX_PACKET_SIZE) { *************** *** 194,198 **** if(sockfd == -1) { FSMLOG(1) <<"Error creating socket: "<<strerror(errno)<<endl; ! tInput::unregister_machine((*vns_i)); } // Name the socket, as agreed with the server --- 221,225 ---- if(sockfd == -1) { FSMLOG(1) <<"Error creating socket: "<<strerror(errno)<<endl; ! //tInput::unregister_machine((*vns_i)); } // Name the socket, as agreed with the server *************** *** 209,213 **** // Unregister machine (socket), clean exit. FSMLOG(2) <<"Unregistering |"<<address.sun_path<<"|"<<endl; ! tInput::unregister_machine((*vns_i)); } else --- 236,240 ---- // Unregister machine (socket), clean exit. FSMLOG(2) <<"Unregistering |"<<address.sun_path<<"|"<<endl; ! //tInput::unregister_machine((*vns_i)); } else *************** *** 220,224 **** // Unregister machine (socket), clean exit. FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; ! tInput::unregister_machine((*vns_i)); } else --- 247,251 ---- // Unregister machine (socket), clean exit. FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; ! //tInput::unregister_machine((*vns_i)); } else *************** *** 247,250 **** --- 274,283 ---- char *ptr; + if (!initialized) + { + FSMLOG(0) << "ERROR!: TInput not initialized." << endl; + return 0; + } + if (sizeof(msg)>MAX_PACKET_SIZE) { *************** *** 279,283 **** if(sockfd == -1) { FSMLOG(1) <<"Error creating socket: "<<strerror(errno)<<endl; ! tInput::unregister_machine(machine); } // Name the socket, as agreed with the server --- 312,316 ---- if(sockfd == -1) { FSMLOG(1) <<"Error creating socket: "<<strerror(errno)<<endl; ! //tInput::unregister_machine(machine); } // Name the socket, as agreed with the server *************** *** 293,297 **** // Unregister machine (socket), clean exit. FSMLOG(2) <<"Unregistering |"<<address.sun_path<<"|"<<endl; ! tInput::unregister_machine(machine); } else --- 326,330 ---- // Unregister machine (socket), clean exit. FSMLOG(2) <<"Unregistering |"<<address.sun_path<<"|"<<endl; ! //tInput::unregister_machine(machine); } else *************** *** 304,308 **** // Unregister machine (socket), clean exit. FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; ! tInput::unregister_machine(machine); } else --- 337,341 ---- // Unregister machine (socket), clean exit. FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; ! //tInput::unregister_machine(machine); } else *************** *** 321,325 **** ! const char *tInput::reserve_socket_server() { // ---------------------------------------------------------------- --- 354,376 ---- ! void tInput::check_socket_dir() ! { ! DIR *dirStructP; ! if((dirStructP = opendir(SOCKET_DIR)) == NULL) ! { ! if (errno == ENOENT) ! { // Doesn't exist ! mkdir(SOCKET_DIR, 0766); // Create directory ! } ! else ! { ! // FIXME: Either we don't have access permissions to this dir or a fatal error ! // has ocurred. We should throw a very big exception here and maybe exit. ! // exit(1); ! } ! } ! } ! ! char *tInput::reserve_socket_server() { // ---------------------------------------------------------------- *************** *** 391,394 **** --- 442,446 ---- } + void tInput::run() { *************** *** 402,405 **** --- 454,463 ---- tEvent::Event event; + if (!initialized) + { + FSMLOG(0) << "ERROR!: TInput not initialized." << endl; + return ; + } + client_len=sizeof(client_address); server_len = sizeof(server_address); *************** *** 467,470 **** --- 525,534 ---- const char *tInput::get_socket_name() const { + if (!initialized) + { + FSMLOG(0) << "ERROR!: TInput not initialized." << endl; + return ""; + } + return tInput::socket_name; } *************** *** 473,477 **** { // Unregister a machine (socket) ! tInput::sm->del_machine(machine_number); // Delete related routes --- 537,547 ---- { // Unregister a machine (socket) ! ! if (!initialized) ! { ! FSMLOG(0) << "ERROR!: TInput not initialized." << endl; ! return; ! } ! tInput::sm->del_machine(machine_number); // Delete related routes *************** *** 487,490 **** --- 557,566 ---- void tInput::register_msg(u_int16_t id_msg) { + if (!initialized) + { + FSMLOG(0) << "ERROR!: TInput not initialized." << endl; + return; + } + tInput::sm->add_msg_machine(id_msg, atoi(tInput::socket_name)); } |
|
From: Andreu M. <am...@us...> - 2004-04-03 06:44:16
|
Update of /cvsroot/dfsm/dFSM/include/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1816/include/libdfsm Modified Files: tfsm.h tinput.h Log Message: Add support for manual and automatic state machine identification Index: tinput.h =================================================================== RCS file: /cvsroot/dfsm/dFSM/include/libdfsm/tinput.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tinput.h 31 Mar 2004 16:42:19 -0000 1.16 --- tinput.h 3 Apr 2004 06:32:01 -0000 1.17 *************** *** 32,35 **** --- 32,38 ---- * $Revision$ * $Log$ + * Revision 1.17 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.16 2004/03/31 16:42:19 amoreno * Tinput interface supports send and send_to (useful for utilities) and change monitor as service *************** *** 139,142 **** --- 142,160 ---- /** + * Initilize with automatic Machine identification + * + * @return True if OK + */ + bool init(); + + /** + * Initilize + * + * @param machine_id Machine identification. + * @return True if OK + */ + bool init(u_int16_t machine_id); + + /** * Send a message to other machines * A list of machines is subscribed to a message id (id_msg). When this function is invoked a message *************** *** 202,207 **** private: ! const char *socket_name; /**< Socket name */ ! const char *reserve_socket_server(); /**< Finds the first avalable id in SOCKET_DIR */ }; --- 220,227 ---- private: ! char *socket_name; /**< Socket name */ ! void check_socket_dir(); ! char *reserve_socket_server(); /**< Finds the first avalable id in SOCKET_DIR */ ! bool initialized; /**< initilized flag */ }; Index: tfsm.h =================================================================== RCS file: /cvsroot/dfsm/dFSM/include/libdfsm/tfsm.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tfsm.h 31 Mar 2004 16:42:19 -0000 1.23 --- tfsm.h 3 Apr 2004 06:32:01 -0000 1.24 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.24 2004/04/03 06:32:01 amoreno + * Add support for manual and automatic state machine identification + * * Revision 1.23 2004/03/31 16:42:19 amoreno * Tinput interface supports send and send_to (useful for utilities) and change monitor as service *************** *** 148,151 **** --- 151,156 ---- verified when inserting a new state. */ // Maybe we should work with state pointers... + // For Machine identification atomatic + #define MACHINE_ID_AUTO 0xFFFF class tFSM; *************** *** 176,184 **** /** * Class constructor * @param name Gives a more human friendly identifier to the machine. * @param log_level log level selected. * @param file finename to output log traces. */ ! tFSM(const char *name, u_int8_t log_level, const char* file=NULL); /** --- 181,190 ---- /** * Class constructor + * @param machine_id Machine identification. * @param name Gives a more human friendly identifier to the machine. * @param log_level log level selected. * @param file finename to output log traces. */ ! tFSM(u_int16_t machine_id, const char *name, u_int8_t log_level, const char* file=NULL); /** |
|
From: Andreu M. <am...@us...> - 2004-04-03 06:44:15
|
Update of /cvsroot/dfsm/dFSM/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1816/doc Modified Files: example3-structure.dia Log Message: Add support for manual and automatic state machine identification Index: example3-structure.dia =================================================================== RCS file: /cvsroot/dfsm/dFSM/doc/example3-structure.dia,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvsOjU8ad and /tmp/cvsP2OkfI differ |
|
From: Andreu M. <am...@us...> - 2004-04-03 06:44:15
|
Update of /cvsroot/dfsm/dFSM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1816 Modified Files: Changelog Log Message: Add support for manual and automatic state machine identification Index: Changelog =================================================================== RCS file: /cvsroot/dfsm/dFSM/Changelog,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Changelog 31 Mar 2004 16:42:19 -0000 1.5 --- Changelog 3 Apr 2004 06:32:00 -0000 1.6 *************** *** 12,17 **** transitions 06. Events are total ordered ! 07. Monitor tool interface improved 08. Add test5 to create automata chain -Andreu Moreno and Joan Valduvieco, 31 March 2004 --- 12,19 ---- transitions 06. Events are total ordered ! 07. Monitor tool interface improved and changed to service 08. Add test5 to create automata chain + 09. Add support for manual and automatic state machine + identification -Andreu Moreno and Joan Valduvieco, 31 March 2004 |
|
From: Andreu M. <am...@us...> - 2004-03-31 16:54:10
|
Update of /cvsroot/dfsm/dFSM/src/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14362/src/utils Modified Files: dfsm_monitor.cpp send_to.cpp supervisor.cpp Log Message: Tinput interface supports send and send_to (useful for utilities) and change monitor as service Index: send_to.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/utils/send_to.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** send_to.cpp 12 Sep 2003 16:29:13 -0000 1.5 --- send_to.cpp 31 Mar 2004 16:42:20 -0000 1.6 *************** *** 25,86 **** #include "libdfsm/tevent.h" - int16_t send( u_int16_t machine_n, u_int16_t id_msg, char *data, u_int16_t len) - { - //strstream socket_path; - u_int16_t sockfd; - unsigned char *msg; - struct sockaddr_un address; - int16_t result; - int bytes_sent; - char *ptr; - tEvent::Event *event; - - //socket_path.clear(); - - // Create a socket for the client - sockfd = socket(AF_UNIX, SOCK_STREAM, 0); - // Name the socket, as agreed with the server - address.sun_family = AF_UNIX; - - char tmp[5]; - strncpy(address.sun_path,SOCKET_DIR,99); // 99 = 104 - 5 104 is the maximum length of a unix socket path UNP - sprintf(tmp,"/%d",machine_n); - strncat(address.sun_path,tmp,5); // There won't be more than 999 machines - - // Now connect our socket to the server's socket - result = connect(sockfd, (struct sockaddr *)&address, sizeof(address)); - if(result != -1) { // Connected - // Now we can read/write via sockfd - clog <<"Connected to "<<address.sun_path<<endl; - msg=new unsigned char[sizeof(tEvent::Event)+len]; - event=(tEvent::Event *)msg; - if (msg != NULL) - { - // Compose message. A (tEvent::Event)header + (char *)data - event->id_msg = id_msg; - event->id_sender = 0; // Monitor. Fake value. - event->n_seq = 0; //Test msg. Fake value. - event->size=len; - ptr=(char *)((tEvent::Event *)msg+1); - memcpy(ptr,data,len); - } - if (sizeof(msg)>MAX_PACKET_SIZE) { - // FIXME: Throw an exception - cerr << "ERROR!: Max. packet size exceeded. Message not sent." << endl; - } - else - { - bytes_sent=write(sockfd, msg, sizeof(tEvent::Event)+len) ; - clog<<"Sent "<<bytes_sent<<" bytes to "<<address.sun_path<<endl; - } - close(sockfd); - delete[] msg ; - } - else - { - cerr << "Error while conecting to: "<<address.sun_path<<endl ; - } - } - int main(int argc, char *argv[]) --- 25,28 ---- *************** *** 89,96 **** char *data; machine_n=atoi(argv[1]); id_msg=atoi(argv[2]); cout <<"Machine id: "<<machine_n<<endl; cout <<"Msg id: "<<id_msg<<endl; ! send(machine_n,id_msg,"",0); } --- 31,45 ---- char *data; + if (argc != 3) + { + printf("Usage: send_to machine id_event \n"); + return 0; + } + machine_n=atoi(argv[1]); id_msg=atoi(argv[2]); cout <<"Machine id: "<<machine_n<<endl; cout <<"Msg id: "<<id_msg<<endl; ! send_event_to(machine_n, id_msg, NULL, 0); ! return 1; } Index: supervisor.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/utils/supervisor.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** supervisor.cpp 19 Mar 2004 21:05:10 -0000 1.8 --- supervisor.cpp 31 Mar 2004 16:42:20 -0000 1.9 *************** *** 21,24 **** --- 21,27 ---- * $Revision$ * $Log$ + * Revision 1.9 2004/03/31 16:42:20 amoreno + * Tinput interface supports send and send_to (useful for utilities) and change monitor as service + * * Revision 1.8 2004/03/19 21:05:10 jvalduvieco * Prerelease cleanup. *************** *** 361,365 **** //Enviar events de shutdown //TODO: haltevent not defined ! if (pg->second->haltevent!=0) tinputs->send_to(pg->second->haltevent, NULL, 0); //Esperar event --- 364,368 ---- //Enviar events de shutdown //TODO: haltevent not defined ! if (pg->second->haltevent!=0) send_event(pg->second->haltevent, NULL, 0); //Esperar event *************** *** 399,403 **** //Enviar events de shutdown //TODO: haltevent not defined ! if (pg->second->resetevent!=0) tinputs->send_to(pg->second->resetevent, NULL, 0); } --- 402,406 ---- //Enviar events de shutdown //TODO: haltevent not defined ! if (pg->second->resetevent!=0) send_event(pg->second->resetevent, NULL, 0); } Index: dfsm_monitor.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/utils/dfsm_monitor.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dfsm_monitor.cpp 19 Mar 2004 21:05:09 -0000 1.11 --- dfsm_monitor.cpp 31 Mar 2004 16:42:20 -0000 1.12 *************** *** 21,24 **** --- 21,27 ---- * $Revision$ * $Log$ + * Revision 1.12 2004/03/31 16:42:20 amoreno + * Tinput interface supports send and send_to (useful for utilities) and change monitor as service + * * Revision 1.11 2004/03/19 21:05:09 jvalduvieco * Prerelease cleanup. *************** *** 89,92 **** --- 92,101 ---- #include "libdfsm/tfsm.h" + #include "libdfsm/tinput.h" + #include "libdfsm/tevent.h" + + + tEvent *events; + dfsm_monitor::dfsm_monitor(u_int16_t machine):tsm_list(machine, false) { *************** *** 299,370 **** int send_to( bool broadcast, u_int16_t machine_n, u_int16_t id_msg, char *data=0,u_int16_t len=0) { - //strstream socket_path; - u_int16_t sockfd; - unsigned char *msg; - struct sockaddr_un address; - int16_t result; - int bytes_sent; - tEvent::Event *event; - char *ptr; - unsigned long long t1, t2; - tsm_route_table *sm; /**< Shared memory region which contains routing tables(which machines are subscribed to which messsages) */ - string socket_name; /**< Socket name */ - vector<u_int16_t>::iterator vns_i; - vector<u_int16_t> vns; - - if (broadcast) { ! sm = new tsm_route_table(MAX_MACHINE-1, false); ! vns = sm->get_msg_machine(id_msg); } ! else { ! vns.push_back(machine_n); ! } ! ! for (vns_i=vns.begin(); vns_i!=vns.end(); ++vns_i) { ! ! // Create a socket for the client ! sockfd = socket(AF_UNIX, SOCK_STREAM, 0); ! ! // Name the socket, as agreed with the server ! address.sun_family = AF_UNIX; ! ! char tmp[5]; ! strncpy(address.sun_path,SOCKET_DIR,99); // 99 = 104 - 5 104 is the maximum length of a unix socket path UNP ! sprintf(tmp,"/%d",(*vns_i)); ! strncat(address.sun_path,tmp,5); // There won't be more than 999 machines ! ! // Now connect our socket to the server's socket ! result = connect(sockfd, (struct sockaddr *)&address, sizeof(address)); ! if(result == -1) { ! } ! if(result != -1) { // Connected ! // Now we can read/write via sockfd ! msg=new unsigned char[sizeof(tEvent::Event)+len]; ! event=(tEvent::Event *)msg; ! if (msg != NULL) ! { ! // Compose message. A (tEvent::Event)header + (char *)data ! event->id_msg = id_msg; ! event->id_sender = MAX_MACHINE-1; ! event->n_seq = 0; //We not support this feature in monitor ! event->size=len; ! ptr=(char *)((tEvent::Event *)msg+1); ! memcpy(ptr,data,len); ! } ! if (sizeof(msg)>MAX_PACKET_SIZE) { ! // FIXME: Throw an exception ! } ! else ! { ! bytes_sent=write(sockfd, msg, sizeof(tEvent::Event)+len) ; ! } ! close(sockfd); ! delete[] msg ; ! } } - return bytes_sent; } --- 308,319 ---- int send_to( bool broadcast, u_int16_t machine_n, u_int16_t id_msg, char *data=0,u_int16_t len=0) { if (broadcast) { ! return send_event(id_msg, data, len); } ! else { ! return send_event_to(machine_n, id_msg, data, len); } } *************** *** 423,426 **** --- 372,381 ---- map <u_int16_t, dfsm_monitor*> machines; + // Setup Input_service + tEvent *events = new tEvent(); + tinputs->set_event_handler(events); + //tinput_service->run(); + + display_notice(); |
|
From: Andreu M. <am...@us...> - 2004-03-31 16:54:10
|
Update of /cvsroot/dfsm/dFSM/src/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14362/src/libdfsm Modified Files: tfsm.cpp tfsm_monitor_sensor.cpp tinput.cpp Log Message: Tinput interface supports send and send_to (useful for utilities) and change monitor as service Index: tfsm_monitor_sensor.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/tfsm_monitor_sensor.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tfsm_monitor_sensor.cpp 3 Aug 2003 21:12:07 -0000 1.2 --- tfsm_monitor_sensor.cpp 31 Mar 2004 16:42:20 -0000 1.3 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.3 2004/03/31 16:42:20 amoreno + * Tinput interface supports send and send_to (useful for utilities) and change monitor as service + * * Revision 1.2 2003/08/03 21:12:07 jvalduvieco * Major cleaning: *************** *** 47,53 **** #include "libdfsm/tfsm_monitor_sensor.h" ! tfsm_monitor_sensor::tfsm_monitor_sensor(u_int16_t machine, bool init) : tsm_list(machine, init) ! { } --- 50,58 ---- #include "libdfsm/tfsm_monitor_sensor.h" ! tFsm_monitor_sensor_service* Singleton<tFsm_monitor_sensor_service>::_instance=0; + tfsm_monitor_sensor::tfsm_monitor_sensor() + { + list = NULL; } *************** *** 57,65 **** } bool tfsm_monitor_sensor::push(unsigned char code, unsigned char size, unsigned char *data) { struct timeval time; gettimeofday(&time,NULL); ! return tsm_list::push(code, size, time, data); } --- 62,80 ---- } + + bool tfsm_monitor_sensor::init(u_int16_t machine, bool init) + { + list = new tsm_list(machine, init); + return true; + } + bool tfsm_monitor_sensor::push(unsigned char code, unsigned char size, unsigned char *data) { struct timeval time; + //Don't log monitor traces when not initialized, used in send_to, supervisor and dfsm_monitor. + if (list == NULL) return false; + gettimeofday(&time,NULL); ! return list->push(code, size, time, data); } Index: tfsm.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/tfsm.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** tfsm.cpp 26 Mar 2004 12:20:43 -0000 1.32 --- tfsm.cpp 31 Mar 2004 16:42:20 -0000 1.33 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.33 2004/03/31 16:42:20 amoreno + * Tinput interface supports send and send_to (useful for utilities) and change monitor as service + * * Revision 1.32 2004/03/26 12:20:43 amoreno * Minor improvement in using tinputs macro *************** *** 151,155 **** tLog tFSM::state_log; - tfsm_monitor_sensor *tFSM::monitor; --- 154,157 ---- *************** *** 181,185 **** strncpy(tFSM::fsm_machine,buf,50) ; - //tFSM::monitor = new tfsm_monitor_sensor(machine ,(machine == 0)); tFSM::events = new tEvent(); tinputs->set_event_handler(tFSM::events); --- 183,186 ---- *************** *** 194,198 **** machine = atoi(socket_number.c_str()); ! tFSM::monitor = new tfsm_monitor_sensor(machine ,(machine == 0)); tFSM::dFSM_log.set_pid(getpid()); tFSM::dFSM_log.set_fsmid(machine); --- 195,199 ---- machine = atoi(socket_number.c_str()); ! monitor_init(machine ,(machine == 0)); tFSM::dFSM_log.set_pid(getpid()); tFSM::dFSM_log.set_fsmid(machine); *************** *** 421,425 **** } ! monitor->push_entry_state(target->get_id()); // Check if events are pended, deferred events mostly, to process it --- 422,426 ---- } ! monitor_push_entry_state(target->get_id()); // Check if events are pended, deferred events mostly, to process it Index: tinput.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/tinput.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** tinput.cpp 30 Mar 2004 15:12:31 -0000 1.21 --- tinput.cpp 31 Mar 2004 16:42:20 -0000 1.22 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.22 2004/03/31 16:42:20 amoreno + * Tinput interface supports send and send_to (useful for utilities) and change monitor as service + * * Revision 1.21 2004/03/30 15:12:31 amoreno * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq *************** *** 145,150 **** // This is a BSAD. Maybe we should put a wrapper method and make this one private. // We should protect against a user mistake in "len". ! // Retornar coses ! int tInput::send_to(u_int16_t id_msg, const char *data=0,u_int16_t len=0) { int16_t sockfd,result; --- 148,152 ---- // This is a BSAD. Maybe we should put a wrapper method and make this one private. // We should protect against a user mistake in "len". ! int tInput::send(u_int16_t id_msg, const char *data=0,u_int16_t len=0) { int16_t sockfd,result; *************** *** 223,227 **** { FSMLOG(3)<<"Sent "<<len<<" data bytes to "<<address.sun_path<<endl; ! tFSM::monitor->push_send_event(id_msg); } } --- 225,229 ---- { FSMLOG(3)<<"Sent "<<len<<" data bytes to "<<address.sun_path<<endl; ! monitor_push_send_event(id_msg); } } *************** *** 236,239 **** --- 238,324 ---- } + int tInput::send_to(u_int16_t machine, u_int16_t id_msg, const char *data=0,u_int16_t len=0) + { + int16_t sockfd,result; + unsigned char *msg; + struct sockaddr_un address; + ssize_t bytes_sent; + tEvent::Event *event; + char *ptr; + + if (sizeof(msg)>MAX_PACKET_SIZE) + { + // FIXME: Throw an exception + FSMLOG(0) << "ERROR!: Max. packet size exceeded. Message not sent." << endl; + return 0; + } + + msg=new unsigned char[sizeof(tEvent::Event)+len]; + if (msg == NULL) + { + // FIXME: Throw an exception + FSMLOG(0) << "ERROR!: Unable to allocate memory for messaget." << endl; + return 0; + } + event=(tEvent::Event *)msg; + + // Compose message. A (tEvent::Event)header + (char *)data + event->id_msg = id_msg; + event->id_sender = atoi(tInput::socket_name); + event->n_seq = tInput::sm_seq->get_n_seq_lock(); //Lock to achive total order of messages + event->size=len; + ptr=(char *)((tEvent::Event *)msg+1); + memcpy(ptr,data,len); + + FSMLOG(2) <<"Sending event "<<id_msg<<endl; + + char tmp[5]; + + // Create a socket for the client + sockfd = socket(AF_UNIX, SOCK_STREAM, 0); + if(sockfd == -1) { + FSMLOG(1) <<"Error creating socket: "<<strerror(errno)<<endl; + tInput::unregister_machine(machine); + } + // Name the socket, as agreed with the server + address.sun_family = AF_UNIX; + strncpy(address.sun_path,SOCKET_DIR,99); // 99 = 104 - 5 + // 104 is the maximum length od a unix socket path UNP + sprintf(tmp,"/%d",machine); + strncat(address.sun_path,tmp,5); // There won't be more than 999 machines /999\0 + // Now connect our socket to the server's socket + result = connect(sockfd, (struct sockaddr *)&address, sizeof(address)); + if(result == -1) + { + // Unregister machine (socket), clean exit. + FSMLOG(2) <<"Unregistering |"<<address.sun_path<<"|"<<endl; + tInput::unregister_machine(machine); + } + else + { // Connected + // Now we can read/write via sockfd + FSMLOG(3) <<"Connected to "<<address.sun_path<<endl; + + bytes_sent=write(sockfd, msg, sizeof(tEvent::Event)+len) ; + if(bytes_sent == -1) { + // Unregister machine (socket), clean exit. + FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; + tInput::unregister_machine(machine); + } + else + { + FSMLOG(3)<<"Sent "<<len<<" data bytes to "<<address.sun_path<<endl; + monitor_push_send_event(id_msg); + } + } + close(sockfd); + //delete[] msg ; + + tInput::sm_seq->get_n_seq_unlock(); + delete[] msg ; + return bytes_sent; + } + + const char *tInput::reserve_socket_server() { *************** *** 376,380 **** close(client_sockfd); ! tFSM::monitor->push_receive_event(event.id_msg); } } --- 461,465 ---- close(client_sockfd); ! monitor_push_receive_event(event.id_msg); } } |
|
From: Andreu M. <am...@us...> - 2004-03-31 16:54:10
|
Update of /cvsroot/dfsm/dFSM/include/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14362/include/libdfsm Modified Files: tfsm.h tfsm_monitor_sensor.h tinput.h Log Message: Tinput interface supports send and send_to (useful for utilities) and change monitor as service Index: tfsm_monitor_sensor.h =================================================================== RCS file: /cvsroot/dfsm/dFSM/include/libdfsm/tfsm_monitor_sensor.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tfsm_monitor_sensor.h 3 Aug 2003 21:12:07 -0000 1.2 --- tfsm_monitor_sensor.h 31 Mar 2004 16:42:19 -0000 1.3 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.3 2004/03/31 16:42:19 amoreno + * Tinput interface supports send and send_to (useful for utilities) and change monitor as service + * * Revision 1.2 2003/08/03 21:12:07 jvalduvieco * Major cleaning: *************** *** 47,52 **** #define TFSM_MONITOR_SENSOR_H - #include "libdfsm/sm_lists.h" using namespace std; --- 50,55 ---- #define TFSM_MONITOR_SENSOR_H #include "libdfsm/sm_lists.h" + #include "libdfsm/singleton.h" using namespace std; *************** *** 60,64 **** * */ ! class tfsm_monitor_sensor: public tsm_list { public: --- 63,67 ---- * */ ! class tfsm_monitor_sensor { public: *************** *** 67,74 **** * Class constructor * - * @param machine Machine number - * @param init Flag to clear list */ ! tfsm_monitor_sensor(u_int16_t machine, bool init); /** --- 70,75 ---- * Class constructor * */ ! tfsm_monitor_sensor(); /** *************** *** 78,81 **** --- 79,90 ---- /** + * Initializz + * + * @param machine Machine number + * @param init Flag to clear list + */ + bool init(u_int16_t machine, bool init); + + /** * Generic push * *************** *** 110,116 **** --- 119,145 ---- */ bool push_entry_state(u_int16_t state); + private: + tsm_list *list; + }; + class tFsm_monitor_sensor_service : public Singleton <tFsm_monitor_sensor_service> + { + public: + tFsm_monitor_sensor_service(){}; + ~tFsm_monitor_sensor_service(){}; + tfsm_monitor_sensor *get_pointer(){ return &monitor_sensor; }; + protected: + private: + tfsm_monitor_sensor monitor_sensor; }; + #define tfsm_monitor_sensor_service tFsm_monitor_sensor_service::getInstance() + #define monitor_sensors tFsm_monitor_sensor_service::getInstance()->get_pointer() + #define monitor_init monitor_sensors->init + #define monitor_push monitor_sensors->push + #define monitor_push_send_event monitor_sensors->push_send_event + #define monitor_push_receive_event monitor_sensors->push_receive_event + #define monitor_push_entry_state monitor_sensors->push_entry_state + #endif Index: tinput.h =================================================================== RCS file: /cvsroot/dfsm/dFSM/include/libdfsm/tinput.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tinput.h 19 Mar 2004 21:05:09 -0000 1.15 --- tinput.h 31 Mar 2004 16:42:19 -0000 1.16 *************** *** 32,35 **** --- 32,38 ---- * $Revision$ * $Log$ + * Revision 1.16 2004/03/31 16:42:19 amoreno + * Tinput interface supports send and send_to (useful for utilities) and change monitor as service + * * Revision 1.15 2004/03/19 21:05:09 jvalduvieco * Prerelease cleanup. *************** *** 145,149 **** * @return Bytes sended */ ! int send_to(u_int16_t id_msg, const char *data, u_int16_t len); /** --- 148,163 ---- * @return Bytes sended */ ! int send(u_int16_t id_msg, const char *data, u_int16_t len); ! ! /** ! * Send a message to a machines ! * ! * @param machine Machine id to send the message. ! * @param id_msg Message id. ! * @param data Extra data ! * @param len Length data ! * @return Bytes sended ! */ ! int send_to(u_int16_t machine, u_int16_t id_msg, const char *data, u_int16_t len); /** *************** *** 206,209 **** #define tinput_service tInput_service::getInstance() #define tinputs tInput_service::getInstance()->get_pointer() ! #define send_event tInput_service::getInstance()->get_pointer()->send_to #endif --- 220,224 ---- #define tinput_service tInput_service::getInstance() #define tinputs tInput_service::getInstance()->get_pointer() ! #define send_event tInput_service::getInstance()->get_pointer()->send ! #define send_event_to tInput_service::getInstance()->get_pointer()->send_to #endif Index: tfsm.h =================================================================== RCS file: /cvsroot/dfsm/dFSM/include/libdfsm/tfsm.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tfsm.h 19 Mar 2004 21:05:09 -0000 1.22 --- tfsm.h 31 Mar 2004 16:42:19 -0000 1.23 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.23 2004/03/31 16:42:19 amoreno + * Tinput interface supports send and send_to (useful for utilities) and change monitor as service + * * Revision 1.22 2004/03/19 21:05:09 jvalduvieco * Prerelease cleanup. *************** *** 303,312 **** static tLog state_log; - /** - * Monitor system - * - */ - static tfsm_monitor_sensor *monitor; - protected: --- 306,309 ---- |
|
From: Andreu M. <am...@us...> - 2004-03-31 16:54:09
|
Update of /cvsroot/dfsm/dFSM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14362 Modified Files: Changelog Log Message: Tinput interface supports send and send_to (useful for utilities) and change monitor as service Index: Changelog =================================================================== RCS file: /cvsroot/dfsm/dFSM/Changelog,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Changelog 16 Jul 2003 09:42:56 -0000 1.4 --- Changelog 31 Mar 2004 16:42:19 -0000 1.5 *************** *** 1,2 **** --- 1,21 ---- + 0.7.0 + + Beta Release + + * Features added: + + 01. Basic Supervisor added + 02. Timer service added + 03. tInput service added + 04. Bug cleaning and clean up + 05. entry_function and exit_function are executed in self + transitions + 06. Events are total ordered + 07. Monitor tool interface improved + 08. Add test5 to create automata chain + + -Andreu Moreno and Joan Valduvieco, 31 March 2004 + + 0.6.0 |
|
From: Andreu M. <am...@us...> - 2004-03-30 15:24:10
|
Update of /cvsroot/dfsm/dFSM/src/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14192/src/libdfsm Modified Files: sm_route_table.cpp sm_seq.cpp tinput.cpp Log Message: Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq Index: tinput.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/tinput.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tinput.cpp 26 Mar 2004 12:36:52 -0000 1.20 --- tinput.cpp 30 Mar 2004 15:12:31 -0000 1.21 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.21 2004/03/30 15:12:31 amoreno + * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq + * * Revision 1.20 2004/03/26 12:36:52 amoreno * Improvement buffer used in tInput::send_to *************** *** 143,147 **** // We should protect against a user mistake in "len". // Retornar coses - // TODO: Total order of events is not guaranteed. Some blocked tool is needed int tInput::send_to(u_int16_t id_msg, const char *data=0,u_int16_t len=0) { --- 146,149 ---- *************** *** 153,158 **** --- 155,183 ---- char *ptr; + if (sizeof(msg)>MAX_PACKET_SIZE) + { + // FIXME: Throw an exception + FSMLOG(0) << "ERROR!: Max. packet size exceeded. Message not sent." << endl; + return 0; + } + msg=new unsigned char[sizeof(tEvent::Event)+len]; + if (msg == NULL) + { + // FIXME: Throw an exception + FSMLOG(0) << "ERROR!: Unable to allocate memory for messaget." << endl; + return 0; + } + event=(tEvent::Event *)msg; + // Compose message. A (tEvent::Event)header + (char *)data + event->id_msg = id_msg; + event->id_sender = atoi(tInput::socket_name); + event->n_seq = tInput::sm_seq->get_n_seq_lock(); //Lock to achive total order of messages + event->size=len; + ptr=(char *)((tEvent::Event *)msg+1); + memcpy(ptr,data,len); + + vector<u_int16_t>::iterator vns_i; vector<u_int16_t> vns = tInput::sm->get_msg_machine(id_msg); *************** *** 161,165 **** char tmp[5]; ! for (vns_i=vns.begin(); vns_i!=vns.end(); ++vns_i) { // Create a socket for the client sockfd = socket(AF_UNIX, SOCK_STREAM, 0); --- 186,191 ---- char tmp[5]; ! for (vns_i=vns.begin(); vns_i!=vns.end(); ++vns_i) ! { // Create a socket for the client sockfd = socket(AF_UNIX, SOCK_STREAM, 0); *************** *** 187,226 **** // Now we can read/write via sockfd FSMLOG(3) <<"Connected to "<<address.sun_path<<endl; ! //msg=new unsigned char[sizeof(tEvent::Event)+len]; ! event=(tEvent::Event *)msg; ! if (msg != NULL) ! { ! // Compose message. A (tEvent::Event)header + (char *)data ! event->id_msg = id_msg; ! event->id_sender = atoi(tInput::socket_name); ! event->n_seq = tInput::sm_seq->get_n_seq(); ! event->size=len; ! ptr=(char *)((tEvent::Event *)msg+1); ! memcpy(ptr,data,len); ! } ! if (sizeof(msg)>MAX_PACKET_SIZE) { ! // FIXME: Throw an exception ! FSMLOG(0) << "ERROR!: Max. packet size exceeded. Message not sent." << endl; } else { ! bytes_sent=write(sockfd, msg, sizeof(tEvent::Event)+len) ; ! if(bytes_sent == -1) { ! // Unregister machine (socket), clean exit. ! FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; ! tInput::unregister_machine((*vns_i)); ! } ! else ! { ! FSMLOG(3)<<"Sent "<<len<<" data bytes to "<<address.sun_path<<endl; ! tFSM::monitor->push_send_event(id_msg); ! } } - close(sockfd); - //delete[] msg ; - } } delete[] msg ; return bytes_sent; --- 213,235 ---- // Now we can read/write via sockfd FSMLOG(3) <<"Connected to "<<address.sun_path<<endl; ! ! bytes_sent=write(sockfd, msg, sizeof(tEvent::Event)+len) ; ! if(bytes_sent == -1) { ! // Unregister machine (socket), clean exit. ! FSMLOG(2) <<"Error sending: "<<strerror(errno)<<endl; ! tInput::unregister_machine((*vns_i)); } else { ! FSMLOG(3)<<"Sent "<<len<<" data bytes to "<<address.sun_path<<endl; ! tFSM::monitor->push_send_event(id_msg); } } + close(sockfd); + //delete[] msg ; + } + tInput::sm_seq->get_n_seq_unlock(); delete[] msg ; return bytes_sent; Index: sm_route_table.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/sm_route_table.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** sm_route_table.cpp 8 Jan 2004 14:35:41 -0000 1.10 --- sm_route_table.cpp 30 Mar 2004 15:12:31 -0000 1.11 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.11 2004/03/30 15:12:31 amoreno + * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq + * * Revision 1.10 2004/01/08 14:35:41 amoreno * Improvement in dump route table *************** *** 87,91 **** // Init semaphore ! tsm_route_table::sem = new tSemaphore(); tsm_route_table::sem->binary_semaphore_wait(); --- 90,94 ---- // Init semaphore ! tsm_route_table::sem = new tSemaphore(SM_SEMAPHORE_KEY); tsm_route_table::sem->binary_semaphore_wait(); Index: sm_seq.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/sm_seq.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sm_seq.cpp 3 Aug 2003 21:12:07 -0000 1.4 --- sm_seq.cpp 30 Mar 2004 15:12:31 -0000 1.5 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.5 2004/03/30 15:12:31 amoreno + * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq + * * Revision 1.4 2003/08/03 21:12:07 jvalduvieco * Major cleaning: *************** *** 57,61 **** // Init semaphore ! tsm_seq::sem = new tSemaphore(); tsm_seq::sem->binary_semaphore_wait(); --- 60,64 ---- // Init semaphore ! tsm_seq::sem = new tSemaphore(SEQ_SEMAPHORE_KEY); tsm_seq::sem->binary_semaphore_wait(); *************** *** 82,86 **** } ! u_int32_t tsm_seq::get_n_seq() { u_int32_t r; --- 85,89 ---- } ! u_int32_t tsm_seq::get_n_seq_lock() { u_int32_t r; *************** *** 88,92 **** r = *(tsm_seq::shared_memory)+1; *(tsm_seq::shared_memory) = r; - tsm_seq::sem->binary_semaphore_post(); return r; } --- 91,100 ---- r = *(tsm_seq::shared_memory)+1; *(tsm_seq::shared_memory) = r; return r; } + + bool tsm_seq::get_n_seq_unlock() + { + tsm_seq::sem->binary_semaphore_post(); + return true; + } |
|
From: Andreu M. <am...@us...> - 2004-03-30 15:24:10
|
Update of /cvsroot/dfsm/dFSM/src/libposixwrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14192/src/libposixwrap Modified Files: tsemaphore.cpp Log Message: Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq Index: tsemaphore.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libposixwrap/tsemaphore.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tsemaphore.cpp 3 Aug 2003 21:12:07 -0000 1.5 --- tsemaphore.cpp 30 Mar 2004 15:12:31 -0000 1.6 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.6 2004/03/30 15:12:31 amoreno + * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq + * * Revision 1.5 2003/08/03 21:12:07 jvalduvieco * Major cleaning: *************** *** 57,64 **** // FIXME: Free semaphore in destructor. ! tSemaphore::tSemaphore() { // Obtain a binary semaphore's ID, allocationg if necessary ! if ((tSemaphore::id = semget(SEMAPHORE_KEY, SET_SIZE, PERMS | IPC_CREAT)) < 0) { //FSMLOG(0) << "Error creating semaphore with key: " << SEMAPHORE_KEY << endl; //FIXME: throw an exception --- 60,67 ---- // FIXME: Free semaphore in destructor. ! tSemaphore::tSemaphore(key_t k) { // Obtain a binary semaphore's ID, allocationg if necessary ! if ((tSemaphore::id = semget(k, SET_SIZE, PERMS | IPC_CREAT)) < 0) { //FSMLOG(0) << "Error creating semaphore with key: " << SEMAPHORE_KEY << endl; //FIXME: throw an exception |
|
From: Andreu M. <am...@us...> - 2004-03-30 15:24:09
|
Update of /cvsroot/dfsm/dFSM/include/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14192/include/libdfsm Modified Files: sm_lists.h sm_route_table.h sm_seq.h Log Message: Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq Index: sm_seq.h =================================================================== RCS file: /cvsroot/dfsm/dFSM/include/libdfsm/sm_seq.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sm_seq.h 3 Aug 2003 21:12:07 -0000 1.6 --- sm_seq.h 30 Mar 2004 15:12:30 -0000 1.7 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.7 2004/03/30 15:12:30 amoreno + * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq + * * Revision 1.6 2003/08/03 21:12:07 jvalduvieco * Major cleaning: *************** *** 60,63 **** --- 63,67 ---- #define OUR_ID_MEMORY_KEY_SM_SEQ 5549 + #define SEQ_SEMAPHORE_KEY ((key_t)99888) //#define DEBUG_SM_SEQ *************** *** 84,92 **** /** ! * Get sequence number ! * * @return Sequence number */ ! u_int32_t get_n_seq(); protected: --- 88,103 ---- /** ! * Get sequence number and lock ! * It is needed to achive total order of messages * @return Sequence number */ ! u_int32_t get_n_seq_lock(); ! ! /** ! * Unlock get sequence number ! * ! * @return true if OK ! */ ! bool get_n_seq_unlock(); protected: Index: sm_route_table.h =================================================================== RCS file: /cvsroot/dfsm/dFSM/include/libdfsm/sm_route_table.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sm_route_table.h 19 Mar 2004 21:05:09 -0000 1.9 --- sm_route_table.h 30 Mar 2004 15:12:30 -0000 1.10 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.10 2004/03/30 15:12:30 amoreno + * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq + * * Revision 1.9 2004/03/19 21:05:09 jvalduvieco * Prerelease cleanup. *************** *** 67,70 **** --- 70,74 ---- #define OUR_ID_MEMORY_KEY 5548 #define SHARED_SEGMENT 0x1000 + #define SM_SEMAPHORE_KEY ((key_t)99887) // Max. number of state machines (0...MAX_MACHINE) Index: sm_lists.h =================================================================== RCS file: /cvsroot/dfsm/dFSM/include/libdfsm/sm_lists.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sm_lists.h 28 Dec 2003 08:11:21 -0000 1.5 --- sm_lists.h 30 Mar 2004 15:12:30 -0000 1.6 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.6 2004/03/30 15:12:30 amoreno + * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq + * * Revision 1.5 2003/12/28 08:11:21 amoreno * dfsm_monitor: bug cleaning in initialization *************** *** 67,70 **** --- 70,75 ---- #include "libdfsm/sm_route_table.h" /**< for MAX_MACHINE*/ + + using namespace std; |
|
From: Andreu M. <am...@us...> - 2004-03-30 15:24:09
|
Update of /cvsroot/dfsm/dFSM/include/libposixwrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14192/include/libposixwrap Modified Files: tsemaphore.h Log Message: Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq Index: tsemaphore.h =================================================================== RCS file: /cvsroot/dfsm/dFSM/include/libposixwrap/tsemaphore.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tsemaphore.h 3 Aug 2003 21:12:07 -0000 1.7 --- tsemaphore.h 30 Mar 2004 15:12:30 -0000 1.8 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.8 2004/03/30 15:12:30 amoreno + * Events are now total ordered. Solved bug in using the same semaphore for sm_route_table and sm_seq + * * Revision 1.7 2003/08/03 21:12:07 jvalduvieco * Major cleaning: *************** *** 87,91 **** * Class constructor */ ! tSemaphore(); /** --- 90,94 ---- * Class constructor */ ! tSemaphore(key_t k); /** |
|
From: Andreu M. <am...@us...> - 2004-03-26 12:47:50
|
Update of /cvsroot/dfsm/dFSM/src/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15475/src/libdfsm Modified Files: tinput.cpp Log Message: Improvement buffer used in tInput::send_to Index: tinput.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/tinput.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** tinput.cpp 5 Mar 2004 18:41:14 -0000 1.19 --- tinput.cpp 26 Mar 2004 12:36:52 -0000 1.20 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.20 2004/03/26 12:36:52 amoreno + * Improvement buffer used in tInput::send_to + * * Revision 1.19 2004/03/05 18:41:14 jvalduvieco * Major modifications. Quick implemetation. A little messy. *************** *** 140,143 **** --- 143,147 ---- // We should protect against a user mistake in "len". // Retornar coses + // TODO: Total order of events is not guaranteed. Some blocked tool is needed int tInput::send_to(u_int16_t id_msg, const char *data=0,u_int16_t len=0) { *************** *** 149,152 **** --- 153,158 ---- char *ptr; + msg=new unsigned char[sizeof(tEvent::Event)+len]; + vector<u_int16_t>::iterator vns_i; vector<u_int16_t> vns = tInput::sm->get_msg_machine(id_msg); *************** *** 181,185 **** // Now we can read/write via sockfd FSMLOG(3) <<"Connected to "<<address.sun_path<<endl; ! msg=new unsigned char[sizeof(tEvent::Event)+len]; event=(tEvent::Event *)msg; if (msg != NULL) --- 187,191 ---- // Now we can read/write via sockfd FSMLOG(3) <<"Connected to "<<address.sun_path<<endl; ! //msg=new unsigned char[sizeof(tEvent::Event)+len]; event=(tEvent::Event *)msg; if (msg != NULL) *************** *** 212,220 **** } close(sockfd); ! delete[] msg ; } } return bytes_sent; } --- 218,227 ---- } close(sockfd); ! //delete[] msg ; } } + delete[] msg ; return bytes_sent; } |
|
From: Andreu M. <am...@us...> - 2004-03-26 12:31:40
|
Update of /cvsroot/dfsm/dFSM/src/libdfsm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12335/src/libdfsm Modified Files: tfsm.cpp Log Message: Minor improvement in using tinputs macro Index: tfsm.cpp =================================================================== RCS file: /cvsroot/dfsm/dFSM/src/libdfsm/tfsm.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** tfsm.cpp 17 Mar 2004 21:59:50 -0000 1.31 --- tfsm.cpp 26 Mar 2004 12:20:43 -0000 1.32 *************** *** 30,33 **** --- 30,36 ---- * $Revision$ * $Log$ + * Revision 1.32 2004/03/26 12:20:43 amoreno + * Minor improvement in using tinputs macro + * * Revision 1.31 2004/03/17 21:59:50 jvalduvieco * Minor improvements: *************** *** 180,184 **** //tFSM::monitor = new tfsm_monitor_sensor(machine ,(machine == 0)); tFSM::events = new tEvent(); ! tInput_service::getInstance()->get_pointer()->set_event_handler(tFSM::events); tFSM::transition_rep=new tTransition_rep(); --- 183,187 ---- //tFSM::monitor = new tfsm_monitor_sensor(machine ,(machine == 0)); tFSM::events = new tEvent(); ! tinputs->set_event_handler(tFSM::events); tFSM::transition_rep=new tTransition_rep(); |