Firenet

Check-in [0221a14fa9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the following [a9cd2ca436] [4e9e3226c9] and [34289a710d]
Timelines: family | ancestors | descendants | both | NEWNET
Files: files | file ages | folders
SHA1:0221a14fa9aafea331f4d9e4eb7a9f7f6f52ba38
User & Date: jim 2013-02-10 01:33:40
References
2013-02-10
01:38 Tested ticket [4e9e3226c9]: Work on code to build shows plus 4 other changes artifact: e770922c4c user: jim
01:37 Ticket [a9cd2ca436] AUTO Hangs in "Progamming Nodes" status still Tested with 1 other change artifact: b261cd6b34 user: jim
01:36 Ticket [34289a710d] Correct programming programs status still Open with 2 other changes artifact: a8a3cd4307 user: jim
01:35 Tested ticket [a9cd2ca436]: AUTO Hangs in "Progamming Nodes" plus 4 other changes artifact: 3c34db377d user: jim
Context
2013-02-10
12:52
Update web pages check-in: 56f976a89a user: jim tags: NEWNET
01:33
Fix the following [a9cd2ca436] [4e9e3226c9] and [34289a710d] check-in: 0221a14fa9 user: jim tags: NEWNET
2012-11-01
17:10
[83c43c7cd5] more efficient firing check-in: 368a67306b user: jim tags: NEWNET
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Firenet.xcodeproj/project.pbxproj.

661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
...
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
...
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
		};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
		08FB7793FE84155DC02AAC07 /* Project object */ = {
			isa = PBXProject;
			attributes = {
				LastUpgradeCheck = 0430;
			};
			buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "Firenet" */;
			compatibilityVersion = "Xcode 3.2";
			developmentRegion = English;
			hasScannedForEncodings = 1;
			knownRegions = (
				en,
................................................................................
				ALWAYS_SEARCH_USER_PATHS = NO;
				COPY_PHASE_STRIP = NO;
				GCC_DYNAMIC_NO_PIC = NO;
				GCC_MODEL_TUNING = G5;
				GCC_OPTIMIZATION_LEVEL = 0;
				INSTALL_PATH = /usr/local/bin;
				PRODUCT_NAME = Firenet;
				SDKROOT = macosx10.7;
			};
			name = Debug;
		};
		1DEB928708733DD80010E9CD /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
				GCC_MODEL_TUNING = G5;
				INSTALL_PATH = /usr/local/bin;
				PRODUCT_NAME = Firenet;
				SDKROOT = macosx10.7;
			};
			name = Release;
		};
		1DEB928A08733DD80010E9CD /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
................................................................................
				GCC_OPTIMIZATION_LEVEL = 0;
				GCC_VERSION = com.apple.compilers.llvmgcc42;
				GCC_WARN_ABOUT_RETURN_TYPE = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				ONLY_ACTIVE_ARCH = YES;
				OTHER_CFLAGS = "-DBSD_VERSION";
				"OTHER_CPLUSPLUSFLAGS[sdk=macosx10.7][arch=*]" = "$(OTHER_CFLAGS)";
				SDKROOT = macosx10.7;
			};
			name = Debug;
		};
		1DEB928B08733DD80010E9CD /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
				GCC_C_LANGUAGE_STANDARD = c99;
				GCC_WARN_ABOUT_RETURN_TYPE = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				ONLY_ACTIVE_ARCH = YES;
				OTHER_CFLAGS = "-DBSD_VERSION";
				SDKROOT = macosx10.7;
			};
			name = Release;
		};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
		1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "Firenet" */ = {







|







 







|











|







 







|












|







661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
...
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
...
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
		};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
		08FB7793FE84155DC02AAC07 /* Project object */ = {
			isa = PBXProject;
			attributes = {
				LastUpgradeCheck = 0460;
			};
			buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "Firenet" */;
			compatibilityVersion = "Xcode 3.2";
			developmentRegion = English;
			hasScannedForEncodings = 1;
			knownRegions = (
				en,
................................................................................
				ALWAYS_SEARCH_USER_PATHS = NO;
				COPY_PHASE_STRIP = NO;
				GCC_DYNAMIC_NO_PIC = NO;
				GCC_MODEL_TUNING = G5;
				GCC_OPTIMIZATION_LEVEL = 0;
				INSTALL_PATH = /usr/local/bin;
				PRODUCT_NAME = Firenet;
				SDKROOT = "";
			};
			name = Debug;
		};
		1DEB928708733DD80010E9CD /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
				GCC_MODEL_TUNING = G5;
				INSTALL_PATH = /usr/local/bin;
				PRODUCT_NAME = Firenet;
				SDKROOT = "";
			};
			name = Release;
		};
		1DEB928A08733DD80010E9CD /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
