|
|
@ -4,6 +4,13 @@ import (
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
|
|
StopSignalType = SignalType("STOP")
|
|
|
|
|
|
|
|
StatusSignalType = SignalType("STATUS")
|
|
|
|
|
|
|
|
LinkSignalType = SignalType("LINK")
|
|
|
|
|
|
|
|
LockSignalType = SignalType("LOCK")
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type SignalDirection int
|
|
|
|
type SignalDirection int
|
|
|
|
const (
|
|
|
|
const (
|
|
|
|
Up SignalDirection = iota
|
|
|
|
Up SignalDirection = iota
|
|
|
@ -12,6 +19,9 @@ const (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type SignalType string
|
|
|
|
type SignalType string
|
|
|
|
|
|
|
|
func (signal_type SignalType) String() string {
|
|
|
|
|
|
|
|
return string(signal_type)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type Signal interface {
|
|
|
|
type Signal interface {
|
|
|
|
Serializable[SignalType]
|
|
|
|
Serializable[SignalType]
|
|
|
@ -29,7 +39,7 @@ func (signal BaseSignal) Type() SignalType {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (signal BaseSignal) Permission() Action {
|
|
|
|
func (signal BaseSignal) Permission() Action {
|
|
|
|
return Action(signal.Type())
|
|
|
|
return MakeAction(signal.Type())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (signal BaseSignal) Direction() SignalDirection {
|
|
|
|
func (signal BaseSignal) Direction() SignalDirection {
|
|
|
@ -60,7 +70,6 @@ func NewDirectSignal(signal_type SignalType) BaseSignal {
|
|
|
|
return NewBaseSignal(signal_type, Direct)
|
|
|
|
return NewBaseSignal(signal_type, Direct)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const StopSignalType = SignalType("STOP")
|
|
|
|
|
|
|
|
var StopSignal = NewDownSignal(StopSignalType)
|
|
|
|
var StopSignal = NewDownSignal(StopSignalType)
|
|
|
|
|
|
|
|
|
|
|
|
type IDSignal struct {
|
|
|
|
type IDSignal struct {
|
|
|
@ -96,7 +105,6 @@ func (signal StatusSignal) String() string {
|
|
|
|
return string(ser)
|
|
|
|
return string(ser)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const StatusSignalType = SignalType("STATUS")
|
|
|
|
|
|
|
|
func NewStatusSignal(status string, source NodeID) StatusSignal {
|
|
|
|
func NewStatusSignal(status string, source NodeID) StatusSignal {
|
|
|
|
return StatusSignal{
|
|
|
|
return StatusSignal{
|
|
|
|
IDSignal: NewIDSignal(StatusSignalType, Up, source),
|
|
|
|
IDSignal: NewIDSignal(StatusSignalType, Up, source),
|
|
|
@ -104,8 +112,6 @@ func NewStatusSignal(status string, source NodeID) StatusSignal {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const LinkSignalType = SignalType("LINK")
|
|
|
|
|
|
|
|
const LockSignalType = SignalType("LOCK")
|
|
|
|
|
|
|
|
type StateSignal struct {
|
|
|
|
type StateSignal struct {
|
|
|
|
BaseSignal
|
|
|
|
BaseSignal
|
|
|
|
State string `json:"state"`
|
|
|
|
State string `json:"state"`
|
|
|
@ -134,6 +140,10 @@ func NewLockSignal(state string) StateSignal {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (signal StateSignal) Permission() Action {
|
|
|
|
|
|
|
|
return MakeAction(signal.Type(), signal.State)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type StartChildSignal struct {
|
|
|
|
type StartChildSignal struct {
|
|
|
|
IDSignal
|
|
|
|
IDSignal
|
|
|
|
Action string `json:"action"`
|
|
|
|
Action string `json:"action"`
|
|
|
|