Firenet

Check-in [368a67306b]
Login

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

Overview
Comment:[83c43c7cd5] more efficient firing
Timelines: family | ancestors | descendants | both | NEWNET
Files: files | file ages | folders
SHA1:368a67306b31754e4cd137ed897b002207aff50e
User & Date: jim 2012-11-01 17:10:12
References
2012-11-01
18:32 Fixed ticket [83c43c7cd5]: Change early fire detection to only happen when data measured plus 4 other changes artifact: 44333be0eb user: jim
Context
2013-02-10
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
11:17
Working diag check-in: 621cf98728 user: jim tags: NEWNET
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Arduino/diag/fireDiag/Firediag.pde.

5
6
7
8
9
10
11


12
13
14
15
16
17
18
...
221
222
223
224
225
226
227

228
229
230
231
232
233
234
...
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
...
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432

433
434
435
436
437
438
439
...
445
446
447
448
449
450
451

452
453
454
455
456
457
458


459
460
461
462
463
464
465
466
467
468
469
470
471


472
473
474
475
476
477
478
  This program is used to to test the firing circuit
  It can:
  	(a) Enable/Disable ARM relay
  	(b) Fire a channel
  	(c) Set firing parameters 
  
  28-Oct-2012	Initial version


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

#include "EEPROM.h"
#include "debug.h"
#include "newnet.h"
#include "eerom.h"
................................................................................
    int i,n;
    int buf_psn = 0;
    long now;
    char val;
    int len;
    char ch;
    int fired = 0;


#if 0
	#pragma mark -
	#pragma mark LOOP PKT PROCESS
#endif

	if( Serial.available() > 0 )
................................................................................
	{
		if( now >= state.next_blink )
		{
			state.next_blink += BLINK_TIME;
			val = digitalRead( LED );
			val = val ^ 0x1;
			digitalWrite(LED,val);
			
		}
	}

#if 0
	#pragma mark -
	#pragma mark LOOP FIRE DELAY
#endif
................................................................................
	}

#if 0
	#pragma mark -
	#pragma mark LOOP FIRE
#endif
	
	if( state.in_fire )					// Terminate FIRE actions
	{
		// [9e81c1a523] Adaptive - See if it's fired already		
		// Read out the A/D on that channel & set fired status
		// fake it on test mode (show as fired)
		
		if( test_mode )
		{
		
			fire[state.fire_channel].pres = 0;		// Assume fired
			fire[state.fire_channel].ch_ad = DEVICE_PRESENT + 0x10;

		}
		else
		{
			// Time to check
			
			n = (int) state.now - state.adaptive_time;
			if( n > FIRE_CHECK_TIME )
................................................................................
				
				DEBUG_PRINT("ADAPT A/D[");
				DEBUG_PRINT_HEX(fire[state.fire_channel].ch_ad);
				DEBUG_PRINTLN("]");
				
				state.adaptive_time = state.now;					// Reset time
				digitalWrite( fire[state.fire_channel].fire,1);		// Enable fire

			}
		}
		
		// Now check for fired status, save the current time
		// for later analysis
		
		fire[state.fire_channel].fire_time = state.now;	// Save fire time


		if( fire[state.fire_channel].ch_ad < DEVICE_PRESENT )
		{
			fired = 1;									// Mark as fired
			fire[state.fire_channel].fired = 1;			// Mark as fired
			fire[state.fire_channel].pres = 0;			// Nothing connected
			DEBUG_PRINT("FIRE EARLY STOP [");
			DEBUG_PRINT_HEX(fire[state.fire_channel].pres);
			DEBUG_PRINTLN("]");
		}
		else
		{
			fired = 0;									// Mark as not fired
			fire[state.fire_channel].pres = 1;			// Item as connected


		}
		
		// If fired tidy up

		if( (fired == 1) || (state.now >= state.fire_time) )
		{
			state.in_fire = 0;







>
>







 







>







 







<







 







|










>







 







>







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







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
...
378
379
380
381
382
383
384

385
386
387
388
389
390
391
...
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
...
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
  This program is used to to test the firing circuit
  It can:
  	(a) Enable/Disable ARM relay
  	(b) Fire a channel
  	(c) Set firing parameters 
  
  28-Oct-2012	Initial version
   1-Nov-2012   Change firing loop to only check for firing when
   				a/d is set [83c43c7cd5]
*/
//**********************************************************************/

#include "EEPROM.h"
#include "debug.h"
#include "newnet.h"
#include "eerom.h"
................................................................................
    int i,n;
    int buf_psn = 0;
    long now;
    char val;
    int len;
    char ch;
    int fired = 0;
    bool fire_check = false;	// [83c43c7cd5]

#if 0
	#pragma mark -
	#pragma mark LOOP PKT PROCESS
#endif

	if( Serial.available() > 0 )
................................................................................
	{
		if( now >= state.next_blink )
		{
			state.next_blink += BLINK_TIME;
			val = digitalRead( LED );
			val = val ^ 0x1;
			digitalWrite(LED,val);

		}
	}

#if 0
	#pragma mark -
	#pragma mark LOOP FIRE DELAY
#endif
................................................................................
	}

#if 0
	#pragma mark -
	#pragma mark LOOP FIRE
#endif
	
	if( state.in_fire )					// Check for firing done
	{
		// [9e81c1a523] Adaptive - See if it's fired already		
		// Read out the A/D on that channel & set fired status
		// fake it on test mode (show as fired)
		
		if( test_mode )
		{
		
			fire[state.fire_channel].pres = 0;		// Assume fired
			fire[state.fire_channel].ch_ad = DEVICE_PRESENT + 0x10;
			fire_check = true;		// [83c43c7cd5]
		}
		else
		{
			// Time to check
			
			n = (int) state.now - state.adaptive_time;
			if( n > FIRE_CHECK_TIME )
................................................................................
				
				DEBUG_PRINT("ADAPT A/D[");
				DEBUG_PRINT_HEX(fire[state.fire_channel].ch_ad);
				DEBUG_PRINTLN("]");
				
				state.adaptive_time = state.now;					// Reset time
				digitalWrite( fire[state.fire_channel].fire,1);		// Enable fire
				fire_check = true;		// [83c43c7cd5]
			}
		}
		
		// Now check for fired status, save the current time
		// for later analysis
		
		fire[state.fire_channel].fire_time = state.now;	// Save fire time
		if( fire_check )		// [83c43c7cd5]
		{
			if( fire[state.fire_channel].ch_ad < DEVICE_PRESENT )
			{
				fired = 1;									// Mark as fired
				fire[state.fire_channel].fired = 1;			// Mark as fired
				fire[state.fire_channel].pres = 0;			// Nothing connected
				DEBUG_PRINT("FIRE EARLY STOP [");
				DEBUG_PRINT_HEX(fire[state.fire_channel].pres);
				DEBUG_PRINTLN("]");
			}
			else
			{
				fired = 0;									// Mark as not fired
				fire[state.fire_channel].pres = 1;			// Item as connected
			}
			fire_check = false;
		}
		
		// If fired tidy up

		if( (fired == 1) || (state.now >= state.fire_time) )
		{
			state.in_fire = 0;