................................................................................
				GCC_OPTIMIZATION_LEVEL = 0;
				GCC_VERSION = com.apple.compilers.llvmgcc42;
				GCC_WARN_ABOUT_RETURN_TYPE = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				ONLY_ACTIVE_ARCH = YES;
				OTHER_CFLAGS = "-DBSD_VERSION";
				"OTHER_CPLUSPLUSFLAGS[sdk=macosx10.7][arch=*]" = "$(OTHER_CFLAGS)";
				SDKROOT = macosx;
			};
			name = Debug;
		};
		1DEB928B08733DD80010E9CD /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
				GCC_C_LANGUAGE_STANDARD = c99;
				GCC_WARN_ABOUT_RETURN_TYPE = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				ONLY_ACTIVE_ARCH = YES;
				OTHER_CFLAGS = "-DBSD_VERSION";
				SDKROOT = macosx;
			};
			name = Release;
		};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
		1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "Firenet" */ = {

Changes to Hardware/.DS_Store.

cannot compute difference between binary files

Changes to Hardware/Board/Firenet/eagle.epf.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
61
62
63
64
65
66
67

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
109
110
111
112
113
114
115
116
117
118
119
[Eagle]
Version="06 02 00"
Platform="Mac OS X"
Serial="62191E841E-LSR-WLM-1EL"
Globals="Globals"
Desktop="Desktop"

[Globals]
AutoSaveProject=1
UsedLibrary="/LApps/lbr/con-subd.lbr"
UsedLibrary="/LApps/Eagle/lbr/atmel.lbr"
UsedLibrary="/LApps/Eagle/lbr/battery.lbr"
UsedLibrary="/LApps/Eagle/lbr/capacitor-wima.lbr"
UsedLibrary="/LApps/Eagle/lbr/crystal.lbr"
UsedLibrary="/LApps/Eagle/lbr/diode.lbr"
UsedLibrary="/LApps/Eagle/lbr/frames.lbr"
UsedLibrary="/LApps/Eagle/lbr/fuse.lbr"
UsedLibrary="/LApps/Eagle/lbr/holes.lbr"
UsedLibrary="/LApps/Eagle/lbr/ir.lbr"
UsedLibrary="/LApps/Eagle/lbr/rectifier.lbr"
UsedLibrary="/LApps/Eagle/lbr/ref-packages.lbr"
UsedLibrary="/LApps/Eagle/lbr/relay.lbr"
UsedLibrary="/LApps/Eagle/lbr/resistor-power.lbr"
UsedLibrary="/LApps/Eagle/lbr/supply1.lbr"
UsedLibrary="/LApps/Eagle/lbr/v-reg.lbr"
UsedLibrary="/Users/jschimpf/Public/USBSW/Hardware/firenet.lbr"
UsedLibrary="/LApps/Eagle/lbr/ic-package.lbr"
UsedLibrary="/LApps/Eagle/lbr/led.lbr"

[Win_1]
Type="Schematic Editor"
Loc="320 218 919 617"
State=0
Number=2
File="Firenet.sch"
................................................................................
PinLength=2
PinVisible=3
SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=91

Sheet=1

[Win_2]
Type="Control Panel"
Loc="30 52 629 451"
State=2
Number=0

[Win_3]
Type="Board Editor"
Loc="262 60 982 577"
State=2
Number=1
File="Firenet.brd"
View="-3.78816 -1.3968 100.74 71.2368"
WireWidths=" 0 0.254 0.3048 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0.4064"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.5 0.6 0.7 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 2 2.2 2.8 3.2 0.8"
................................................................................
SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=16

[Desktop]
Screen="1280 1024"
Window="Win_1"
Window="Win_2"
Window="Win_3"

|








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

<
<







 







>










|







 







|



1
2
3
4
5
6
7
8
9
10















11


12
13
14
15
16
17
18
..
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
..
93
94
95
96
97
98
99
100
101
102
103
[Eagle]
Version="06 03 00"
Platform="Mac OS X"
Serial="62191E841E-LSR-WLM-1EL"
Globals="Globals"
Desktop="Desktop"

[Globals]
AutoSaveProject=1
UsedLibrary="/LApps/lbr/con-subd.lbr"















UsedLibrary="/Users/jschimpf/Public/USBSW/Hardware/firenet.lbr"



[Win_1]
Type="Schematic Editor"
Loc="320 218 919 617"
State=0
Number=2
File="Firenet.sch"
................................................................................
PinLength=2
PinVisible=3
SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=91
Views=" 1: -21.3522 -17.5422 270.064 207.834"
Sheet=1

[Win_2]
Type="Control Panel"
Loc="30 52 629 451"
State=2
Number=0

[Win_3]
Type="Board Editor"
Loc="400 338 999 737"
State=2
Number=1
File="Firenet.brd"
View="-3.78816 -1.3968 100.74 71.2368"
WireWidths=" 0 0.254 0.3048 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0.4064"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.5 0.6 0.7 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 2 2.2 2.8 3.2 0.8"
................................................................................
SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=16

[Desktop]
Screen="1600 1200"
Window="Win_1"
Window="Win_2"
Window="Win_3"

Changes to Logging/firenetlog.c.

9
10
11
12
13
14
15

16
17
18
19
20
21
22
..
40
41
42
43
44
45
46

47
48
49
50
51
52
53
..
57
58
59
60
61
62
63






64
65
66
67
68
69
70
*  Description:         This code will run a logging system for the app
*
*  Revision History:	22-May-2010 Initial version [d98ef0303d]
*/
//************************************************************************

#include "firenetlog.h"


#if 0
	#pragma mark -
	#pragma mark -- DATA --
#endif

static int log_on		= 0;		// Logging control, default = OFF
................................................................................
//***********************************************************************/

void log_control( int flag, const char *where )
{
	// (1) Is logging turn ON or OFF
	
	log_on = flag;

	
	// (2) If OFF we can skip the rest of this
	
	if( log_on )
	{
		// (3) Is there a new logging file ?
		
................................................................................
			
			if( log_file != NULL )
				fclose( log_file );
				
			// (3b) Open a new one
			
			log_file = fopen( where,"w");






		}
	}
}

//***********************************************************************
/*
*	void log_data( const char *format, va_list data )







>







 







>







 







>
>
>
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
*  Description:         This code will run a logging system for the app
*
*  Revision History:	22-May-2010 Initial version [d98ef0303d]
*/
//************************************************************************

#include "firenetlog.h"
#include "time.h"

#if 0
	#pragma mark -
	#pragma mark -- DATA --
#endif

static int log_on		= 0;		// Logging control, default = OFF
................................................................................
//***********************************************************************/

void log_control( int flag, const char *where )
{
	// (1) Is logging turn ON or OFF
	
	log_on = flag;
	time_t now;
	
	// (2) If OFF we can skip the rest of this
	
	if( log_on )
	{
		// (3) Is there a new logging file ?
		
................................................................................
			
			if( log_file != NULL )
				fclose( log_file );
				
			// (3b) Open a new one
			
			log_file = fopen( where,"w");
			if( log_file != NULL )
			{
				now = time(NULL);
				fprintf(log_file,"# --- START  %s",ctime(&now));
			}

		}
	}
}

