1 / 26

SOWN Code Review

SOWN Code Review. Top-level Control. SOWN Configuration. SOWN.nc and MainControlC.nc specify wiring of components. SOWN. Main. MainControlC. BackboneC. TripWireM. TimeSyncC. RoutingC. SD. etc. MainControlC Wiring Details. SOWN Files. Makefile SOWN.nc SOWN configuration definition

kanan
Télécharger la présentation

SOWN Code Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SOWN Code Review Top-level Control

  2. SOWN Configuration • SOWN.nc and MainControlC.nc specify wiring of components SOWN Main MainControlC BackboneC TripWireM TimeSyncC RoutingC SD etc.

  3. MainControlC Wiring Details

  4. SOWN Files • Makefile • SOWN.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. Returns SUCCESS Not used / Unimplemented 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(); } Delegated to SentrySelC

  7. MainControlC.nc • Uses components: • 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. Select phases to skip Parameters sent by GUI 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 Progress flags Round start and counter For sentry selection

  9. Only called locally 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() NOP

  10. Initialization • StdControl.init() • 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, 2*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, 2 * 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

More Related