Download presentation
Presentation is loading. Please wait.
1
SOWN Code Review Top-level Control
2
SOWN Configuration SOWN Main MainControlC BackboneC TripWireM TimeSyncC RoutingC SD etc. SOWN.nc and MainControlC.nc specify wiring of components
3
MainControlC Wiring Details
4
SOWN Files Makefile SOWN.nc MainControl.h MainControl.nc
SOWN configuration definition MainControl.h System states MainControl.nc Interface definition MainControlC.nc Wiring of components MainControlM.nc Implementation of top-level state-machine
5
MainControl.h /* legitimate system phases/states */ enum {
STATE_CHAOS, STATE_INIT, STATE_SYSSYNC, STATE_LOCALIZE, STATE_DISCNEIGHBORS, STATE_BUILDBACKBONE, STATE_COMMITBACKBONE, STATE_SENTRYSEL, STATE_STATUS_REPORT, STATE_PM, STATE_TRACKING_PM, } NETWORK_STATES;
6
MainControl.nc interface MainControl { command result_t start();
command result_t stop(); command result_t setParameters (phaseDelay, PM_COUNT, SendPowerForSentrySelection, reportPeriod); command bool isSentry(); command result_t getMySentry(*id); command result_t getSentries(*sentries, *num_sentries); command result_t getNonsentries(*nonsentries_ptr, *num_nonsentries); event result_t ready (bool isReady); command result_t getNetworkStatus(); } Returns SUCCESS Delegated to SentrySelC Not used / Unimplemented
7
MainControlC.nc Uses components: Wiring as shown previously
MainControlM, BackboneC, ReportC, TimeSyncC, SD, TripWireM, TimeUtilC, TimerC, SentryPmC, SentrySelC, RandomLFSR, LedsC, ResetC, LocalC, TrackingC, GenericBaseRecvC, RoutingC, ConfigureC, DebugC, GenericComm, RadioResetC, RadioModelC, XTestXnpM, XnpC, CC1000ControlM Wiring as shown previously
8
MainControlM.nc Data uint8_t state; uint8_t phase_bits;
bool DynamicSettingDone; bool GlobalTimeDone; uint32_t round_start_time; uint16_t roundCount = 0; uint8_t sending_power_for_sensing_radius; uint32_t PHASE_DELAY; uint32_t REPORT_PERIOD; uint16_t PM_PHASE_COUNT; uint8_t SENTRY_SEND_POWER; uint32_t SYNC_DELAY; State of network Select phases to skip Progress flags Round start and counter For sentry selection Parameters sent by GUI
9
MainControlM.nc Functions
command result_t StdControl.init() command result_t StdControl.start() command result_t StdControl.stop() command result_t MainControl.start() event result_t Configure.SettingsReady(...) command result_t MainControl.setParameters(...) event result_t SysSync.GlobalTimeReady() event result_t PhaseTransitionTimer.fired() event uint8_t Backbone.GenericReceive(...) event result_t PM.wakeup() event result_t PM.sleep() Only called locally NOP
10
Initialization StdControl.init() StdControl.start()
Initialize Leds, Random, SysSyncControl, SDControl Initialize module data StdControl.start() Call Debug.start(), MainControl.start() MainControl.start() Set STATE_CHAOS, radio power Start 5s timer
11
MainControlM State Diagram
12
PhaseTransitionTimer.fired()
STATE_CHAOS: roundCount++ call Configure.start()
13
Configure.SettingsReady()
// only do the following once DynamicSettingDone = TRUE; state = STATE_INIT; post ReportTask(); ResetNodeStatus(); stop sub-component timers initParameters(settings); save and push settings down to components call PhaseTransitionTimer.start (TIMER_ONE_SHOT,1000 + call Random.rand()%1000);
14
PhaseTransitionTimer.fired()
STATE_INIT: call Configure.stop(); EnableSync(); sets master/slave for time sync call SysSyncControl.start();
15
SysSync.GlobalTimeReady()
GlobalTimeDone = TRUE; state = STATE_SYSSYNC; post ReportTask(); get global time and compute delay until round start (6 * GridX + 5s) call PhaseTransitionTimer.start2 (TIMER_ONE_SHOT, round_start_time - now );
16
PhaseTransitionTimer.fired()
STATE_SYSSYNC: state = STATE_LOCALIZE; post ReportTask(); call SysSyncControl.stop(); call Local.start( PHASE_DELAY>>2); call PhaseTransitionTimer.start (TIMER_ONE_SHOT, PHASE_DELAY); if (!call TripWire.isTripWireBase()) call RoutingControl.init();
17
PhaseTransitionTimer.fired()
STATE_LOCALIZE: call Local.stop(); if (localized) state = STATE_DISCNEIGHBORS; post ReportTask(); call SDControl.start(); call PhaseTransitionTimer.start (TIMER_ONE_SHOT, *PHASE_DELAY); else state = CHAOS; call RoutingControl.init(); call PhaseTransitionTimer.start (TIMER_ONE_SHOT, 5000);
18
PhaseTransitionTimer.fired()
STATE_DISCNEIGHBORS: state = STATE_BUILDBACKBONE; post ReportTask(); call SDControl.stop(); if (call TripWire.isTripWireBase()) call SentrySel.setSentry(TRUE); call Backbone.build(BRODCAST_PERIOD); call PhaseTransitionTimer.start (TIMER_ONE_SHOT, PHASE_DELAY);
19
PhaseTransitionTimer.fired()
STATE_BUILDBACKBONE: state = STATE_COMMITBACKBONE; post ReportTask(); call Backbone.commit(); call PhaseTransitionTimer.start (TIMER_ONE_SHOT, SHORT_PHASE_DELAY);
20
PhaseTransitionTimer.fired()
STATE_COMMITBACKBONE: state = STATE_SENTRYSEL; post ReportTask(); call Backbone.stop(); call SDNeighborTable.free(); call SentrySel.reset(); set non-leaves to be sentries if (!call TripWire.isTripWireBase()) call SentrySel.startSelection(sending_power..., PHASE_DELAY) call PhaseTransitionTimer.start (TIMER_ONE_SHOT, PHASE_DELAY);
21
PhaseTransitionTimer.fired()
STATE_SENTRYSEL: state = STATE_STATUS_REPORT; post ReportTask(); call SentrySel.stopSelection(); call Report.startReport(REPORT_PERIOD); call PhaseTransitionTimer.start (TIMER_ONE_SHOT, * PHASE_DELAY);
22
PhaseTransitionTimer.fired()
STATE_STATUS_REPORT: state = STATE_PM; post ReportTask(); call Report.stopReport(); call PM.enable(); call WakeupCom.EnablePowerM(TRUE); call PhaseTransitionTimer.start (TIMER_ONE_SHOT, SHORT_PHASE_DELAY);
23
PhaseTransitionTimer.fired()
STATE_STATUS_PM: state = STATE_TRACKING_PM; post ReportTask(); call Tracking.init(); call Tracking.start(); call PhaseTransitionTimer.start (TIMER_ONE_SHOT, PHASE_DELAY * PM_PHASE_COUNT);
24
PhaseTransitionTimer.fired()
STATE_STATUS_TRACKING_PM: state = STATE_CHAOS; post ReportTask(); if (!call TripWire.isTripWireBase()) Reset.reset(); else call PhaseTransitionTimer.start (TIMER_ONE_SHOT, SHORT_PHASE_DELAY); ResetNodeStatus();
25
task ReportTask call Leds.set(state)
call Report.ReportNetworkStatus(state);
26
MainControlM State Diagram
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.