//***********************************************************************
/*
*	void log_data( const char *format, va_list data )

Changes to Network/phy.c.

9
10
11
12
13
14
15

16
17
18
19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
146
147
148
149
150
151
152
153

154
155
156
157

158
159
160
161
162
163
164
...
216
217
218
219
220
221
222

223
224
225
226

227
228
229
230
231
232
233
*  Description:         This code will be used to simulate the
*						firing box CSMA RS-485 network used between
*						firing boxes
*
*  Revision History:	28-Jul-2009	Initial version supporting both
*									real and sim phy [fa981152d5] 
*						23-Jan-2011 [c6b3a88a66] Add PHY logging

*/
//************************************************************************

#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <stdio.h>
#include <ctype.h>
#include "sim_phy.h"
#include "real_phy.h"
#include "firenetlog.h"


#if 0
	#pragma mark -
	#pragma mark -- Data --
#endif

typedef enum {
................................................................................
*/
//************************************************************************

void  *init_phy( char *port )
{
	void *h = NULL;
	
	log_data("PHY OPEN\n");
	
	switch( phy_flag )
	{
		case REAL_PHY:	h = real_init_phy( port );
						break;
						
		case SIM_PHY:	h = sim_init_phy( port );
................................................................................
*
*/
//************************************************************************

int put_phy( unsigned char data,void *h )
{
	int rtnval = 0;
	

	if( isprint(data) )
		log_data("PHY OUT [%c]\n",data);
	else
		log_data("PHY OUT [0x%02X]\n",0xff & data);

	
	switch( phy_flag )
	{
		case REAL_PHY:	rtnval = real_put_phy( data,h );
						break;
						
		case SIM_PHY:	rtnval = sim_put_phy( data,h );
................................................................................
						
		case SIM_PHY:	rtnval = sim_get_phy( h );
						break;
	}
	
	if( rtnval != EOF )
	{

		if( isprint(rtnval) )
			log_data("PHY IN [%c]\n",rtnval);
		else
			log_data("PHY IN [0x%02X]\n",rtnval);

	}
	
	return( rtnval );
}

//*************************************************************************
/*







>











>







 







|







 







|
>




>







 







>




>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
*  Description:         This code will be used to simulate the
*						firing box CSMA RS-485 network used between
*						firing boxes
*
*  Revision History:	28-Jul-2009	Initial version supporting both
*									real and sim phy [fa981152d5] 
*						23-Jan-2011 [c6b3a88a66] Add PHY logging
*						 9-Feb-2013 Add control for PHY logging
*/
//************************************************************************

#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <stdio.h>
#include <ctype.h>
#include "sim_phy.h"
#include "real_phy.h"
#include "firenetlog.h"
#include "debug.h"

#if 0
	#pragma mark -
	#pragma mark -- Data --
#endif

typedef enum {
................................................................................
*/
//************************************************************************

void  *init_phy( char *port )
{
	void *h = NULL;
	
	log_data("PHY OPEN [%s]\n",port);
	
	switch( phy_flag )
	{
		case REAL_PHY:	h = real_init_phy( port );
						break;
						
		case SIM_PHY:	h = sim_init_phy( port );
................................................................................
*
*/
//************************************************************************

int put_phy( unsigned char data,void *h )
{
	int rtnval = 0;

#ifdef MON_PHY
	if( isprint(data) )
		log_data("PHY OUT [%c]\n",data);
	else
		log_data("PHY OUT [0x%02X]\n",0xff & data);
#endif
	
	switch( phy_flag )
	{
		case REAL_PHY:	rtnval = real_put_phy( data,h );
						break;
						
		case SIM_PHY:	rtnval = sim_put_phy( data,h );
................................................................................
						
		case SIM_PHY:	rtnval = sim_get_phy( h );
						break;
	}
	
	if( rtnval != EOF )
	{
#ifdef MON_PHY
		if( isprint(rtnval) )
			log_data("PHY IN [%c]\n",rtnval);
		else
			log_data("PHY IN [0x%02X]\n",rtnval);
#endif
	}
	
	return( rtnval );
}

//*************************************************************************
/*

Changes to Node/debug.h.

10
11
12
13
14
15
16

17
18
19
20
21
22
23
//*****************************************************************************

#ifndef DEBUG_H
#define DEBUG_H	1

	#define MON_PARENT_DATA	1		// Uncomment to display Parent network data
	#define MON_CHILD_DATA	1		// Uncomment to display Child network data

	//#define CMD_LINE_OPERATION	1		// Uncomment to run CMD Line version of system
	//#define DEBUG_RESPONSE_TIME		30000	// Wait 30 seconds for response
	//#define RS232_COM           1   // If present RS-232 connection to single node
                                    // used instead of FIRENET RS-485
                                    // DTR set OFF for all com

#endif







>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//*****************************************************************************

#ifndef DEBUG_H
#define DEBUG_H	1

	#define MON_PARENT_DATA	1		// Uncomment to display Parent network data
	#define MON_CHILD_DATA	1		// Uncomment to display Child network data
//	#define MON_PHP			1
	//#define CMD_LINE_OPERATION	1		// Uncomment to run CMD Line version of system
	//#define DEBUG_RESPONSE_TIME		30000	// Wait 30 seconds for response
	//#define RS232_COM           1   // If present RS-232 connection to single node
                                    // used instead of FIRENET RS-485
                                    // DTR set OFF for all com

#endif

Changes to Node/node/child_cmd.c.

21
22
23
24
25
26
27


28
29
30
31
32
33
34
...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
...
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
...
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
...
476
477
478
479
480
481
482

483
484
485
486
487
488
489
*						16-Jan-2011 Reformat STATUS response to match others
*						24-Jan-2011 [4fd91ac4c2] Add Channel information command [4fd91ac4c2]
*						28-Feb-2011 Add code in fire_circuit() to simulate firing delay
*						10-May-2011	[241aaaeb3d ] Update simulator to match hardware
*						16-Jul-2011 [9e81c1a523] Add adaptive firing action & read out of
*									adaptive results
*						14-Nov-2011 [683a021143] Add pgm event queue


*/
//************************************************************************

#include <stdio.h>
#include <string.h>
#include "network.h"
#include "child.h"
................................................................................
								
				case DLY_CMD:		// Delay command	
								rtnval = delay_handler(data,packet,h );
								send_ack(data,packet,h);
								break;
								
				case PGM_CMD:	rtnval = pgm_handler(data, packet, h);
								send_ack(data,packet,h);
								break;
														
				case SYNC_CMD:		// Sync command
								rtnval = sync_handler(data,packet,h );
								send_ack(data,packet,h);
								break;
								
				// Information commands
				case STATUS_CMD:		// Handle STATUS packet
								rtnval = status_handler(data,packet,h);
								break;
								
................................................................................
				case CHI_CMD:		// Channel information command
								rtnval = channel_handler(data,packet,h);
								break;
								
				// Setup commands
				case SET_AD_CMD:		// Handle WHO packet
								rtnval = who_handler( data,packet,h );
								send_ack(data,packet,h);
								break;
								
				case SET_FT_CMD:		// Handle Firing TIME packet
								rtnval = time_handler(data,packet,h);
								send_ack(data,packet,h);
								break;
								
				case SET_TM_CMD:		// Handle Test Mode command
								rtnval = test_mode_handler(data,packet,h);
								send_ack(data,packet,h);
								break;
								
				case SET_BKOFF_CMD:		// Set backoff value
								rtnval = backoff_handler(data,packet,h);
								send_ack(data,packet,h);
								break;
								
				case RESET_CMD:			// Handle RESET cmd
								rtnval = reset_handler(data,packet,h);
									// No response....
								break;
								
				case GET_DATA:			// Heandle read out command
								rtnval = getdata_handler(data,packet,h);
								send_ack(data,packet,h);
								break;

				default:		// Ignore and drop packet
								break;
			}
		
			// Get next chunk, and handle
................................................................................
*			Data[2]	-> end of packet = delay value as a number
*	Just sync the internal clock
*/
//************************************************************************

static int pgm_handler( CHILD_DATA *data,PACKET *packet,void *h )
{
	int rtnval = 0;
	int ch;
	long ft;
	PACKET pk;
	int bcast;
		
	// (1) Get channel values
	
................................................................................
	
	ft = strtoul((const char *)&(packet->data[packet->chunk_ptr+2]),NULL,10);
	
	// (3) Store in queue and return result
	
	if( store_in_queue( ch,ft,data ) == 0 )
	{

		data->control = packet->from;		// Save controller address
		pk.to = packet->from;
		pk.from = 0;
		
		pk.len = 2;
		pk.data[0] = RESP_CMD;
		pk.data[1] = PGM_CMD;







>
>







 







<




<







 







<




<




<




<









<







 







|







 







>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
185
186
187
188
189
190
191

192
193
194
195

196
197
198
199
200
201
202
...
208
209
210
211
212
213
214

215
216
217
218

219
220
221
222

223
224
225
226

227
228
229
230
231
232
233
234
235

236
237
238
239
240
241
242
...
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
...
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
*						16-Jan-2011 Reformat STATUS response to match others
*						24-Jan-2011 [4fd91ac4c2] Add Channel information command [4fd91ac4c2]
*						28-Feb-2011 Add code in fire_circuit() to simulate firing delay
*						10-May-2011	[241aaaeb3d ] Update simulator to match hardware
*						16-Jul-2011 [9e81c1a523] Add adaptive firing action & read out of
*									adaptive results
*						14-Nov-2011 [683a021143] Add pgm event queue
*						 9-Feb-2013 Fix commands that return packets to NOT
*									use send ACK
*/
//************************************************************************

#include <stdio.h>
#include <string.h>
#include "network.h"
#include "child.h"
................................................................................
								
				case DLY_CMD:		// Delay command	
								rtnval = delay_handler(data,packet,h );
								send_ack(data,packet,h);
								break;
								
				case PGM_CMD:	rtnval = pgm_handler(data, packet, h);

								break;
														
				case SYNC_CMD:		// Sync command
								rtnval = sync_handler(data,packet,h );

								break;
								
				// Information commands
				case STATUS_CMD:		// Handle STATUS packet
								rtnval = status_handler(data,packet,h);
								break;
								
................................................................................
				case CHI_CMD:		// Channel information command
								rtnval = channel_handler(data,packet,h);
								break;
								
				// Setup commands
				case SET_AD_CMD:		// Handle WHO packet
								rtnval = who_handler( data,packet,h );

								break;
								
				case SET_FT_CMD:		// Handle Firing TIME packet
								rtnval = time_handler(data,packet,h);

								break;
								
				case SET_TM_CMD:		// Handle Test Mode command
								rtnval = test_mode_handler(data,packet,h);

								break;
								
				case SET_BKOFF_CMD:		// Set backoff value
								rtnval = backoff_handler(data,packet,h);

								break;
								
				case RESET_CMD:			// Handle RESET cmd
								rtnval = reset_handler(data,packet,h);
									// No response....
								break;
								
				case GET_DATA:			// Heandle read out command
								rtnval = getdata_handler(data,packet,h);

								break;

				default:		// Ignore and drop packet
								break;
			}
		
			// Get next chunk, and handle
................................................................................
*			Data[2]	-> end of packet = delay value as a number
*	Just sync the internal clock
*/
//************************************************************************

static int pgm_handler( CHILD_DATA *data,PACKET *packet,void *h )
{
	int rtnval = -1;
	int ch;
	long ft;
	PACKET pk;
	int bcast;
		
	// (1) Get channel values
	
................................................................................
	
	ft = strtoul((const char *)&(packet->data[packet->chunk_ptr+2]),NULL,10);
	
	// (3) Store in queue and return result
	
	if( store_in_queue( ch,ft,data ) == 0 )
	{
		rtnval = 0;
		data->control = packet->from;		// Save controller address
		pk.to = packet->from;
		pk.from = 0;
		
		pk.len = 2;
		pk.data[0] = RESP_CMD;
		pk.data[1] = PGM_CMD;

Changes to Shows/mariseillaise.json.

1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20

21
22
23
24
25
26
27

28
29
30
31
32
33
34

35
36
37
38
39
40
41

42
43
44
45
46


47
48
{
	"show"		:	"La Mariseillaise",
	"music" 	:	"marseillaise.mp3",
	"time"		:	"1:03",
	"nodes"		:	"6",
	"program" : [
			{ "node" : "1", "ch" : "1" , "delay" : "1048" },
			{ "node" : "2", "ch" : "1" , "delay" : "2245" },
			{ "node" : "3", "ch" : "1" , "delay" : "5957" },
			{ "node" : "4", "ch" : "1" , "delay" : "7663" },
			{ "node" : "5", "ch" : "1" , "delay" : "10357" },
			{ "node" : "6", "ch" : "1" , "delay" : "10925" },
			{ "node" : "7", "ch" : "1" , "delay" : "11444" },

			{ "node" : "1", "ch" : "2" , "delay" : "11983" },
			{ "node" : "2", "ch" : "2" , "delay" : "12502" },
			{ "node" : "3", "ch" : "2" , "delay" : "13021" },
			{ "node" : "4", "ch" : "2" , "delay" : "14687" },
			{ "node" : "5", "ch" : "2" , "delay" : "15226" },
			{ "node" : "6", "ch" : "2" , "delay" : "15794" },
			{ "node" : "7", "ch" : "2" , "delay" : "16273" },

			{ "node" : "1", "ch" : "3" , "delay" : "16463" },
			{ "node" : "2", "ch" : "3" , "delay" : "18478" },
			{ "node" : "3", "ch" : "3" , "delay" : "19676" },
			{ "node" : "4", "ch" : "3" , "delay" : "20115" },
			{ "node" : "5", "ch" : "3" , "delay" : "33025" },
			{ "node" : "6", "ch" : "3" , "delay" : "35200" },
			{ "node" : "7", "ch" : "3" , "delay" : "37425" },

			{ "node" : "1", "ch" : "4" , "delay" : "40877" },
			{ "node" : "2", "ch" : "4" , "delay" : "41286" },
			{ "node" : "3", "ch" : "4" , "delay" : "41795" },
			{ "node" : "4", "ch" : "4" , "delay" : "41965" },
			{ "node" : "5", "ch" : "4" , "delay" : "42334" },
			{ "node" : "6", "ch" : "4" , "delay" : "42823" },
			{ "node" : "7", "ch" : "4" , "delay" : "45487" },

			{ "node" : "1", "ch" : "5" , "delay" : "47023" },
			{ "node" : "2", "ch" : "5" , "delay" : "47552" },
			{ "node" : "3", "ch" : "5" , "delay" : "51304" },
			{ "node" : "4", "ch" : "5" , "delay" : "53379" },
			{ "node" : "5", "ch" : "5" , "delay" : "54556" },
			{ "node" : "6", "ch" : "5" , "delay" : "54985" },
			{ "node" : "7", "ch" : "5" , "delay" : "57170" },

			{ "node" : "2", "ch" : "6" , "delay" : "57609" },
			{ "node" : "4", "ch" : "6" , "delay" : "58747" },
			{ "node" : "6", "ch" : "6" , "delay" : "59904" },
			{ "node" : "1", "ch" : "6" , "delay" : "60403" },
			{ "node" : "3", "ch" : "6" , "delay" : "60972" }


				]
}




|

|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
>
|
|
|
|
|
>
>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
	"show"		:	"La Mariseillaise",
	"music" 	:	"marseillaise.mp3",
	"time"		:	"1:03",
	"nodes"		:	"8",
	"program" : [
			{ "node" : "1", "ch" : "1" , "delay" : "1631" },
			{ "node" : "2", "ch" : "1" , "delay" : "2149" },
			{ "node" : "3", "ch" : "1" , "delay" : "2718" },
			{ "node" : "4", "ch" : "1" , "delay" : "3685" },
			{ "node" : "5", "ch" : "1" , "delay" : "4159" },
			{ "node" : "6", "ch" : "1" , "delay" : "5220" },
			{ "node" : "7", "ch" : "1" , "delay" : "5853" },
			{ "node" : "8", "ch" : "1" , "delay" : "6637" },
			{ "node" : "1", "ch" : "2" , "delay" : "6835" },
			{ "node" : "2", "ch" : "2" , "delay" : "7052" },
			{ "node" : "3", "ch" : "2" , "delay" : "7875" },
			{ "node" : "4", "ch" : "2" , "delay" : "8131" },
			{ "node" : "5", "ch" : "2" , "delay" : "8922" },
			{ "node" : "6", "ch" : "2" , "delay" : "11301" },
			{ "node" : "7", "ch" : "2" , "delay" : "11685" },
			{ "node" : "8", "ch" : "2" , "delay" : "12218" },
			{ "node" : "1", "ch" : "3" , "delay" : "13253" },
			{ "node" : "2", "ch" : "3" , "delay" : "15458" },
			{ "node" : "3", "ch" : "3" , "delay" : "15825" },
			{ "node" : "4", "ch" : "3" , "delay" : "16337" },
			{ "node" : "5", "ch" : "3" , "delay" : "17243" },
			{ "node" : "6", "ch" : "3" , "delay" : "19848" },
			{ "node" : "7", "ch" : "3" , "delay" : "24543" },
			{ "node" : "8", "ch" : "3" , "delay" : "27134" },
			{ "node" : "1", "ch" : "4" , "delay" : "27928" },
			{ "node" : "2", "ch" : "4" , "delay" : "30049" },
			{ "node" : "3", "ch" : "4" , "delay" : "33568" },
			{ "node" : "4", "ch" : "4" , "delay" : "35894" },
			{ "node" : "5", "ch" : "4" , "delay" : "41001" },
			{ "node" : "6", "ch" : "4" , "delay" : "42049" },
			{ "node" : "7", "ch" : "4" , "delay" : "43071" },
			{ "node" : "8", "ch" : "4" , "delay" : "43921" },
			{ "node" : "1", "ch" : "5" , "delay" : "45614" },
			{ "node" : "2", "ch" : "5" , "delay" : "46101" },
			{ "node" : "3", "ch" : "5" , "delay" : "47088" },
			{ "node" : "4", "ch" : "5" , "delay" : "47796" },
			{ "node" : "5", "ch" : "5" , "delay" : "49622" },
			{ "node" : "6", "ch" : "5" , "delay" : "51017" },
			{ "node" : "7", "ch" : "5" , "delay" : "52756" },
			{ "node" : "8", "ch" : "5" , "delay" : "53613" },
			{ "node" : "2", "ch" : "6" , "delay" : "54267" },
			{ "node" : "4", "ch" : "6" , "delay" : "54989" },
			{ "node" : "6", "ch" : "6" , "delay" : "56118" },
			{ "node" : "8", "ch" : "6" , "delay" : "57603" },
			{ "node" : "3", "ch" : "6" , "delay" : "59056" },
			{ "node" : "5", "ch" : "6" , "delay" : "60643" },
			{ "node" : "7", "ch" : "6" , "delay" : "61562" }
				]
}

Changes to Shows/marseillaise.mp3.

cannot compute difference between binary files

Changes to Shows/shows.json.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
	"shows" : [
		{ "show"		:	"La Mariseillaise",
		  "file"		:	"mariseillaise.json",
		  "nodes"		:	"6",
		  "time"		:	"1:26"
		  },
		  
		  {
		  	"show"		:	"Stars & Stripes Forever",
		  	"file"		:	"ss_forever.json",
		  	"nodes"		:	"10",
		  	"time"		:	"3:38"
		  }
		]
}  




|
|










1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
	"shows" : [
		{ "show"		:	"La Mariseillaise",
		  "file"		:	"mariseillaise.json",
		  "nodes"		:	"8",
		  "time"		:	"1:02"
		  },
		  
		  {
		  	"show"		:	"Stars & Stripes Forever",
		  	"file"		:	"ss_forever.json",
		  	"nodes"		:	"10",
		  	"time"		:	"3:38"
		  }
		]
}  

Changes to Site/Site_J/auto.js.

1
2
3
4
5

6
7
8
9
10
11
12
...
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199












200




















201
202
203
204
205
206
207
// *************************************************
//
// AUTOMATIC RUN	- Selection part
//
//	18-Nov-2011	[7f829d5df2] Initial Version

//
// *************************************************

//var FNET_Status;
var FNET_NET_MAX = 30;		// Maximum net size
var FNET_NET_MIN = 1;
var FNET_NET_CH	= 6;
................................................................................
		
		path = lcnURI + "firenet/program/set/" + SELECT_ROW.id;
		result = FNET_getData(path,true,"",true);
		if( result.STATUS == "OK" )
		{
			// Now program the nodes but first reset ALL of them
			
			$("#AUTO_RUN_BLOCK").replaceWith("<div id=\"AUTO_RUN_BLOCK\"><p><center>...Programming nodes...</center></div>");
			path = lcnURI + "firenet/program/pgm";
			result = FNET_getData(path,true,"",true);
			if( result.STATUS == "OK" )
			{
				$("#AUTO_RUN_BLOCK").replaceWith("<div id=\"AUTO_RUN_BLOCK\"><p><center>...READY...</center></div>");
				AUTO_RunOperation();
			}












		}




















	}
	
}

//-----------------------------------------------------------------------
/*
	AUTO_BuildShowHeader()





>







 







|







>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
...
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
// *************************************************
//
// AUTOMATIC RUN	- Selection part
//
//	18-Nov-2011	[7f829d5df2] Initial Version
//	 9-Feb-2013 Handle programming failures
//
// *************************************************

//var FNET_Status;
var FNET_NET_MAX = 30;		// Maximum net size
var FNET_NET_MIN = 1;
var FNET_NET_CH	= 6;
................................................................................
		
		path = lcnURI + "firenet/program/set/" + SELECT_ROW.id;
		result = FNET_getData(path,true,"",true);
		if( result.STATUS == "OK" )
		{
			// Now program the nodes but first reset ALL of them
			
			$("#AUTO_RUN_BLOCK").replaceWith("<div id=\"AUTO_RUN_BLOCK\"><p><center><h2>...Programming nodes...</h2></center></div>");
			path = lcnURI + "firenet/program/pgm";
			result = FNET_getData(path,true,"",true);
			if( result.STATUS == "OK" )
			{
				$("#AUTO_RUN_BLOCK").replaceWith("<div id=\"AUTO_RUN_BLOCK\"><p><center>...READY...</center></div>");
				AUTO_RunOperation();
			}
			else
			{
				// Failed to program so go back to start
				outmsg = "<div id=\"AUTO_RUN_BLOCK\"><center><h1>PGM FAILED...</h1></center>";
				outmsg = outmsg + "<p><h4><center>" + result.STATUS + "</center></h3></div>";
				$("#AUTO_RUN_BLOCK").replaceWith(outmsg);
				SHOW_SELECT = 0;
				SHOW_TIME = 0;
				SELECT_ROW = null;
				// Reset all nodes before returning
				path = lcnURI + "firenet/program/abort";
				result = FNET_getData(path,true,"",true);
				
				setTimeout(AUTO_Operation,5000)
            }
		}
		else
		{
			// Failed to load program so go back to start
			outmsg = "<div id=\"AUTO_RUN_BLOCK\"><center><h1>PGM LOAD FAILED...</h1></center>";
			outmsg = outmsg + "<p><h4><center>" + result.STATUS + "</center></h3></div>";
			$("#AUTO_RUN_BLOCK").replaceWith(outmsg);
			SHOW_SELECT = 0;
			SHOW_TIME = 0;
			SELECT_ROW = null;
			
			// Reset all nodes before returning
			path = lcnURI + "firenet/program/abort";
			result = FNET_getData(path,true,"",true);

			setTimeout(AUTO_Operation,5000)
		}

	}
	
}

//-----------------------------------------------------------------------
/*
	AUTO_BuildShowHeader()

Changes to Site/Site_J/autorun.js.

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
...
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
{
	
	var path;
	var result;
	
	if( AUTO_RUN == false )
	{

		// Depending on FIRE status send an ARM or disarm command
		
		if( AUTO_ARM )
		{
			// Send a DISARM command
			
			path = lcnURI + "firenet/arm/0/D";
................................................................................
		$("#AUTO_RUN_BLOCK").replaceWith(outmsg);
		
		// Send the command then update the status
		// Allow network to settle before doing status
		
		result = FNET_getData(path,true,"" );
		
		setTimeout(AUTO_RunOperation,500);
	}
}

//-----------------------------------------------------------------------
/*
		EVENT RUN Button - Do RUN or ABORT
*/
................................................................................
			AUTO_RUN = false;
			AUTO_ARM = false;
			SHOW_SELECT = 0;
			SHOW_TIME = 0;
			SELECT_ROW = null;
			AUTO_RUN_TIME = 0;
			setTimeout(AUTO_Operation,500);
			
		}
	}
}

