rendered paste body? chris.patch5? chris3.patch? hal/.tm_project.cache? hal/classicladder.prj? hal/classicladder.pws? hal/hal.prj? hal/hal.pwsIndex: hal/classicladder/arrays.c===================================================================RCS file: /cvs/emc2/src/hal/classicladder/arrays.c,vretrieving revision 1.8.2.1diff -u -r1.8.2.1 arrays.c--- hal/classicladder/arrays.c 21 Jan 2007 19:10:39 -0000 1.8.2.1+++ hal/classicladder/arrays.c 24 May 2007 04:58:44 -0000@@ -126,7 +126,10 @@ .nbr_phys_outputs = NBR_PHYS_OUTPUTS_DEF, .nbr_arithm_expr = NBR_ARITHM_EXPR_DEF, .nbr_sections = NBR_SECTIONS_DEF,- .nbr_symbols = NBR_SYMBOLS_DEF+ .nbr_symbols = NBR_SYMBOLS_DEF,+ .nbr_refresh = NBR_REFRESH_DEF,+ .nbr_s32in = NBR_S32IN_DEF,+ .nbr_s32out = NBR_S32OUT_DEF }; #endif @@ -154,8 +157,7 @@ #ifdef RTAPI pSizesInfos = &sinfo; // Calculate SHMEM size.- numBits =- pSizesInfos->nbr_bits + pSizesInfos->nbr_phys_inputs ++ numBits = pSizesInfos->nbr_bits + pSizesInfos->nbr_phys_inputs + pSizesInfos->nbr_phys_outputs; numWords = pSizesInfos->nbr_words; #ifdef SEQUENTIAL_SUPPORT@@ -174,6 +176,7 @@ #endif bytes += numWords * sizeof(int); bytes += numBits * sizeof(TYPE_FOR_BOOL_VAR);+ bytes += 1 * sizeof(int); // am guessing for numRefresh variable cm #endif // Attach SHMEM with proper size. if ((ShmemId = rtapi_shmem_new(CL_SHMEM_KEY, compId, bytes)) < 0) {@@ -225,7 +228,7 @@ InfosGene->CurrentSection = 0; #endif - rtapi_print("Sizes: %d %d %d %d %d %d %d %d %d %d %d\n",+ rtapi_print("Sizes: rungs- %d bits- %d words- %d timers- %d mono- %d count- %d \n HAL Bin- %d HAL Bout- %d expressions- %d sections- %d symbols - %d\n refresh- %d s32in - %d s32out- %d\n", pSizesInfos->nbr_rungs, pSizesInfos->nbr_bits, pSizesInfos->nbr_words,@@ -236,7 +239,10 @@ pSizesInfos->nbr_phys_outputs, pSizesInfos->nbr_arithm_expr, pSizesInfos->nbr_sections,- pSizesInfos->nbr_symbols);+ pSizesInfos->nbr_symbols,+ pSizesInfos->nbr_refresh,+ pSizesInfos->nbr_s32in,+ pSizesInfos->nbr_s32out); // Set global SHMEM pointers. pByte = (unsigned char *) InfosGene;@@ -468,7 +474,6 @@ InitIOConf( ); InfosGene->AskConfirmationToQuit = FALSE; InfosGene->DisplaySymbols = TRUE;- return TRUE; } @@ -555,4 +560,4 @@ DisplaySymbols( ); } #endif-}+}Index: hal/classicladder/classicladder.c===================================================================RCS file: /cvs/emc2/src/hal/classicladder/classicladder.c,vretrieving revision 1.8.2.2diff -u -r1.8.2.2 classicladder.c--- hal/classicladder/classicladder.c 20 Feb 2007 01:45:46 -0000 1.8.2.2+++ hal/classicladder/classicladder.c 24 May 2007 04:58:45 -0000@@ -67,10 +67,7 @@ #if !defined( MODULE ) && !defined( RTAPI ) -#ifdef __WIN32__-HANDLE ThreadHandleCyclicRefresh = NULL;-DWORD ThreadIdCyclicRefresh;-#else+ pthread_t thread_cyclic_refresh; #endif int CyclicThreadRunning = 0;@@ -78,12 +75,8 @@ void HandlerSignalInterrupt( int signal_id ) { printf("End of application asked\n");-#ifdef HAL_SUPPORT+// HAL_SUPPORT hal_exit(compId);-#else- CloseSocketModbusMaster( );- CloseSocketServer( );-#endif ClassicLadderFreeAll(); exit( 0 ); }@@ -102,21 +95,23 @@ "-c file --config=file read PLC configuration from file\n" #endif );+ hal_exit(compId); exit(0); } void display_version (void) {- printf("ClassicLadder v" RELEASE_VER_STRING "\n" RELEASE_DATE_STRING "\n"- "\n"- "Copyright (C) 2001-2004 Marc Le Douarain\nmavati@club-internet.fr\n"- "\n"+ printf("\nClassicLadder v" RELEASE_VER_STRING "\n" RELEASE_DATE_STRING "\n"+ "Copyright (C) 2001-2004 Marc Le Douarain\nmavati@club-internet.fr\n"+ "Adapted to EMC\n"+ "\n" "ClassicLadder comes with NO WARRANTY\n" "to the extent permitted by law.\n" "\n" "You may redistribute copies of ClassicLadder\n" "under the terms of the GNU Lesser General Public Licence.\n" "See the file `lesserGPL.txt' for more information.\n");+ hal_exit(compId); exit(0); } @@ -140,9 +135,7 @@ int c = getopt_long(argc, argv, short_options, long_options, &option_index);- if (c == EOF) {- break;- }+ if (c == EOF) {break;} switch (c) { case 0:@@ -156,13 +149,12 @@ } break; case 'c':-#ifndef RT_SUPPORT- read_config (optarg);-#else- printf("Config file is used by the RT module in RTLinux version !!!\n");-#endif++ printf("Config file is not used in EMC.\n Configure info is specified when loading the classicladder RT module only!\n");+ hal_exit(compId);+ exit(0); break;- case 'n':+ case 'n': nogui = 1; break; case 'p':@@ -181,199 +173,85 @@ VerifyDirectorySelected (argv[optind]); } -#ifndef HAL_SUPPORT-void DoPauseMilliSecs( int Time )-{-#ifdef __WIN32__- Sleep( Time );-#else- struct timespec time;- time.tv_sec = 0;- time.tv_nsec = Time*1000000;- nanosleep( &time, NULL );- //usleep( Time*1000 );-#endif-}--void CyclicCalcRefresh( void )-{-#ifdef __XENO__- struct timespec start, period, now;- unsigned long overruns;- int err = 0;- pthread_set_name_np( pthread_self(), __FUNCTION__ );- clock_gettime( CLOCK_REALTIME, &start );- start.tv_sec += 1; /* Start in one second from now. */- period.tv_sec = 0;- period.tv_nsec = TIME_REFRESH_RUNG_MS*1000000;- if ( pthread_make_periodic_np(pthread_self(), &start, &period)!=0 )- {- printf("Xenomai make_periodic failed: err %d\n", err);- exit(EXIT_FAILURE);- }-#endif- while( CyclicThreadRunning )- {-#ifdef __XENO__- err = pthread_wait_np(&overruns);- if (err || overruns) {- printf( "Xenomai wait_period failed: err %d, overruns: %lu\n", err, overruns);-// exit(EXIT_FAILURE);- }-#else- DoPauseMilliSecs( TIME_REFRESH_RUNG_MS );-#endif-- if (InfosGene->LadderState==STATE_RUN)- {-#ifdef __XENO__- clock_gettime( CLOCK_REALTIME, &start );-#endif- ReadPhysicalInputs();- RefreshAllRungs();- WritePhysicalOutputs();--#ifdef __XENO__- clock_gettime( CLOCK_REALTIME, &now );- if ( now.tv_sec==start.tv_sec )- InfosGene->DurationOfLastScan = now.tv_nsec-start.tv_nsec;-#endif- }- }-#ifndef __WIN32__- pthread_exit(NULL);-#endif-}--int InitCyclicThread( void )-{- int InitOk = 0;- int Error;- CyclicThreadRunning = 1;-#ifdef __WIN32__- ThreadHandleCyclicRefresh = CreateThread( NULL/*no security attributes*/, 16*1024L/*default stack size*/, - (LPTHREAD_START_ROUTINE)CyclicCalcRefresh/* thread function*/, - NULL/*argument to thread function*/, - THREAD_QUERY_INFORMATION/*use default creation flags*/, - &ThreadIdCyclicRefresh/* returns the thread identifier*/); - if ( ThreadHandleCyclicRefresh==NULL )-#else- pthread_attr_t ThreadAttributes;- pthread_attr_init(&ThreadAttributes);- pthread_attr_setdetachstate(&ThreadAttributes, PTHREAD_CREATE_DETACHED /*PTHREAD_CREATE_JOINABLE*/);-#ifdef __XENO__- pthread_attr_setschedpolicy(&ThreadAttributes, SCHED_FIFO);- struct sched_param paramA = { .sched_priority = 98 };- pthread_attr_setschedparam(&ThreadAttributes, ¶mA);-#endif- pthread_attr_setstacksize(&ThreadAttributes, 32*1024);- Error = pthread_create( &thread_cyclic_refresh, &ThreadAttributes, (void *(*)(void *))CyclicCalcRefresh, (void *)NULL );- if (Error==-1)-#endif- printf("Failed to create cyclic calc thread...\n");- else- InitOk = 1;- return InitOk;-}-#endif--#ifdef HAL_SUPPORT+// HAL_SUPPORT static void do_exit(int unused) { hal_exit(compId);+ printf("Error inticalising classicladder user module"); _exit(0); }-#endif+ int main( int argc, char *argv[] ) {-#ifdef __XENO__- mlockall(MCL_CURRENT | MCL_FUTURE);-#endif+ int used=0, NumRung; -#if defined(HAL_SUPPORT) && defined(ULAPI)- compId = hal_init("classicladder");+//HAL_SUPPORT+ + compId = hal_init("classicladder"); if(compId < 0) return -1; signal(SIGTERM, do_exit);- hal_ready(compId);-#endif--#ifdef USE_MODBUS- InitModbusMasterBeforeReadConf( );-#endif+ process_options (argc, argv); if (ClassicLadderAllocAll()) {- if ( nogui ) {- InitAllLadderDatas( TRUE );- InitTempDir( );- LoadProjectFiles( LadderDirectory );- InfosGene->LadderState = STATE_RUN;- ClassicLadderFreeAll();- hal_exit(compId);- return 0;- }-#if !defined(HAL_SUPPORT)- InitAllLadderDatas( TRUE );- InitSocketServer( 0/*UseUdpMode*/, ModbusServerPort/*PortNbr*/ );- InitSocketModbusMaster( );-#endif+ if ( nogui )+ {+ printf("**** NO GUI! ****\n"); + InitAllLadderDatas( TRUE );+ InitTempDir( );+ LoadProjectFiles( LadderDirectory );+// start the ladder program + InfosGene->LadderState = STATE_RUN;+// Let HAL know we are ready now+ hal_ready(compId); + printf("Ladder project loaded\n");+ hal_exit(compId); + return 0;+ }+++ else{ +//check for used rungs+// check for previous program loaded+ printf("checking for used rungs\n");+ for(NumRung=0;NumRung<NBR_RUNGS;NumRung++) + { if(RungArray[NumRung].Used) used++; }+ printf("Used rungs: %d\n", used);+ + if (used==0) + { InitAllLadderDatas( TRUE );} -// cyclic thread for rt is in the kernel (RTLinux/RTAI)-#if #defined(RT_SUPPORT) && !defined(HAL_SUPPORT)- if ( InitCyclicThread( ) )-#endif- {- int used=0, NumRung;- for(NumRung=0;NumRung<NBR_RUNGS;NumRung++) {- if(RungArray[NumRung].Used) used++;- }- printf("Used rungs: %d\n", used); #ifdef GTK_INTERFACE- InitGtkWindows( argc, argv );+ InitGtkWindows( argc, argv );+ printf("Init GTK"); #endif+ InitTempDir( );+ printf("Init tmp dir=%s\n", TmpDirectory); - - // added here in v0.7.5- InitTempDir( );-printf("Init tmp dir=%s\n", TmpDirectory);- - //// LoadAllLadderDatas(LadderDirectory);- if(!used)- LoadProjectFiles( LadderDirectory );+// if no rungs used (meaning no program previously loaded)+// then Load All LadderDatas+ if(used==0)+ { LoadProjectFiles( LadderDirectory );}+ #ifdef GTK_INTERFACE- UpdateGtkAfterLoading( TRUE/*cCreateTimer*/ );-#endif-#ifndef RT_SUPPORT- OpenHardware( 0 );- ConfigHardware( );+ UpdateGtkAfterLoading( TRUE/*cCreateTimer*/ ); #endif- - InfosGene->LadderState = STATE_RUN;- +// start running ladder program+ InfosGene->LadderState = STATE_RUN;+//let HAL know we are ready...+ hal_ready(compId);+ #ifdef GTK_INTERFACE- //ProblemWithPrint gdk_threads_enter( );+//ProblemWithPrint gdk_threads_enter( );+ printf("Loading GUI\n"); gtk_main();- //ProblemWithPrint gdk_threads_leave( );-#else- signal( SIGINT /*SIGTERM*/, HandlerSignalInterrupt );- printf("Running...\n");- for( ;; )- sleep( 1 );-#endif- CyclicThreadRunning = 0;-#ifdef __WIN32__- if ( ThreadHandleCyclicRefresh )- TerminateThread( ThreadHandleCyclicRefresh, 0);-#endif - }- }- else- {- ClassicLadderFreeAll();+ printf("GUI closed realtime module still runs till HAL closes\n");+//ProblemWithPrint gdk_threads_leave( ); + } }-+ else { ClassicLadderFreeAll();}+ hal_exit(compId);- return 0; }-#endif+#endifIndex: hal/classicladder/classicladder.h===================================================================RCS file: /cvs/emc2/src/hal/classicladder/classicladder.h,vretrieving revision 1.4diff -u -r1.4 classicladder.h--- hal/classicladder/classicladder.h 16 Nov 2006 01:45:33 -0000 1.4+++ hal/classicladder/classicladder.h 24 May 2007 04:58:45 -0000@@ -41,6 +41,9 @@ #define NBR_ARITHM_EXPR_DEF 100 #define NBR_SECTIONS_DEF 10 #define NBR_SYMBOLS_DEF 100+#define NBR_REFRESH_DEF 50+#define NBR_S32IN_DEF 0+#define NBR_S32OUT_DEF 0 #define NBR_INPUTS_CONF 5 #define NBR_OUTPUTS_CONF 5@@ -58,7 +61,10 @@ int nbr_arithm_expr; int nbr_sections; int nbr_symbols;-}plc_sizeinfo_s;+ int nbr_refresh; //number of ms between refresh of rungs+ int nbr_s32in; //number of HAL signed inputs+ int nbr_s32out; // number of HAL signed outputs+ }plc_sizeinfo_s; #define NBR_RUNGS InfosGene->SizesInfos.nbr_rungs #define NBR_BITS InfosGene->SizesInfos.nbr_bits@@ -71,7 +77,10 @@ #define NBR_ARITHM_EXPR InfosGene->SizesInfos.nbr_arithm_expr #define NBR_SECTIONS InfosGene->SizesInfos.nbr_sections #define NBR_SYMBOLS InfosGene->SizesInfos.nbr_symbols-+#define NBR_REFRESH InfosGene->SizesInfos.nbr_refresh //add cm+#define NBR_S32IN InfosGene->SizesInfos.nbr_s32in+#define NBR_S32OUT InfosGene->SizesInfos.nbr_s32out+ #else /* static size */ #define NBR_RUNGS NBR_RUNGS_DEF@@ -85,6 +94,10 @@ #define NBR_ARITHM_EXPR NBR_ARITHM_EXPR_DEF #define NBR_SECTIONS NBR_SECTIONS_DEF #define NBR_SYMBOLS NBR_SYMBOLS_DEF+#define NBR_REFRESH NBR_REFRESH_DEF+#define NBR_S32IN NBR_S32IN_DEF+#define NBR_S32OUT NBR_S32OUT_DEF+ #endif #define ARITHM_EXPR_SIZE 32@@ -95,7 +108,7 @@ #define TYPE_FOR_BOOL_VAR char #endif -#define TIME_REFRESH_RUNG_MS 100+#define TIME_REFRESH_RUNG_MS 100 #define TIME_BASE_MINS 60000 #define TIME_BASE_SECS 1000 #define TIME_BASE_100MS 100@@ -379,4 +392,4 @@ #include "hal.h" extern int compId; #endif-extern int nogui;+extern int nogui;Index: hal/classicladder/classicladder_gtk.c===================================================================RCS file: /cvs/emc2/src/hal/classicladder/classicladder_gtk.c,vretrieving revision 1.16.2.3diff -u -r1.16.2.3 classicladder_gtk.c--- hal/classicladder/classicladder_gtk.c 14 Mar 2007 23:47:28 -0000 1.16.2.3+++ hal/classicladder/classicladder_gtk.c 24 May 2007 04:58:45 -0000@@ -33,9 +33,9 @@ #include "classicladder_gtk.h" // #include "hardware.h" -#define NBR_BOOLS_VAR_SPY 15-#define NBR_TYPE_BOOLS_SPY 3-#define NBR_FREE_VAR_SPY 5+#define NBR_BOOLS_VAR_SPY 15 //for bit variable list (15 in each column)+#define NBR_TYPE_BOOLS_SPY 3 // for 3 columns+#define NBR_FREE_VAR_SPY 10 //for word variable list (10 variables) GdkPixmap *pixmap = NULL; GtkWidget *drawing_area = NULL;@@ -43,7 +43,8 @@ int ValOffsetBoolVar[ NBR_TYPE_BOOLS_SPY ] = { 0, 0, 0 }; GtkWidget *chkvar[ NBR_TYPE_BOOLS_SPY ][ NBR_BOOLS_VAR_SPY ]; GtkWidget *EntryVarSpy[NBR_FREE_VAR_SPY*2];-int VarSpy[NBR_FREE_VAR_SPY][2] = { {VAR_MEM_WORD,0}, {VAR_MEM_WORD,1}, {VAR_MEM_WORD,2}, {VAR_MEM_WORD,3}, {VAR_MEM_WORD,4} }; /* defaults vars to spy */+int VarSpy[NBR_FREE_VAR_SPY][2] = { {VAR_MEM_WORD,0}, {VAR_MEM_WORD,1}, {VAR_MEM_WORD,2}, {VAR_MEM_WORD,3}, {VAR_MEM_WORD,4}, {VAR_MEM_WORD,5}, {VAR_MEM_WORD,6}, {VAR_MEM_WORD,7}, {VAR_MEM_WORD,8},{VAR_MEM_WORD,9 } }; /* defaults vars to spy */+static int VarWindowToggle; // toggle display of vars window variable GtkWidget *DisplayFormatVarSpy[NBR_FREE_VAR_SPY]; GtkWidget *entrylabel,*entrycomment; GtkWidget *CheckDispSymbols;@@ -58,7 +59,8 @@ GtkWidget *FileSelector; GtkWidget *ConfirmDialog; GtkWidget *RungWindow;-+GtkWidget *windowvars;+GtkWidget *windowvars2; #include "drawing.h" #include "vars_access.h" #include "calc.h"@@ -395,7 +397,18 @@ gtk_widget_set_sensitive(entrycomment, TRUE); } }-+void ButtonRefresh_click()+{+ if (InfosGene->SizesInfos.nbr_refresh <=10)+ {+ InfosGene->SizesInfos.nbr_refresh=100;+ }+ else+ {+ InfosGene->SizesInfos.nbr_refresh-=10; + }+ } + void ButtonRunStop_click() { if (InfosGene->LadderState==STATE_RUN)@@ -610,11 +623,20 @@ GtkWidget *dialog, *label, *okay_button; /* Create the widgets */ dialog = gtk_dialog_new();- label = gtk_label_new ("ClassicLadder v" RELEASE_VER_STRING "\n" RELEASE_DATE_STRING "\n"+ label = gtk_label_new (" Classicladder v" RELEASE_VER_STRING "\n" RELEASE_DATE_STRING "\n"+ "EMC2 Development of Classicladder\n" "Copyright (C) 2001-2006 Marc Le Douarain\nmarc . le - douarain /At\\ laposte \\DoT/ net\n" "http://www.sourceforge.net/projects/classicladder\n" "http://www.multimania.com/mavati/classicladder\n"- "Released under the terms of the\nGNU Lesser General Public License v2.1");+ "Released under the terms of the\nGNU Lesser General Public License v2.1\n"+ "Updates:\n"+ " ***New to this update ***\n"+ "-compare/equate works properly, accepts symbols\n"+ "-Two variable windows, toggle button to show/hide\n"+ "-HAL s32 IN and OUT equipt words \n"+ "-refresh rate button, rate is variable\n"+ "-symbols checkbox in section display controls variable window also\n"+ "number of HAL s32 IN / OUT pins and rate of rung refresh configurable when loading classicladder RT module\n" ); gtk_label_set_justify( GTK_LABEL(label), GTK_JUSTIFY_CENTER ); okay_button = gtk_button_new_with_label("Okay"); /* Ensure that the dialog box is destroyed when the user clicks ok. */@@ -688,8 +710,8 @@ } void DoQuit( void )-{- gtk_widget_destroy( RungWindow );+{ + gtk_widget_destroy( RungWindow ); //sends signal 'destroy' to end the GUI } void ConfirmQuit( void ) {@@ -700,8 +722,8 @@ } gint RungWindowDeleteEvent( GtkWidget * widget, GdkEvent * event, gpointer data ) {- ConfirmQuit( );- // we do not want that the window be destroyed.+ ConfirmQuit( ); //If confirm quit returns then+ // we do not want the window to be destroyed. return TRUE; } void OpenEditWindow( void )@@ -712,13 +734,14 @@ #endif } + void RungWindowInitGtk() { GtkWidget *vbox,*hboxtop,*hboxbottom,*hboxbottom2; GtkWidget *hboxmiddle; GtkWidget *ButtonQuit; GtkWidget *ButtonNew,*ButtonLoad,*ButtonSave,*ButtonSaveAs,*ButtonReset,*ButtonConfig,*ButtonAbout;- GtkWidget *ButtonEdit,*ButtonSymbols;+ GtkWidget *ButtonEdit,*ButtonSymbols,*ButtonVars,*ButtonRefresh; #ifdef GNOME_PRINT_USE GtkWidget *ButtonPrint,*ButtonPrintPreview; #endif@@ -837,7 +860,12 @@ gtk_signal_connect(GTK_OBJECT (ButtonReset), "clicked", (GtkSignalFunc) ButtonReset_click, 0); gtk_widget_show (ButtonReset);- ButtonRunStop = gtk_button_new_with_label ("Stop");+ ButtonRefresh= gtk_button_new_with_label ("Refresh");+ gtk_box_pack_start (GTK_BOX (hboxbottom), ButtonRefresh, TRUE, TRUE, 0);+ gtk_signal_connect(GTK_OBJECT (ButtonRefresh), "clicked",+ (GtkSignalFunc) ButtonRefresh_click, 0);+ gtk_widget_show (ButtonRefresh);+ ButtonRunStop = gtk_button_new_with_label ("Stop"); gtk_box_pack_start (GTK_BOX (hboxbottom), ButtonRunStop, TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT (ButtonRunStop), "clicked", (GtkSignalFunc) ButtonRunStop_click, 0);@@ -853,7 +881,12 @@ gtk_signal_connect(GTK_OBJECT (ButtonSymbols), "clicked", (GtkSignalFunc) OpenSymbolsWindow, 0); gtk_widget_show (ButtonSymbols);- ButtonConfig = gtk_button_new_with_label ("Config");+ ButtonVars = gtk_button_new_with_label ("Vars"); // add button to open vars list+ gtk_box_pack_start (GTK_BOX (hboxbottom2), ButtonVars, TRUE, TRUE, 0);+ gtk_signal_connect(GTK_OBJECT (ButtonVars), "clicked",+ (GtkSignalFunc) OpenVarsWindow, 0);+ gtk_widget_show (ButtonVars);+ ButtonConfig = gtk_button_new_with_label ("Config"); gtk_box_pack_start (GTK_BOX (hboxbottom2), ButtonConfig, TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT (ButtonConfig), "clicked", (GtkSignalFunc) ButtonConfig_click, 0);@@ -909,31 +942,34 @@ } gint VarsWindowDeleteEvent( GtkWidget * widget, GdkEvent * event, gpointer data )-{- // we do not want that the window be destroyed.+{ + VarWindowToggle=(VarWindowToggle-1)*-1; //toggle the windowtoggle variable+ gtk_widget_hide (windowvars2); + gtk_widget_hide (windowvars);+ // we can not destroy return TRUE; } void VarsWindowInitGtk() {- GtkWidget *windowvars;+ //GtkWidget *windowvars; // used for bit variables+ //GtkWidget *windowvars2; // used for word variable list GtkWidget *vboxboolvars[ NBR_TYPE_BOOLS_SPY ],*vboxmain,*hboxvars,*hboxvars2;- GtkWidget * hboxfreevars[ NBR_FREE_VAR_SPY ];+ GtkWidget *hboxfreevars[ NBR_FREE_VAR_SPY ],*vboxmain2;//added cm int NumCheckWidget,ColumnVar,NumVarSpy,NumEntry; GList *DisplayFormatItems = NULL;- + windowvars = gtk_window_new (GTK_WINDOW_TOPLEVEL);- gtk_window_set_title ((GtkWindow *)windowvars, "Vars");+ gtk_window_set_title ((GtkWindow *)windowvars, "Bit Vars");+ vboxmain = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (windowvars), vboxmain); gtk_widget_show (vboxmain);+ hboxvars = gtk_hbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (vboxmain), hboxvars); gtk_widget_show (hboxvars);- hboxvars2 = gtk_hbox_new (FALSE, 0);- gtk_container_add (GTK_CONTAINER (vboxmain), hboxvars2);- gtk_widget_show (hboxvars2);-+ for( ColumnVar=0; ColumnVar<NBR_TYPE_BOOLS_SPY; ColumnVar++ ) { vboxboolvars[ ColumnVar ] = gtk_vbox_new (FALSE, 0);@@ -968,17 +1004,32 @@ } } UpdateAllLabelsBoolsVars( );+ //gtk_widget_show (windowvars); //default hide window+ + // next is to build vars2 window+ + windowvars2 = gtk_window_new (GTK_WINDOW_TOPLEVEL); //added cm+ gtk_window_set_title ((GtkWindow *)windowvars2, " Word Vars"); // added cm + vboxmain2 = gtk_vbox_new (FALSE, 0);//added cm+ gtk_container_add (GTK_CONTAINER (windowvars2), vboxmain2);//added cm+ gtk_widget_show (vboxmain2);//added cm+ + hboxvars2 = gtk_hbox_new (FALSE, 0);+ gtk_container_add (GTK_CONTAINER (vboxmain2), hboxvars2);// changed cm+ gtk_widget_show (hboxvars2);+ + // NBR_FREE_VAR_SPY = how many WORDS shown for(NumVarSpy=0; NumVarSpy<NBR_FREE_VAR_SPY; NumVarSpy++) { hboxfreevars[ NumVarSpy ] = gtk_hbox_new (FALSE, 0);- gtk_container_add (GTK_CONTAINER (vboxmain), hboxfreevars[ NumVarSpy ]);+ gtk_container_add (GTK_CONTAINER (vboxmain2), hboxfreevars[ NumVarSpy ]); gtk_widget_show (hboxfreevars[ NumVarSpy ]); for(ColumnVar=0; ColumnVar<2; ColumnVar++) { NumEntry = NumVarSpy+ColumnVar*NBR_FREE_VAR_SPY; EntryVarSpy[ NumEntry ] = gtk_entry_new();- gtk_widget_set_usize((GtkWidget *)EntryVarSpy[ NumEntry ],(ColumnVar==0)?50:80,0);+ gtk_widget_set_usize((GtkWidget *)EntryVarSpy[ NumEntry ],(ColumnVar==0)?85:80,0); gtk_box_pack_start (GTK_BOX( hboxfreevars[ NumVarSpy ] ), EntryVarSpy[ NumEntry ], TRUE, TRUE, 0); gtk_widget_show(EntryVarSpy[NumEntry]); if ( ColumnVar==0 )@@ -999,9 +1050,28 @@ gtk_signal_connect( GTK_OBJECT(windowvars), "delete_event", (GtkSignalFunc)VarsWindowDeleteEvent, 0 );- gtk_widget_show (windowvars);+ gtk_signal_connect( GTK_OBJECT(windowvars2), "delete_event",+ (GtkSignalFunc)VarsWindowDeleteEvent, 0 );+ //gtk_widget_show (windowvars2);//default the windows hidden+ } +void OpenVarsWindow ( void )+{+ + if (!VarWindowToggle)+ { gtk_widget_show (windowvars); //show windows+ gtk_window_present( GTK_WINDOW(windowvars) );+ gtk_widget_show (windowvars2);+ gtk_window_present( GTK_WINDOW(windowvars2) );+ }+ else {gtk_widget_hide (windowvars); //hide windows+ gtk_widget_hide (windowvars2);+ }+ VarWindowToggle=(VarWindowToggle-1)*-1; //toggle+} ++ char * ConvToBin( unsigned int Val ) { static char TabBin[ 33 ];@@ -1033,6 +1103,8 @@ int Value; char BufferValue[50]; char DisplayFormat[10];+ static int LastTime;+ int NumEntry; for (NumVarSpy=0; NumVarSpy<NBR_FREE_VAR_SPY; NumVarSpy++) { Value = ReadVar(VarSpy[NumVarSpy][0],VarSpy[NumVarSpy][1]);@@ -1045,7 +1117,19 @@ if (strcmp( DisplayFormat,"Bin" )==0 ) strcpy( BufferValue, ConvToBin( Value ) ); gtk_entry_set_text((GtkEntry *)EntryVarSpy[NBR_FREE_VAR_SPY+NumVarSpy],BufferValue);+ if (InfosGene->DisplaySymbols!=LastTime) //check if display symbols checkbox changed+ { + NumEntry = NumVarSpy+0*NBR_FREE_VAR_SPY;// toggle display of symbols/variables in vars2 + gtk_entry_set_text((GtkEntry *)EntryVarSpy[ NumEntry ],DisplayInfo(VarSpy[NumVarSpy][0],VarSpy[NumVarSpy][1]));+ }+ }+ // we do this check after the FOR loop+ // so it does not toggle each time thru loop+ if (InfosGene->DisplaySymbols!=LastTime) //check if toggled display+ {+ LastTime=((LastTime-1)*-1); //toggle lasttime variable to match display+ } } void RefreshOneBoolVar( int Type, int Num, int Val )@@ -1093,13 +1177,14 @@ void quit_appli() { #ifdef HAL_SUPPORT- hal_exit(compId);-#else- CloseSocketModbusMaster( );- CloseSocketServer( );+ +#else + CloseSocketModbusMaster( );+ CloseSocketServer( ); #endif- ClassicLadderFreeAll();- gtk_exit (0);+ + //ClassicLadderFreeAll();+ gtk_main_quit(); } static gint PeriodicUpdateDisplay(gpointer data)Index: hal/classicladder/classicladder_gtk.h===================================================================RCS file: /cvs/emc2/src/hal/classicladder/classicladder_gtk.h,vretrieving revision 1.5diff -u -r1.5 classicladder_gtk.h--- hal/classicladder/classicladder_gtk.h 16 Nov 2006 01:45:33 -0000 1.5+++ hal/classicladder/classicladder_gtk.h 24 May 2007 04:58:45 -0000@@ -11,4 +11,4 @@ void quit_appli(); void InitGtkWindows( int argc, char *argv[] ); void UpdateGtkAfterLoading( char cCreateTimer );-+void OpenVarsWindow( void );Index: hal/classicladder/config_gtk.c===================================================================RCS file: /cvs/emc2/src/hal/classicladder/config_gtk.c,vretrieving revision 1.3diff -u -r1.3 config_gtk.c--- hal/classicladder/config_gtk.c 16 Nov 2006 01:45:33 -0000 1.3+++ hal/classicladder/config_gtk.c 24 May 2007 04:58:45 -0000@@ -30,7 +30,7 @@ #include "global.h" #include "config_gtk.h" -#define NBR_OBJECTS 9+#define NBR_OBJECTS 10 GtkWidget *LabelParam[ NBR_OBJECTS ],*ValueParam[ NBR_OBJECTS ]; static char * Devices[] = { "None", "DirectPortAccess",@@ -118,6 +118,10 @@ sprintf( BuffLabel, "Nbr.Sections (%d%c used)", InfoUsed,'%' ); sprintf( BuffValue, "%d", InfosGene->SizesInfos.nbr_sections ); break;+ case 9: + sprintf( BuffLabel, "Rung Refresh Rate" );+ sprintf( BuffValue, "%d", InfosGene->SizesInfos.nbr_refresh );+ break; default: sprintf( BuffLabel, "???" ); sprintf( BuffValue, "???" );@@ -634,5 +638,3 @@ gtk_widget_show( ConfigWindow ); }--Index: hal/classicladder/edit.c===================================================================RCS file: /cvs/emc2/src/hal/classicladder/edit.c,vretrieving revision 1.3diff -u -r1.3 edit.c--- hal/classicladder/edit.c 16 Nov 2006 01:45:33 -0000 1.3+++ hal/classicladder/edit.c 24 May 2007 04:58:46 -0000@@ -455,81 +455,176 @@ /* return pointer on the new string converted and verified if okay, else NULL */ char * TextParserForArithmExpr(char * text, int TypeElement) {- static char NewExpr[100];- char Buffer[20];+ static char NewExpr[100];+ char Buffer[20];+ char Temp [2]; int ItIsOk = TRUE;+ int BeenHere = FALSE;+ int HaveAUnit= FALSE; int VarType; int VarOffset;- char * ptr = text; int StringLength;+ char * tmpptr = text;+ char * bufptr = Buffer; ErrorMessageVarParser = NULL; strcpy(NewExpr,"");- /* Convert expression for variables authorized */- do- {-//TODO: symbols strings to support here...- /* Verify if it is a variable (character and number) */- if ( *ptr=='%' && *(ptr+2)>='0' && *(ptr+2)<='9' )- {- switch(*(ptr+1))- {- case 'W':- case 'T':- case 'M':- case 'C':- case 'X':- if (TextParserForAVar(ptr,&VarType,&VarOffset,&StringLength,FALSE/*PartialNames*/))+ strcpy(Buffer,"");+ + // we want to break the text into a "unit". The unit is between the math + // symbols. The unit is check for a symbol, proper variable, decimal or text and converted. + + // if the text is empty then set an error which does nothing+ if (*tmpptr == '\0') { ItIsOk=FALSE;}+ + do{+ do{+ + + switch (*tmpptr)+ {+ case '\0':// we have found the end-must be a unit to check+ HaveAUnit= TRUE; + break;+ case ' ':+ ItIsOk= FALSE;+ ErrorMessageVarParser="No spaces allowed.";+ break;+ case '=':case '<':case '>':case '*':case '/':case '|':case ',':+ case '!':case '&':case '+':case '-':case ')':case '^':+ if (BeenHere==TRUE) // been here before then save the math symbols+ { + //printf("added %c to NewExpr\n",*tmpptr);+ sprintf (Temp,"%c",*tmpptr);+ strcat(NewExpr,Temp);+ tmpptr ++;+ }+ else { + //printf("set been here true\n");+ HaveAUnit=TRUE;// otherwise we have a unit to check+ BeenHere=TRUE;+ }+ break;+ case '(': // is this the beginning bracket of absolute, minimum, maximum or average(MOY) funtion? + if (strcmp(Buffer,"ABS")==0 || strcmp(Buffer,"MINI")|| strcmp(Buffer,"MAXI")||strcmp(Buffer,"MOY")) + { sprintf(Temp,"%c",*tmpptr);// add ( to our buffer + strcat(Buffer,Temp);+ strcat(NewExpr,Buffer); // add Buffer to NewExp+ strcpy(Buffer,""); //clear buffer+ tmpptr ++; // next character+ }+ else+ {+ // printf("added %c to NewExpr NewExpr %s\n",*tmpptr,NewExpr); + sprintf (Temp,"%c",*tmpptr); // add it to NewExpr+ strcat(NewExpr,Temp);+ tmpptr ++;+ } + break;+ default:+ //printf("added %c to Buffer\n",*tmpptr);+ sprintf(Temp,"%c",*tmpptr);// add it to our buffer to make a unit+ strcat(Buffer,Temp);+ tmpptr ++;+ BeenHere=FALSE;+ break;+ }+ + + } + while (HaveAUnit == FALSE && ItIsOk == TRUE); ++ if (ItIsOk == TRUE) // we have a unit and no error+ {+ //printf("Have a unit! %s\n",Buffer);+ if (*bufptr !='%') // if not a variable+ {+ char * VarName=ConvSymbolToVarName(bufptr);// check for symbols+ + if (VarName!=NULL)+ { + //printf("converted symbol to variable %s,%s\n",Buffer,VarName);+ strcpy(Buffer,""); // empty buffer of symbols+ strcpy(Buffer,VarName); // copy the variable in+ }+ }+ if (*bufptr !='%') // still not a variable?+ { + //printf("checking for a number\n");+ switch (*bufptr) // does it have to do with numbers dec or hex? {+ case '0':case '1':case '2':case '3':+ case '4':case '5':case '6':case '7':+ case '8':case '9':case '-':case '+':+ case '(':case ')':case '$':case '\0': //or at the end+ //printf("found number\n"); + break;++ default:+ //printf("'%c' is not a number!\n",*bufptr); + ItIsOk=FALSE;+ ErrorMessageVarParser="Not a symbol or dec/Hex number";+ break; + }+ } + if (*bufptr =='%' && *(bufptr+2) >='0' && *(bufptr+2)<='9') //now a variable?+ { + //printf("It's a variable!\n");+ switch (*(bufptr+1)) // is it the right variable?+ {+ case 'W':case 'T':case 'M':case 'C':case 'X':+ if (TextParserForAVar(bufptr,&VarType,&VarOffset,&StringLength,FALSE/*PartialNames allowed*/))+ {+ strcpy(Buffer,""); sprintf(Buffer,"@%d/%d@",VarType,VarOffset); strcat(NewExpr,Buffer);- ptr+=StringLength;+ strcpy(Buffer,"");+ HaveAUnit=FALSE;+ //printf("new expresion=%s\nbuffer=%s\n",NewExpr,Buffer); if ( VarType<VAR_ARE_WORD ) {+ //printf("variable atribute error 1"); ItIsOk = FALSE; ErrorMessageVarParser = "Incompatible type of variable (must be an integer!)"; } } else- {+ { + //printf("variable atribute error 2"); ItIsOk = FALSE; }+ break;- // booleans variables not allowed for arithmetic expressions...- case 'B':- case 'I':- case 'Q':- ItIsOk = FALSE;- ErrorMessageVarParser = "Incompatible type of variable";- break;- case '\0':- ItIsOk = FALSE;- ErrorMessageVarParser = "Null expression not valid";- break;+ default:- sprintf(Buffer,"%c",*ptr);- strcat(NewExpr, Buffer);- ptr++;- break;+ ItIsOk=FALSE;+ ErrorMessageVarParser = "can only use W,T,M,C,X variable letters";+ break;+ } }- } else- {- sprintf(Buffer,"%c",*ptr);- strcat(NewExpr, Buffer);- ptr++;- }- }- while( (*ptr) && ItIsOk );- /* Verify length of the expression */- if (ItIsOk)- {- if (strlen(NewExpr)>=ARITHM_EXPR_SIZE)- {- ItIsOk = FALSE;- ErrorMessageVarParser = "Expression too long";+ {if (*tmpptr=='%')+ { ItIsOk=FALSE;+ ErrorMessageVarParser = "Syntaxt error in variable";+ }+ else + {+ if (ItIsOk== TRUE)+ { + //printf("Adding %s to NewExpr_%s\n",Buffer,NewExpr);+ strcat(NewExpr,Buffer);+ strcpy(Buffer,""); + HaveAUnit=FALSE;+ }+ }+ } } }+ while (ItIsOk != FALSE && *tmpptr!='\0');// not at end and no error? + + + //printf("Parser Arithm ; ItIsOk=%d ; OriExpr=%s ; NewExpr=%s\n",ItIsOk, text, NewExpr);+ /* Verify expression converted */ if (ItIsOk) {@@ -547,8 +642,11 @@ } /* Give result */ if (ItIsOk)+ { + //printf("returned %s\n",NewExpr); //for debugging return NewExpr;- else+ }+ else return NULL; } Index: hal/classicladder/edit_gtk.c===================================================================RCS file: /cvs/emc2/src/hal/classicladder/edit_gtk.c,vretrieving revision 1.4diff -u -r1.4 edit_gtk.c--- hal/classicladder/edit_gtk.c 16 Nov 2006 01:45:33 -0000 1.4+++ hal/classicladder/edit_gtk.c 24 May 2007 04:58:46 -0000@@ -271,12 +271,67 @@ switch( ToolBarEle.Type ) { case EDIT_POINTER:- gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Selector", NULL);+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Current Object\n Selector", NULL); break; case EDIT_ERASER: gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Eraser", NULL); break;- }+ case ELE_RISING_INPUT:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Rising Edge\n Input", NULL);+ break;+ case ELE_FALLING_INPUT:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Falling Edge\n Input", NULL);+ break;+ case ELE_INPUT:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "N.O. Input", NULL);+ break;+ case ELE_INPUT_NOT:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "N.C. Input ", NULL);+ break;+ case ELE_CONNECTION:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Horizontal\nConection", NULL);+ break;+ case EDIT_CNX_WITH_TOP:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], " Vertical\nConection", NULL);+ break;+ case EDIT_LONG_CONNECTION:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], " Running\nConnection", NULL);+ break;+ case ELE_TIMER:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Timer", NULL);+ break;+ case ELE_MONOSTABLE:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Monostable", NULL);+ break;+ case ELE_COUNTER:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Counter", NULL);+ break;+ case ELE_COMPAR:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Compare\n Variable", NULL);+ break;+ case ELE_OUTPUT:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "N.O. Output", NULL);+ break;+ case ELE_OUTPUT_NOT:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "N.C. Output", NULL);+ break;+ case ELE_OUTPUT_SET:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Set Output ", NULL);+ break;+ case ELE_OUTPUT_RESET:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Reset Output", NULL);+ break;+ case ELE_OUTPUT_JUMP:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Jump Coil", NULL);+ break;+ case ELE_OUTPUT_CALL:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], "Call Coil", NULL);+ break;+ case ELE_OUTPUT_OPERATE:+ gtk_tooltips_set_tip (TheTooltips, ToolbarBtnRadio[ CurrentAvail ], " Variable\nAssignment", NULL);+ break;+ + } gtk_widget_show( ToolbarBtnRadio[ CurrentAvail ] ); CurrentAvail++;@@ -354,4 +409,3 @@ EditDatas.NumElementSelectedInToolBar = -1; }-Index: hal/classicladder/files.c===================================================================RCS file: /cvs/emc2/src/hal/classicladder/files.c,vretrieving revision 1.6diff -u -r1.6 files.c--- hal/classicladder/files.c 16 Nov 2006 01:45:33 -0000 1.6+++ hal/classicladder/files.c 24 May 2007 04:58:46 -0000@@ -51,7 +51,11 @@ #else static inline int dbg_printf(char *f, ...) {return 0;} #endif-+// for auto assignment of symbols+ enum pinnames+ {BITIN=0,BITOUT,S32IN,S32OUT};+ char pinletter[4]={'I','Q','W','W'};+// StrDatasForBase CorresDatasForBase[3] = { {BASE_MINS , TIME_BASE_MINS , "%.1fmn" , "Mins" } , {BASE_SECS , TIME_BASE_SECS , "%.1fs" , "Secs" } , {BASE_100MS , TIME_BASE_100MS , "%.0f00ms" , "100msecs" } };@@ -949,7 +953,93 @@ fclose(File); Okay = TRUE; }- return (Okay);+// call funtion to auto assign symbol names to HAL pins +// must assign S32IN before S32OUT! + + SymbolsAutoAssign(BITIN,"HALinB\0","Auto named bit-in pin \0");+ SymbolsAutoAssign(BITOUT,"HALoutB\0","Auto named bit-out pin \0");+ SymbolsAutoAssign(S32IN,"HALinS\0","Auto named s32-in pin \0");+ SymbolsAutoAssign(S32OUT,"HALoutS\0","Auto named s32-out pin \0");+ +return (Okay);+}++//auto assignment of names for symbols of s32in,s32out, bitin +//and bitout if not already assigned a name+// you must assign s32in before s32out unless there are no s32in+void SymbolsAutoAssign (int VariableBuf,char SymbolBuf[],char CommentBuf[])+{+ int scansymb,found = FALSE,i,numofvariable =1;+ char Buffer[30];+ int startnum=0;// default number of s32in pins+ + // this checks which type of pin we are naming. S32out is different+ // because it starts naming variables after the last S32in so it needs+ // to how many positions to offset- startnum+ // S32 in and out are mapped on top of WORD variables instead of adding a new variable + switch(VariableBuf)+ {+ case BITIN:numofvariable= InfosGene->SizesInfos.nbr_phys_inputs;break;+ case BITOUT:numofvariable= InfosGene->SizesInfos.nbr_phys_outputs;break;+ case S32IN:numofvariable= InfosGene->SizesInfos.nbr_s32in;break;+ case S32OUT:numofvariable= InfosGene->SizesInfos.nbr_s32out +InfosGene->SizesInfos.nbr_s32in;+ startnum=InfosGene->SizesInfos.nbr_s32in;break;+ + default : printf("Cannot auto assign symbol names-wrong variable name");return;+ }+//printf("variable to assin %i number of variables available %i\n",numofvariable-startnum,InfosGene->SizesInfos.nbr_symbols);+ // assign variable to each s32in pin...+ for (i=startnum;i<numofvariable;i++)+ +{+ found = FALSE;+ //set buffer to variable to check %W0,%W1 ...+ strcpy(Buffer,"");+ sprintf(Buffer,"%%%c%d",pinletter[VariableBuf],i); ++ // printf("%s\n",Buffer);+ scansymb=0; + // scan all symbol variables+ while ( scansymb<InfosGene->SizesInfos.nbr_symbols ) + { + // check for exsisting variable/symbol name+ if (strcmp(SymbolArray[ scansymb ].VarName, Buffer) == FALSE)+ {+ found = TRUE ; // already a symbol for this variable+ break;// stop looking then+ }+ scansymb ++;// check the rest+ }+ + scansymb=0;+// this assigns a symbol to an unassigned variable+// while there is no symbol already assigned and we are not at the+// end of the symbol data..+ while ( found == FALSE && scansymb<InfosGene->SizesInfos.nbr_symbols )+ {+ // look for an empty spot...+ if (SymbolArray[ scansymb ].VarName[ 0 ] == '\0')+ { + //copy variable name already in Buffer to VarName array+ strcpy( SymbolArray[scansymb].VarName, Buffer ); + + //put a symbol name (and it's number) in buffer+ // and copy it to Symbol array+ strcpy(Buffer,"");+ sprintf(Buffer,"%s%d",SymbolBuf,i-startnum);+ strcpy( SymbolArray[scansymb].Symbol, Buffer );+ + strcpy(Buffer,"");+ sprintf(Buffer,"%s",CommentBuf);+ strcpy( SymbolArray[scansymb].Comment, Buffer );+ + break;// we are done looking+ }+ + scansymb ++;// keep looking for empty spot if not done+ } +}+return; } char SaveSymbols(char * FileName)@@ -987,27 +1077,27 @@ printf("Loading datas from %s...\n", DatasDirectory); sprintf(FileName,"%s/timers.csv",DatasDirectory);-// printf("Loading timers datas from %s\n",FileName);+ //printf("Loading timers datas from %s\n",FileName); LoadTimersParams(FileName,TimerArray); sprintf(FileName,"%s/monostables.csv",DatasDirectory);-// printf("Loading monostables datas from %s\n",FileName);+ //printf("Loading monostables datas from %s\n",FileName); LoadMonostablesParams(FileName,MonostableArray); sprintf(FileName,"%s/counters.csv",DatasDirectory);-// printf("Loading counters datas from %s\n",FileName);+ //printf("Loading counters datas from %s\n",FileName); LoadCountersParams(FileName); PrepareTimers(); PrepareMonostables(); PrepareCounters(); sprintf(FileName,"%s/arithmetic_expressions.csv",DatasDirectory);-// printf("Loading arithmetic expressions from %s\n",FileName);+ //printf("Loading arithmetic expressions from %s\n",FileName); LoadArithmeticExpr(FileName); // Sections added since v0.5.5, the format of files has a little changed : // before the prev/next rungs were not saved in each rung... // and the nmber of rungs changed when saved... sprintf(FileName,"%s/sections.csv",DatasDirectory);-// printf("Loading sections datas from %s\n",FileName);+ // printf("Loading sections datas from %s\n",FileName); if ( LoadSectionsParams(FileName) ) { sprintf(FileName,"%s/rung_",DatasDirectory);@@ -1024,18 +1114,19 @@ } #ifdef SEQUENTIAL_SUPPORT sprintf(FileName,"%s/sequential.csv",DatasDirectory);-// printf("Loading sequential datas from %s\n",FileName);+ //printf("Loading sequential datas from %s\n",FileName); LoadSequential( FileName ); #endif sprintf(FileName,"%s/ioconf.csv",DatasDirectory);-// printf("Loading I/O configuration datas from %s\n",FileName);+ //printf("Loading I/O configuration datas from %s\n",FileName); LoadIOConfParams( FileName ); #ifdef USE_MODBUS sprintf(FileName,"%s/modbusioconf.csv",DatasDirectory);-// printf("Loading modbus distributed I/O configuration datas from %s\n",FileName);+ //printf("Loading modbus distributed I/O configuration datas from %s\n",FileName); LoadModbusIOConfParams( FileName ); #endif sprintf(FileName,"%s/symbols.csv",DatasDirectory);+ //printf("Loading symbols from %s\n",FileName); LoadSymbols(FileName); PrepareRungs();@@ -1048,6 +1139,7 @@ ManagerDisplaySections( ); DisplaySymbols( ); #endif+return; } void SaveAllLadderDatas(char * DatasDirectory)Index: hal/classicladder/files.h===================================================================RCS file: /cvs/emc2/src/hal/classicladder/files.h,vretrieving revision 1.4diff -u -r1.4 files.h--- hal/classicladder/files.h 16 Nov 2006 01:45:33 -0000 1.4+++ hal/classicladder/files.h 24 May 2007 04:58:46 -0000@@ -20,6 +20,7 @@ char LoadModbusIOConfParams(char * FileName); char SaveModbusIOConfParams(char * FileName); char LoadSymbols(char * FileName);+void SymbolsAutoAssign(int VariableBuf,char SymbolBuf[],char CommentBuf[]); char SaveSymbols(char * FileName); void LoadAllLadderDatas(char * DatasDirectory);Index: hal/classicladder/module_hal.c===================================================================RCS file: /cvs/emc2/src/hal/classicladder/module_hal.c,vretrieving revision 1.1diff -u -r1.1 module_hal.c--- hal/classicladder/module_hal.c 6 Nov 2006 23:41:35 -0000 1.1+++ hal/classicladder/module_hal.c 24 May 2007 04:58:46 -0000@@ -41,23 +41,32 @@ int comedi_to_open_mask; #ifdef DYNAMIC_PLCSIZE int numRungs=NBR_RUNGS_DEF, numBits=NBR_BITS_DEF,numWords=NBR_WORDS_DEF, numTimers=NBR_TIMERS_DEF, numMonostables=NBR_MONOSTABLES_DEF;-int numPhysInputs=NBR_PHYS_INPUTS_DEF, numPhysOutputs=NBR_PHYS_OUTPUTS_DEF, numArithmExpr=NBR_ARITHM_EXPR_DEF, numSections=NBR_SECTIONS_DEF;+int numCounters=NBR_COUNTERS_DEF,numPhysInputs=NBR_PHYS_INPUTS_DEF, numPhysOutputs=NBR_PHYS_OUTPUTS_DEF, numArithmExpr=NBR_ARITHM_EXPR_DEF, numSections=NBR_SECTIONS_DEF;+int numSymbols=NBR_SYMBOLS_DEF,numRefresh=NBR_REFRESH_DEF,numS32in=NBR_S32IN_DEF,numS32out=NBR_S32OUT_DEF; RTAPI_MP_INT(numRungs, "i"); RTAPI_MP_INT(numBits, "i"); RTAPI_MP_INT(numWords, "i"); RTAPI_MP_INT(numTimers, "i"); RTAPI_MP_INT(numMonostables, "i");+RTAPI_MP_INT(numCounters, "i"); RTAPI_MP_INT(numPhysInputs, "i"); RTAPI_MP_INT(numPhysOutputs, "i"); RTAPI_MP_INT(numArithmExpr, "i"); RTAPI_MP_INT(numSections, "i");+RTAPI_MP_INT(numSymbols, "i");+RTAPI_MP_INT(numRefresh, "i");+RTAPI_MP_INT(numS32in, "i");+RTAPI_MP_INT(numS32out, "i"); #else #define numPhysInputs InfosGene->SizesInfos.nbr_phys_inputs #define numPhysOutputs InfosGene->SizesInfos.nbr_phys_outputs+#define numWords InfosGene->SizesInfos.nbr_words #endif hal_bit_t **hal_inputs; hal_bit_t **hal_outputs;+hal_s32_t **hal_s32_inputs;+hal_s32_t **hal_s32_outputs; extern plc_sizeinfo_s sinfo; @@ -70,30 +79,49 @@ } } +void HalReads32Inputs(void) {+ int i;+ for( i=0; i<InfosGene->SizesInfos.nbr_s32in; i++) {+ WriteVar(VAR_MEM_WORD, i, *hal_s32_inputs[i]);+ }+}+ void HalWritePhysicalOutputs(void) { int i; for( i=0; i<InfosGene->SizesInfos.nbr_phys_outputs; i++) { *(hal_outputs[i]) = ReadVar(VAR_PHYS_OUTPUT, i); }+} +void HalWrites32Outputs(void) {+ int i;+ for( i=0; i<InfosGene->SizesInfos.nbr_s32out; i++) {+ *(hal_s32_outputs[i]) = ReadVar(VAR_MEM_WORD, i+InfosGene->SizesInfos.nbr_s32in);+ } } static void hal_task(void *arg, long period) {- /* XXX: TIME_REFRESH_RUNG_MS is a compile-time constant. suck it. */- static long left = TIME_REFRESH_RUNG_NS;+ //* SizesInfos.nbr_refresh holds rung refresh time+ // and is is configurable when loading RT module+ + int adjust =InfosGene->SizesInfos.nbr_refresh *1000000;+ static long left = 75; left = left - period; if(left < 0) { unsigned long t0 = rtapi_get_time(), t1;- left += TIME_REFRESH_RUNG_NS;-+ left += adjust ;+ //left += TIME_REFRESH_RUNG_NS if (InfosGene->LadderState==STATE_RUN) { HalReadPhysicalInputs(); + HalReads32Inputs();+ RefreshAllRungs(); HalWritePhysicalOutputs(); + HalWrites32Outputs(); } t1 = rtapi_get_time(); InfosGene->DurationOfLastScan = t1 - t0;@@ -117,8 +145,12 @@ hal_inputs = hal_malloc(sizeof(hal_bit_t*) * numPhysInputs); if(!hal_inputs) { result = -ENOMEM; goto error; }+ hal_s32_inputs = hal_malloc(sizeof(hal_s32_t*) * numS32in);+ if(!hal_s32_inputs) { result = -ENOMEM; goto error; } hal_outputs = hal_malloc(sizeof(hal_bit_t*) * numPhysOutputs); if(!hal_outputs) { result = -ENOMEM; goto error; }+ hal_s32_outputs = hal_malloc(sizeof(hal_bit_t*) * numS32out);+ if(!hal_s32_outputs) { result = -ENOMEM; goto error; } for(i=0; i<numPhysInputs; i++) { result = hal_pin_bit_newf(HAL_IN, &hal_inputs[i], compId,@@ -126,11 +158,22 @@ if(result < 0) goto error; } + for(i=0; i<numS32in; i++) {+ result = hal_pin_s32_newf(HAL_IN, &hal_s32_inputs[i], compId,+ "classicladder.0.s32in-%02d", i);+ if(result < 0) goto error;+ }+ for(i=0; i<numPhysOutputs; i++) { result = hal_pin_bit_newf(HAL_OUT, &hal_outputs[i], compId, "classicladder.0.out-%02d", i); if(result < 0) goto error; }+ for(i=0; i<numS32out; i++) {+ result = hal_pin_s32_newf(HAL_OUT, &hal_s32_outputs[i], compId,+ "classicladder.0.s32out-%02d", i);+ if(result < 0) goto error;+ } hal_ready(compId); ClassicLadderAllocAll( );@@ -154,6 +197,8 @@ sinfo.nbr_timers = numTimers; if ( numMonostables>0 ) sinfo.nbr_monostables = numMonostables;+ if ( numCounters>0 )+ sinfo.nbr_counters = numCounters; if ( numPhysInputs>0 ) sinfo.nbr_phys_inputs = numPhysInputs; if ( numPhysOutputs>0 )@@ -162,5 +207,13 @@ sinfo.nbr_arithm_expr = numArithmExpr; if ( numSections>0 ) sinfo.nbr_sections = numSections;-#endif+ if ( numSymbols>0 )+ sinfo.nbr_symbols = numSymbols;+ if ( numRefresh>0 )+ sinfo.nbr_refresh = numRefresh;+ if ( numS32in>0 )+ sinfo.nbr_s32in = numS32in;+ if ( numS32out>0 )+ sinfo.nbr_s32out = numS32out;+ #endif }Index: hal/classicladder/module_rt.c===================================================================RCS file: /cvs/emc2/src/hal/classicladder/Attic/module_rt.c,vretrieving revision 1.12diff -u -r1.12 module_rt.c--- hal/classicladder/module_rt.c 18 Nov 2006 03:04:57 -0000 1.12+++ hal/classicladder/module_rt.c 24 May 2007 04:58:46 -0000@@ -15,7 +15,8 @@ * * insmod classicladder_rt <numRungs=10> <numBits=500> <numWords=50> * <numTimers=8> <numMonostables=8> <numPhysInputs=10>- * <numPhysOutputs=50> <numArithmExpr=100> <numSections=10>+ * <numPhysOutputs=50> <numArithmExpr=100> <numSections=10> <numRefresh> <numS32in> + * <numS32out> * * * The following items are exported to the HAL. <channel> is@@ -27,7 +28,8 @@ * u8 classicladder.<plcId>.status // 0=load, 1=stop, 2=run * bit classicladder.<plcId>.in-<channel> * bit classicladder.<plcId>.out-<channel>- *+ * S32 classicladder.<plcId>.s32oin-<channel>+ * S32 classicladder.<plcId>.s32out-<channel> * Functions: * void classicladder.<plcId>.refresh *@@ -92,7 +94,9 @@ RTAPI_MP_INT(numTimers, "Number of timers to allocate"); static int numMonostables = 8; RTAPI_MP_INT(numMonostables, "Number of monostables to allocate");-static int numPhysInputs = 10;+static int numCounters = 10;+RTAPI_MP_INT(numCounters, "Number of timers to allocate");+static int numPhysInputs = 50; RTAPI_MP_INT(numPhysInputs, "Number of inputs to allocate"); static int numPhysOutputs = 50; RTAPI_MP_INT(numPhysOutputs, "Number of outputs to allocate");@@ -100,6 +104,14 @@ RTAPI_MP_INT(numArithmExpr, "Number of arithmetic expressions to allocate"); static int numSections = 10; RTAPI_MP_INT(numSections, "Number of sections to allocate");+static int numSymbols = 100;+RTAPI_MP_INT(numSymbols, "Number of symbols to allocate")+static int numRefresh = 50;+RTAPI_MP_INT(numRefresh, "Refresh Rate to start")+static int numS32in = 10;+RTAPI_MP_INT(numS32in, "Number of s32in to allocate")+static int numS32out= 10;+RTAPI_MP_INT(numS32out, "Number of s32out to allocate") /******************************************************************************@@ -285,11 +297,16 @@ sizeInfo.nbr_words = numWords; sizeInfo.nbr_timers = numTimers; sizeInfo.nbr_monostables = numMonostables;- sizeInfo.nbr_phys_inputs = numPhysInputs;+ sizeInfo.nbr_counters = numCounters;+ sizeInfo.nbr_phys_inputs = numPhysInputs; sizeInfo.nbr_phys_outputs = numPhysOutputs; sizeInfo.nbr_arithm_expr = numArithmExpr; sizeInfo.nbr_sections = numSections;-+ sizeInfo.nbr_symbols = numSymbols;+ sizeInfo.nbr_refresh = numRefresh;+ sizeInfo.nbr_s32in = numS32in;+ sizeInfo.nbr_s32out = numS32out;+ if(!ClassicLadderAllocAll(componentId, &sizeInfo)){ rtapi_print_msg(RTAPI_MSG_ERR, "CLRT: ERROR: ClassicLadderAllocAll() failed\n"); return(-1);Index: hal/classicladder/symbols_gtk.c===================================================================RCS file: /cvs/emc2/src/hal/classicladder/symbols_gtk.c,vretrieving revision 1.1diff -u -r1.1 symbols_gtk.c--- hal/classicladder/symbols_gtk.c 6 Nov 2006 23:41:35 -0000 1.1+++ hal/classicladder/symbols_gtk.c 24 May 2007 04:58:46 -0000@@ -29,6 +29,7 @@ #include "classicladder_gtk.h" #include "symbols_gtk.h" +static int SymbolWindowToggle; // toggle variable GtkWidget *SymbolsWindow; GtkListStore *ListStore; @@ -68,7 +69,8 @@ /* The callback for the editing of text in our GtkTreeView */ /* data=column number */ void Callback_TextEdited(GtkCellRendererText *cell, gchar *path_string,- gchar *new_text, gpointer data) {+ gchar *new_text, gpointer data)+{ int OffsetArray = -999; StrSymbol * pSymbol = NULL;@@ -128,18 +130,26 @@ gint SymbolsWindowDeleteEvent( GtkWidget * widget, GdkEvent * event, gpointer data ) {- gtk_widget_hide( SymbolsWindow );+ SymbolWindowToggle=(SymbolWindowToggle-1)*-1; //toggle variable+ gtk_widget_hide( SymbolsWindow );// hide window // we do not want that the window be destroyed. return TRUE; } void OpenSymbolsWindow( void ) {- gtk_widget_show (SymbolsWindow);-#ifdef GTK2- gtk_window_present( GTK_WINDOW(SymbolsWindow) );-#endif-}+ + if (!SymbolWindowToggle)+ { gtk_widget_show (SymbolsWindow); //show window+ gtk_window_present( GTK_WINDOW(SymbolsWindow) );+ + }+ else {gtk_widget_hide (SymbolsWindow); //hide window+ gtk_widget_hide (SymbolsWindow);+ }+ SymbolWindowToggle=(SymbolWindowToggle-1)*-1; //toggle+} + void SymbolsInitGtk() {@@ -164,7 +174,7 @@ for (ScanCol=1; ScanCol<NBR_INFOS; ScanCol++) { GtkTreeViewColumn *column;- renderer = gtk_cell_renderer_text_new();+ renderer = gtk_cell_renderer_text_new(); g_object_set(renderer, "editable", TRUE, NULL); //TODO? gtk_entry_set_max_length(GTK_ENTRY( ),9); g_signal_connect( G_OBJECT(renderer), "edited", G_CALLBACK(Callback_TextEdited), (gpointer)ScanCol );@@ -191,6 +201,5 @@ gtk_container_add( GTK_CONTAINER(SymbolsWindow), vbox ); gtk_widget_show( vbox ); -//gtk_widget_show (SymbolsWindow);+//gtk_widget_show (SymbolsWindow); //hide till toggled }-Index: hal/classicladder/projects_examples/example.clp===================================================================RCS file: /cvs/emc2/src/hal/classicladder/projects_examples/example.clp,vretrieving revision 1.2diff -u -r1.2 example.clp--- hal/classicladder/projects_examples/example.clp 16 Nov 2006 01:45:42 -0000 1.2+++ hal/classicladder/projects_examples/example.clp 24 May 2007 04:58:46 -0000@@ -286,9 +286,6 @@ _FILE-ioconf.csv ; I/O Configuration _/FILE-ioconf.csv-_FILE-modbusioconf.csv-; Modbus Distributed I/O Configuration-_/FILE-modbusioconf.csv _FILE-symbols.csv ; Symbols #VER=1.0