Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## pacemaker
Class FireflyProtocol

    java.lang.Object
      pacemaker.Firefly
          pacemaker.FireflyProtocol

All Implemented Interfaces:
  java.lang.Cloneable, peersim.core.Protocol, peersim.edsim.EDProtocol

    public class FireflyProtocol

extends Firefly
implements peersim.edsim.EDProtocol

The implementation of a protocol inspired by Fireflies.

Field Summary
`double` | `adjustable_period` the period we choiced to use, for models that adjust the frequency of flashing, eg `ADAPTIVE model` NOW it's a double: store also micro-adjustment.
`long` | `birth` the time when I first come to life, in Simulator time.
`int` | `cycle` Count the number of cycles done.
`long` | `last_cycle_time` the time (simulator's timestamp) we start the last cycle.
`long` | `last_flash_time` The LAST TIME (simulator's timestamp) we DO FLASH.
`long` | `last_stimulus_time` the time (simulator's timestamp) we received the last stimulus (other's pulse) from the environment.
`static int` | `lid` Identifier of the linkable ID
`int` | `n_received` How many msg I received since birth
`long` | `next_cycle_time` the time (simulator's timestamp) we scheduled our next cycle.
`static java.lang.String` | `PAR_FANOUT`
`static java.lang.String` | `PAR_HEAR`
`static java.lang.String` | `PAR_START` String name of the parameter used to configure the starting time of the firefly protocol, e.g.
`static int` | `pid` Identifier of the protocol ID
`int` | `start`
`static int` | `tid` Identifier of the transport ID
`int` | `timestamp` Useful for implementing a technique of modifiable timer for peersim EDSimulator.

Fields inherited from class pacemaker.Firefly
`b, epsilon, inert, max, min, model, PAR_B, PAR_EPSILON, PAR_INERT, PAR_MAX, PAR_MIN, PAR_MODEL, PAR_PERIOD, PAR_PREP, PAR_PULSE_DURATION, PAR_RELAXATION, PAR_SPECIES, period, prep, pulse_duration, relaxation, species`

Constructor Summary
`FireflyProtocol(java.lang.String prefix)`

Method Summary
`void` | `doFlash()` Do Emission of a Firefly Flash.
`double` | `getAdjustable_period()`
`void` | `initSchedule()` Run just after `contructor` or `Firefly.clone()`, here we must set up a first event delivered to self: because execution took place in a node when an event is delivered, without this such first event, this node won't start.
`void` | `processEvent(peersim.core.Node node, int p_id, java.lang.Object event)` Process 2 types of events: Timer (when clock ticks) and Pulse (from other fireflies).
`void` | `receive(peersim.core.Node node, int pid, java.lang.Object event)` Called by `processEvent(Node, int, Object)` when the event is a light pulse from a neighbor firefly.
`void` | `setPeriod(int value)` Setter for use with initializers.
`void` | `setStart(int value)` Setter for use with initializers.

Methods inherited from class pacemaker.Firefly
`clone`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface peersim.core.Protocol
`clone`

Field Detail

### PAR_START

    public static final java.lang.String PAR_START

  String name of the parameter used to configure the starting time of the firefly protocol, e.g. when that firefly do its first flash (cycle)!

  Suggestion: First flash must not be all-together: what you want to find if you already start in sync?.

  Some ways to start:

  1. Sync emersion/Sync speed: start somewhere during the first period because fireflies still do 1 flash each period.
  2. Sunset happening: fireflies usually start flashing when Light/Dark Ratio is favorable (after sunset), you can use some random larger-then-period start time to simulate this.
  3. Mass flashing: Will all fireflies start flashing and will they end up being in sync if just 1, 2, 3, few, some, or many-but-not-all of them will voluntary emit their first flash?

  Defaults to: random start time during first period.

  See Also:
    Constant Field Values

### start

    public int start

### PAR_FANOUT

    public static final java.lang.String PAR_FANOUT

See Also:
  Constant Field Values

### PAR_HEAR

    public static final java.lang.String PAR_HEAR

See Also:
  Constant Field Values

### lid

    public static int lid

  Identifier of the linkable ID

### tid

    public static int tid

  Identifier of the transport ID

### pid

    public static int pid

  Identifier of the protocol ID

### cycle

    public int cycle

  Count the number of cycles done.

### timestamp

    public int timestamp

  Useful for implementing a technique of modifiable timer for peersim EDSimulator.

  See Also:
    `EDSimulator`

### last_cycle_time

    public long last_cycle_time

  the time (simulator's timestamp) we start the last cycle.

  Note that a cycle do not imply flashing. Ex: `DELAY model`.

### next_cycle_time

    public long next_cycle_time

  the time (simulator's timestamp) we scheduled our next cycle.

  Note that a cycle do not imply flashing. Ex: `DELAY model`.

### last_flash_time

    public long last_flash_time

  The LAST TIME (simulator's timestamp) we DO FLASH.

### adjustable_period

    public double adjustable_period

  the period we choiced to use, for models that adjust the frequency of flashing, eg `ADAPTIVE model` NOW it's a double: store also micro-adjustment.

### last_stimulus_time

    public long last_stimulus_time

  the time (simulator's timestamp) we received the last stimulus (other's pulse) from the environment.

### birth

    public long birth

  the time when I first come to life, in Simulator time.

### n_received

    public int n_received

  How many msg I received since birth

Constructor Detail

### FireflyProtocol

    public FireflyProtocol(java.lang.String prefix)

Method Detail

### getAdjustable_period

    public double getAdjustable_period()

  Returns:
    the adjustable_period

### initSchedule

    public void initSchedule()

  Description copied from class: `Firefly`
  Run just after `contructor` or `Firefly.clone()`, here we must set up a first event delivered to self: because execution took place in a node when an event is delivered, without this such first event, this node won't start.

  Specified by:
    `initSchedule` in class `Firefly`
  See Also:
    `Firefly.initSchedule()`

### setStart

    public void setStart(int value)

  Setter for use with initializers.

### setPeriod

    public void setPeriod(int value)

  Setter for use with initializers.

  XXX note the conversion from int (randomized by setter) to double

### doFlash

    public void doFlash()

  Description copied from class: `Firefly`
  Do Emission of a Firefly Flash.

  Here you implement a 'firefly flash' so you should keep in mind some characteristics of that flash:

  1. direction: firefly can decide the direction to emit light. usually is a 180° cone.

  2. sensibility: Firefly's eyes able to sense flashes within 3 meters circa (Buck).

  3. visibility: vegetation (...) can create obstacles to line-of-sight.

  Specified by:
    `doFlash` in class `Firefly`

### processEvent

    public void processEvent(peersim.core.Node node,
                             int p_id,
                             java.lang.Object event)

  Process 2 types of events: Timer (when clock ticks) and Pulse (from other fireflies).

  The periodic timed flash of a firefly will be implemented as a special event delivered each period to the node itself.

  Specified by:
    `processEvent` in interface `peersim.edsim.EDProtocol`

### receive

    public void receive(peersim.core.Node node,
                        int pid,
                        java.lang.Object event)

  Called by `processEvent(Node, int, Object)` when the event is a light pulse from a neighbor firefly.

  The models (ADVANCE,DELAY,MAS,ADAPTIVE...) are applied here: choice how to react to the event.

  Specified by:
    `receive` in class `Firefly`

Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD