Documentation ¶
Index ¶
- Constants
- Variables
- type CallbackHandler
- type CoapCode
- type CoapMessage
- type CoapMessageRecvInfo
- type CoapType
- type Config
- type Dispatcher
- func (d *Dispatcher) AddNode(nodeid NodeId, x, y int, radioRange int)
- func (d *Dispatcher) CollectCoapMessages() []*CoapMessage
- func (d *Dispatcher) DeleteNode(id NodeId)
- func (d *Dispatcher) EnableCoaps()
- func (d *Dispatcher) GetAliveCount() int
- func (d *Dispatcher) GetFailedCount() int
- func (d *Dispatcher) GetGlobalMessageDropRatio() float64
- func (d *Dispatcher) GetNode(id NodeId) *Node
- func (d *Dispatcher) GetSpeed() float64
- func (d *Dispatcher) GetVisualizationOptions() VisualizationOptions
- func (d *Dispatcher) GetVisualizer() visualize.Visualizer
- func (d *Dispatcher) Go(duration time.Duration) <-chan struct{}
- func (d *Dispatcher) Nodes() map[NodeId]*Node
- func (d *Dispatcher) NotifyCommand(nodeid NodeId)
- func (d *Dispatcher) NotifyExit(nodeid NodeId)
- func (d *Dispatcher) PostAsync(trivial bool, task func())
- func (d *Dispatcher) RecvEvents() int
- func (d *Dispatcher) Run()
- func (d *Dispatcher) SendToUART(id NodeId, data []byte)
- func (d *Dispatcher) SetGlobalPacketLossRatio(plr float64)
- func (d *Dispatcher) SetNodeFailed(id NodeId, fail bool)
- func (d *Dispatcher) SetNodePos(id NodeId, x, y int)
- func (d *Dispatcher) SetSpeed(f float64)
- func (d *Dispatcher) SetVisualizationOptions(opts VisualizationOptions)
- func (d *Dispatcher) SetVisualizer(vis visualize.Visualizer)
- func (d *Dispatcher) Stop()
- func (d *Dispatcher) UnwatchNode(nodeid NodeId)
- func (d *Dispatcher) WatchNode(nodeid NodeId)
- type FailTime
- type FailureCtrl
- type JoinResult
- type Node
- func (node *Node) CollectJoins() []*JoinResult
- func (node *Node) CollectPings() []*PingResult
- func (node *Node) DumpStat() string
- func (node *Node) Fail()
- func (node *Node) GetDistanceTo(other *Node) (dist int)
- func (node *Node) IsFailed() bool
- func (node *Node) Recover()
- func (node *Node) Send(elapsed uint64, data []byte)
- func (node *Node) SendMessage(msg []byte)
- func (node *Node) SetFailTime(failTime FailTime)
- func (node *Node) String() string
- type OtJoinerState
- type PingResult
- type VisualizationOptions
Constants ¶
View Source
const ( ProcessEventTimeErrorUs = 0 MaxSimulateSpeed = 1000000 )
View Source
const (
Ever uint64 = math.MaxUint64 / 2
)
Variables ¶
View Source
var (
NonFailTime = FailTime{0, 0}
)
Functions ¶
This section is empty.
Types ¶
type CallbackHandler ¶
type CallbackHandler interface { OnNodeFail(nodeid NodeId) OnNodeRecover(nodeid NodeId) // Notifies that the node's UART was written with data. OnUartWrite(nodeid NodeId, data []byte) }
type CoapMessage ¶
type CoapMessage struct { Timestamp uint64 `yaml:"time"` SrcNode NodeId `yaml:"src"` ID int `yaml:"id"` Type CoapType `yaml:"type"` Code CoapCode `yaml:"code"` URI string `yaml:"uri,omitempty"` DstAddr string `yaml:"dst_addr"` DstPort int `yaml:"dst_port"` Error string `yaml:"error,omitempty"` Receivers []CoapMessageRecvInfo `yaml:"receivers,flow"` }
type CoapMessageRecvInfo ¶
type Config ¶
func DefaultConfig ¶
func DefaultConfig() *Config
type Dispatcher ¶
type Dispatcher struct { CurTime uint64 Counters struct { // Event counters AlarmEvents uint64 RadioEvents uint64 StatusPushEvents uint64 UartWriteEvents uint64 // Packet dispatching counters DispatchByExtAddrSucc uint64 DispatchByExtAddrFail uint64 DispatchByShortAddrSucc uint64 DispatchByShortAddrFail uint64 DispatchAllInRange uint64 } // contains filtered or unexported fields }
func NewDispatcher ¶
func NewDispatcher(ctx *progctx.ProgCtx, cfg *Config, cbHandler CallbackHandler) *Dispatcher
func (*Dispatcher) AddNode ¶
func (d *Dispatcher) AddNode(nodeid NodeId, x, y int, radioRange int)
func (*Dispatcher) CollectCoapMessages ¶
func (d *Dispatcher) CollectCoapMessages() []*CoapMessage
func (*Dispatcher) DeleteNode ¶
func (d *Dispatcher) DeleteNode(id NodeId)
func (*Dispatcher) EnableCoaps ¶
func (d *Dispatcher) EnableCoaps()
func (*Dispatcher) GetAliveCount ¶
func (d *Dispatcher) GetAliveCount() int
func (*Dispatcher) GetFailedCount ¶
func (d *Dispatcher) GetFailedCount() int
func (*Dispatcher) GetGlobalMessageDropRatio ¶
func (d *Dispatcher) GetGlobalMessageDropRatio() float64
func (*Dispatcher) GetNode ¶
func (d *Dispatcher) GetNode(id NodeId) *Node
func (*Dispatcher) GetSpeed ¶
func (d *Dispatcher) GetSpeed() float64
func (*Dispatcher) GetVisualizationOptions ¶
func (d *Dispatcher) GetVisualizationOptions() VisualizationOptions
func (*Dispatcher) GetVisualizer ¶
func (d *Dispatcher) GetVisualizer() visualize.Visualizer
func (*Dispatcher) Go ¶
func (d *Dispatcher) Go(duration time.Duration) <-chan struct{}
func (*Dispatcher) Nodes ¶
func (d *Dispatcher) Nodes() map[NodeId]*Node
func (*Dispatcher) NotifyCommand ¶
func (d *Dispatcher) NotifyCommand(nodeid NodeId)
func (*Dispatcher) NotifyExit ¶
func (d *Dispatcher) NotifyExit(nodeid NodeId)
NotifyExit notifies the dispatcher that the node process has exited.
func (*Dispatcher) PostAsync ¶
func (d *Dispatcher) PostAsync(trivial bool, task func())
func (*Dispatcher) RecvEvents ¶
func (d *Dispatcher) RecvEvents() int
RecvEvents receives events from nodes until there is no more alive node.
func (*Dispatcher) Run ¶
func (d *Dispatcher) Run()
func (*Dispatcher) SendToUART ¶
func (d *Dispatcher) SendToUART(id NodeId, data []byte)
SendToUART sends data to virtual time UART of the target node.
func (*Dispatcher) SetGlobalPacketLossRatio ¶
func (d *Dispatcher) SetGlobalPacketLossRatio(plr float64)
func (*Dispatcher) SetNodeFailed ¶
func (d *Dispatcher) SetNodeFailed(id NodeId, fail bool)
func (*Dispatcher) SetNodePos ¶
func (d *Dispatcher) SetNodePos(id NodeId, x, y int)
func (*Dispatcher) SetSpeed ¶
func (d *Dispatcher) SetSpeed(f float64)
func (*Dispatcher) SetVisualizationOptions ¶
func (d *Dispatcher) SetVisualizationOptions(opts VisualizationOptions)
func (*Dispatcher) SetVisualizer ¶
func (d *Dispatcher) SetVisualizer(vis visualize.Visualizer)
func (*Dispatcher) Stop ¶
func (d *Dispatcher) Stop()
func (*Dispatcher) UnwatchNode ¶
func (d *Dispatcher) UnwatchNode(nodeid NodeId)
func (*Dispatcher) WatchNode ¶
func (d *Dispatcher) WatchNode(nodeid NodeId)
type FailureCtrl ¶
type FailureCtrl struct {
// contains filtered or unexported fields
}
func (*FailureCtrl) OnTimeAdvanced ¶
func (fc *FailureCtrl) OnTimeAdvanced(oldTime uint64)
func (*FailureCtrl) SetFailTime ¶
func (fc *FailureCtrl) SetFailTime(failTime FailTime)
type JoinResult ¶
type Node ¶
type Node struct { D *Dispatcher Id NodeId X, Y int PartitionId uint32 ExtAddr uint64 Rloc16 uint16 CreateTime uint64 CurTime uint64 Role OtDeviceRole // contains filtered or unexported fields }
func (*Node) CollectJoins ¶
func (node *Node) CollectJoins() []*JoinResult
func (*Node) CollectPings ¶
func (node *Node) CollectPings() []*PingResult
func (*Node) GetDistanceTo ¶
func (*Node) SendMessage ¶
func (*Node) SetFailTime ¶
type OtJoinerState ¶
type OtJoinerState int
const ( OtJoinerStateIdle OtJoinerState = 0 OtJoinerStateDiscover OtJoinerState = 1 OtJoinerStateConnect OtJoinerState = 2 OtJoinerStateConnected OtJoinerState = 3 OtJoinerStateEntrust OtJoinerState = 4 OtJoinerStateJoined OtJoinerState = 5 )
type PingResult ¶
Click to show internal directories.
Click to hide internal directories.