//-----------------------------------------------------------------------
/*
		RUN MONITOR







<







 







|







 







<







87
88
89
90
91
92
93

94
95
96
97
98
99
100
...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
...
195
196
197
198
199
200
201

202
203
204
205
206
207
208
{
	
	var path;
	var result;
	
	if( AUTO_RUN == false )
	{

		// Depending on FIRE status send an ARM or disarm command
		
		if( AUTO_ARM )
		{
			// Send a DISARM command
			
			path = lcnURI + "firenet/arm/0/D";
................................................................................
		$("#AUTO_RUN_BLOCK").replaceWith(outmsg);
		
		// Send the command then update the status
		// Allow network to settle before doing status
		
		result = FNET_getData(path,true,"" );
		
		setTimeout(AUTO_RunOperation,1000);
	}
}

//-----------------------------------------------------------------------
/*
		EVENT RUN Button - Do RUN or ABORT
*/
................................................................................
			AUTO_RUN = false;
			AUTO_ARM = false;
			SHOW_SELECT = 0;
			SHOW_TIME = 0;
			SELECT_ROW = null;
			AUTO_RUN_TIME = 0;
			setTimeout(AUTO_Operation,500);

		}
	}
}

//-----------------------------------------------------------------------
/*
		RUN MONITOR

Changes to Site/rest/firenet_sup.lua.

18
19
20
21
22
23
24

25
26
27
28
29
30
31
...
152
153
154
155
156
157
158


159
160
161
162
163







164
165
166
167
168
169
170
--	20-Sep-2009	Add cmd line handler
--	21-Sep-2009 Add music shutdown
--	17-May-2010 [ba31d5cae3] Convert to NEWNET version
--	16-Jan-2011	[e4208b8f56] Change status response msg header
--	23-Jan-2011 Correct update_status() code for new response hdr
--	23-Jan-2011 [e63a96467f] Fix status return parsing
--	23-Apr-2011 [ef1d5adef2] Wrong calculation in status.

--
----------------------------------------------------------------

----------------------------------------------------------------
-- GLOBAL DATA STRUCTURES
----------------------------------------------------------------
FNET_MAP = {}			-- Network MAP
................................................................................
			print("-- Rec Packet --")
			table.foreach(rtnval,print)
			if( pkt.TO == 0 or pkt.TO == rtnval.FROM )
			then
				break
			else
				print("Packet REJECTED Wrong address Discarded",pkt.TO,rtnval.FROM)


			end
		end
	end
	
	-- Remove timer and return result







	wtimer:delete()	
	return rtnval
end

----------------------------------------------------------------
--	update_status( sd )
--







>







 







>
>





>
>
>
>
>
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
--	20-Sep-2009	Add cmd line handler
--	21-Sep-2009 Add music shutdown
--	17-May-2010 [ba31d5cae3] Convert to NEWNET version
--	16-Jan-2011	[e4208b8f56] Change status response msg header
--	23-Jan-2011 Correct update_status() code for new response hdr
--	23-Jan-2011 [e63a96467f] Fix status return parsing
--	23-Apr-2011 [ef1d5adef2] Wrong calculation in status.
--	 9-Feb-2013 Change swr_firenet() to return nil on bad addr or timeout
--
----------------------------------------------------------------

----------------------------------------------------------------
-- GLOBAL DATA STRUCTURES
----------------------------------------------------------------
FNET_MAP = {}			-- Network MAP
................................................................................
			print("-- Rec Packet --")
			table.foreach(rtnval,print)
			if( pkt.TO == 0 or pkt.TO == rtnval.FROM )
			then
				break
			else
				print("Packet REJECTED Wrong address Discarded",pkt.TO,rtnval.FROM)
				--rtnval = nil
				--break	-- Quit bad stuff...
			end
		end
	end
	
	-- Remove timer and return result
	-- If timed out return NIL
	if( wtimer:done(delay) == 1 )
	then
		print("** SWR TIMEOUT ***")
		rtnval = nil
	end
	
	wtimer:delete()	
	return rtnval
end

----------------------------------------------------------------
--	update_status( sd )
--

Changes to Site/rest/program.lua.

277
278
279
280
281
282
283

284
285
286
287
288
289
290
											SHOW_PGM[i].JOBJ.ch)
							break;
						end
					else
						out.STATUS =  string.format("COM FAIL @ [%s] [%s]",
											SHOW_PGM[i].JOBJ.node,
											SHOW_PGM[i].JOBJ.ch)

						run = nil
						break
					end
					
					-- Did program run OK
					
					if( run ~= nil )







>







277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
											SHOW_PGM[i].JOBJ.ch)
							break;
						end
					else
						out.STATUS =  string.format("COM FAIL @ [%s] [%s]",
											SHOW_PGM[i].JOBJ.node,
											SHOW_PGM[i].JOBJ.ch)
						print(out.STATUS)
						run = nil
						break
					end
					
					-- Did program run OK
					
					if( run ~= nil )

Changes to Tools/ShowGen/ShowGen.lua.

120
121
122
123
124
125
126

















































127
128
129
130
131
132
133
...
145
146
147
148
149
150
151

152
153
154
155
156
157
158
159
160
161
162
163
164




165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221





222
223
224
225
226
227
228
229
230
231
232
233
if( infl == nil )
then
	out = string.format("ERROR Cannot open %s as input",INPUT_FILE)
	show_help(out)
	os.exit()
end


















































if( outfl == nil )
then
	out = string.format("ERROR Cannot open %s as output",OUTPUT_FILE)
	show_help(out)
	os.exit()
end

................................................................................
-- will only have a \n

-- Set up for run

current_node = 1
file_run = 1
first = 1


for line in infl:lines() 
do
	-- Extract the first chunk which is the time
	-- Convert to integer MS
	-- Extract the number as a substring
	-- convert to MS and do a ceiling to
	-- get the rounded up value
	n,en = string.find(line,"(%d+%p%d+)")
	delay = string.sub(line,n,en)
	delay = tonumber(delay)*1000
	delay = math.ceil( delay )
	




	-- Next use the current node and current channel for the output
	-- If used up try next and so on fail if no channels left
	
	current_ch = nodelist[current_node]
	node = current_node
	while( current_ch >= MAX_CHANNEL )
	do
		-- Try the next node
		
		node = node + 1
		if( node > NODES )
		then
			node = 1
		end
		
		-- If we hit the current node AGAIN then failure 
		-- not enough nodes in the list
		
		if( node == current_node )
		then
			print("FAILURE: EXCEEDED CHANNELS, ADD MORE NODES")
			os.exit()
		end
		
		if( nodelist[node] <= MAX_CHANNEL )
		then
			-- SUCCESS use this node
			
			current_node = node
			current_ch = nodelist[current_node]
			break
		end
	end

	-- Finish the last line (do only after first line)
	
	if( first == nil )
	then
		outfl:write(",\n")
	end
	first = nil
	
	-- Generate and output line
	
	out = string.format("\t\t\t{ \"node\" : \"%d\", \"ch\" : \"%d\" , \"delay\" : \"%d\" }",
				current_node,
				current_ch,
				delay)
	outfl:write(out)
	
	-- Update channel and current_node
	
	nodelist[current_node] = nodelist[current_node] + 1
	current_node = current_node + 1
	if( current_node > NODES )
	then
		current_node = 1





	end
end

-- Now add last \n on the output and close

outfl:write("\n")
infl:close()
outfl:close()
print("-- END RUN --")
	









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>













>
>
>
>
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>












120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
if( infl == nil )
then
	out = string.format("ERROR Cannot open %s as input",INPUT_FILE)
	show_help(out)
	os.exit()
end

-----------------------------------------------
-- Right here read all the file and count lines

FLINES = 0
for line in infl:lines()
do
	FLINES = FLINES + 1
end
if( FLINES == 0 )
then
	out = string.format("File [%s] has no data - quitting",INPUT_FILE)
	show_help(out)
	os.exit()
else
	-- Compute how many to fire per queue
	SKIP_FIRE = FLINES/(NODES * MAX_CHANNEL)
	if( SKIP_FIRE < 1 )
	then
		-- Going here means we have more pieces than queues
		-- So compute the number of pieces to fire/queue
		SKIP_FIRE = 1.0 / SKIP_FIRE
		SKIP_FIRE = math.floor( SKIP_FIRE )
		SKIP_FIRE = -1 * SKIP_FIRE
	else
		SKIP_FIRE = math.floor( SKIP_FIRE )
	end

end

-- Now Re-open the file

infl:close()
infl = io.open(INPUT_FILE,"r")

out = string.format("File Lines = [%d]",FLINES)
print(out)
if( SKIP_FIRE > 0 )
then
	out = string.format("Queues skipped between fires [%d]",SKIP_FIRE)
else
	print("-- Too many pieces for # queues decrease nodes")
	out = string.format("Pieces fired/queue = [%d]",-1*SKIP_FIRE)
	print(out)
	os.exit() 
end
print(out)
print("\n")
-----------------------------------------------
	
if( outfl == nil )
then
	out = string.format("ERROR Cannot open %s as output",OUTPUT_FILE)
	show_help(out)
	os.exit()
end

................................................................................
-- will only have a \n

-- Set up for run

current_node = 1
file_run = 1
first = 1
skip = SKIP_FIRE

for line in infl:lines() 
do
	-- Extract the first chunk which is the time
	-- Convert to integer MS
	-- Extract the number as a substring
	-- convert to MS and do a ceiling to
	-- get the rounded up value
	n,en = string.find(line,"(%d+%p%d+)")
	delay = string.sub(line,n,en)
	delay = tonumber(delay)*1000
	delay = math.ceil( delay )
	

	if( skip < 1.0 )
	then
			print(delay,skip)		
		-- Next use the current node and current channel for the output
		-- If used up try next and so on fail if no channels left
	
		current_ch = nodelist[current_node]
		node = current_node
		while( current_ch >= MAX_CHANNEL )
		do
			-- Try the next node
			
			node = node + 1
			if( node > NODES )
			then
				node = 1
			end
			
			-- If we hit the current node AGAIN then failure 
			-- not enough nodes in the list
			
			if( node == current_node )
			then
				print("FAILURE: EXCEEDED CHANNELS, ADD MORE NODES")
				os.exit()
			end
			
			if( nodelist[node] <= MAX_CHANNEL )
			then
				-- SUCCESS use this node
				
				current_node = node
				current_ch = nodelist[current_node]
				break
			end
		end

		-- Finish the last line (do only after first line)
		
		if( first == nil )
		then
			outfl:write(",\n")
		end
		first = nil
		
		-- Generate and output line
		
		out = string.format("\t\t\t{ \"node\" : \"%d\", \"ch\" : \"%d\" , \"delay\" : \"%d\" }",
					current_node,
					current_ch,
					delay)
		outfl:write(out)
		
		-- Update channel and current_node
		
		nodelist[current_node] = nodelist[current_node] + 1
		current_node = current_node + 1
		if( current_node > NODES )
		then
			current_node = 1
		end
		-- Restore skip value
		skip = SKIP_FIRE
	else
		skip = skip - 1
	end
end

-- Now add last \n on the output and close

outfl:write("\n")
infl:close()
outfl:close()
print("-- END RUN --")