core

package
v0.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STARTED    = Status("started")
	IN_PROCESS = Status("in process")
	ENDED      = Status("ended")
	DONE       = Status("done")
	ERROR      = Status("error")
)

Variables

This section is empty.

Functions

func NewCron

func NewCron() (cron *cr.Cron)

Types

type Action

type Action struct {
	Device       *m.Device
	Node         *Node
	ScriptEngine *scripts.Engine
	Message      *Message
	// contains filtered or unexported fields
}

func NewAction

func NewAction(device *m.Device,
	script *m.Script,
	node *Node,
	flow *Flow,
	scriptService *scripts.ScriptService) (action *Action, err error)

func (*Action) Do

func (a *Action) Do() (res string, err error)

func (*Action) GetDevice

func (a *Action) GetDevice() *m.Device

func (*Action) GetNode

func (a *Action) GetNode() *Node

func (*Action) NewScript

func (a *Action) NewScript() (err error)

type ActionBind

type ActionBind struct {
	// contains filtered or unexported fields
}

Javascript Binding

IC.Action()

.device()
.node()

func (*ActionBind) Device

func (a *ActionBind) Device() *DeviceBind

func (*ActionBind) Node

func (a *ActionBind) Node() *NodeBind

type ActionPrototypes

type ActionPrototypes interface {
	After(*Message, *Flow) error
	Run(*Message, *Flow) error
	Before(*Message, *Flow) error
	Type() string
}

type Core

type Core struct {
	sync.Mutex

	Map *Map
	// contains filtered or unexported fields
}

func NewCore

func NewCore(adaptors *adaptors.Adaptors,
	scripts *scripts.ScriptService,
	graceful *graceful_service.GracefulService,
	cron *cr.Cron,
	mqtt *mqtt.Mqtt,
	telemetry telemetry.ITelemetry,
	streamService *stream.StreamService) (core *Core, err error)

func (*Core) AddFlow

func (b *Core) AddFlow(flow *m.Flow) (err error)

func (*Core) AddNode

func (b *Core) AddNode(node *m.Node) (n *Node, err error)

func (*Core) AddWorkflow

func (b *Core) AddWorkflow(workflow *m.Workflow) (err error)

добавление рабочего процесс

func (*Core) ConnectNode

func (b *Core) ConnectNode(node *m.Node) (err error)

func (*Core) DeleteWorkflow

func (b *Core) DeleteWorkflow(workflow *m.Workflow) (err error)

нельзя удалить workflow, если присутствуют связанные сущности

func (*Core) DisconnectNode

func (b *Core) DisconnectNode(node *m.Node) (err error)

func (*Core) DoWorker

func (b *Core) DoWorker(model *m.Worker) (err error)

func (*Core) GetFlow

func (b *Core) GetFlow(id int64) (*Flow, error)

func (*Core) GetNodeById

func (b *Core) GetNodeById(nodeId int64) *Node

func (*Core) GetNodes

func (b *Core) GetNodes() (nodes map[int64]*Node)

func (*Core) GetWorkflow

func (wf *Core) GetWorkflow(workflowId int64) (workflow *Workflow, err error)

func (*Core) InitWorkflows

func (b *Core) InitWorkflows() (err error)

инициализация всего рабочего процесса, с запуском дочерни подпроцессов

func (*Core) ReloadNode

func (b *Core) ReloadNode(node *m.Node) (err error)

func (*Core) RemoveFlow

func (b *Core) RemoveFlow(flow *m.Flow) (err error)

func (*Core) RemoveNode

func (b *Core) RemoveNode(node *m.Node) (err error)

func (*Core) RemoveWorker

func (b *Core) RemoveWorker(_worker *m.Worker) (err error)

func (*Core) Restart

func (b *Core) Restart() (err error)

func (*Core) Run

func (c *Core) Run() (err error)

func (*Core) Shutdown

func (b *Core) Shutdown()

func (*Core) Stop

func (b *Core) Stop() (err error)

func (*Core) UpdateFlow

func (b *Core) UpdateFlow(flow *m.Flow) (err error)

func (*Core) UpdateFlowFromDevice

func (b *Core) UpdateFlowFromDevice(device *m.Device) (err error)

func (*Core) UpdateWorker

func (b *Core) UpdateWorker(_worker *m.Worker) (err error)

func (*Core) UpdateWorkflow

func (b *Core) UpdateWorkflow(workflow *m.Workflow) (err error)

func (*Core) UpdateWorkflowScenario

func (b *Core) UpdateWorkflowScenario(workflow *m.Workflow) (err error)

type Device

type Device struct {
	// contains filtered or unexported fields
}

func (*Device) ModBus added in v0.0.19

func (d *Device) ModBus(f string, address, count uint16, command []uint16) (result *DevModBusResponse)

func (*Device) RunCommand

func (d *Device) RunCommand(name string, args []string) (result *DevCommandResponse)

run command

func (*Device) SmartBus

func (d *Device) SmartBus(command []byte) (result *DevSmartBusResponse)

type DeviceBind

type DeviceBind struct {
	// contains filtered or unexported fields
}

Javascript Binding

Device

.getName()
.getModel()
.getDescription()
.runCommand(command []string)
.smartBus(command []byte)
.modBus(func string, address, count int64, command []byte)

func (*DeviceBind) GetDescription

func (d *DeviceBind) GetDescription() string

func (*DeviceBind) GetModel

func (d *DeviceBind) GetModel() *m.Device

func (*DeviceBind) GetName

func (d *DeviceBind) GetName() string

func (*DeviceBind) ModBus

func (d *DeviceBind) ModBus(f string, address, count uint16, command []uint16) (result *DevModBusResponse)

func (*DeviceBind) RunCommand

func (d *DeviceBind) RunCommand(name string, args []string) (result *DevCommandResponse)

func (*DeviceBind) SmartBus

func (d *DeviceBind) SmartBus(command []byte) (result *DevSmartBusResponse)

type Flow

type Flow struct {
	Storage
	Model *m.Flow

	Connections  []*m.Connection
	FlowElements []*FlowElement

	Node *Node

	Workers map[int64]*Worker

	sync.Mutex
	// contains filtered or unexported fields
}

func NewFlow

func NewFlow(model *m.Flow,
	workflow *Workflow,
	adaptors *adaptors.Adaptors,
	scripts *scripts.ScriptService,
	cron *cr.Cron,
	core *Core) (flow *Flow, err error)

func (*Flow) AddWorker

func (f *Flow) AddWorker(model *m.Worker) (err error)

func (*Flow) InitWorkers

func (f *Flow) InitWorkers() (err error)

func (*Flow) NewMessage

func (f *Flow) NewMessage(ctx context.Context) (err error)

func (*Flow) NewScript

func (f *Flow) NewScript(s ...*m.Script) (engine *scripts.Engine, err error)

func (*Flow) Remove

func (f *Flow) Remove()

func (*Flow) RemoveWorker

func (f *Flow) RemoveWorker(worker *m.Worker) (err error)

func (*Flow) UpdateWorker

func (f *Flow) UpdateWorker(worker *m.Worker) (err error)

type FlowBind

type FlowBind struct {
	// contains filtered or unexported fields
}

Javascript Binding

IC.Flow()

.getName()
.getDescription()
.setVar(string, interface)
.getVar(string)
.node()

func (*FlowBind) GetDescription

func (f *FlowBind) GetDescription() string

func (*FlowBind) GetName

func (f *FlowBind) GetName() string

func (*FlowBind) GetVar

func (f *FlowBind) GetVar(key string) interface{}

func (*FlowBind) Node

func (f *FlowBind) Node() *NodeBind

func (*FlowBind) SetVar

func (f *FlowBind) SetVar(key string, value interface{})

type FlowElement

type FlowElement struct {
	Model        *m.FlowElement
	Flow         *Flow
	Workflow     *Workflow
	ScriptEngine *scripts.Engine
	Prototype    ActionPrototypes

	Action *Action
	// contains filtered or unexported fields
}

func NewFlowElement

func NewFlowElement(model *m.FlowElement,
	flow *Flow,
	workflow *Workflow,
	adaptors *adaptors.Adaptors) (flowElement *FlowElement, err error)

func (*FlowElement) After

func (m *FlowElement) After(message *Message) error

func (*FlowElement) Before

func (m *FlowElement) Before(message *Message) error

func (*FlowElement) GetStatus

func (m *FlowElement) GetStatus() (status Status)

func (*FlowElement) Run

func (m *FlowElement) Run(ctx context.Context) (b bool, returnMessage *Message, err error)

run internal process

type FlowLink struct{}

ActionPrototypes

func (*FlowLink) After

func (m *FlowLink) After(message *Message, flow *Flow) (err error)

func (*FlowLink) Before

func (m *FlowLink) Before(message *Message, flow *Flow) (err error)

func (*FlowLink) Run

func (m *FlowLink) Run(message *Message, flow *Flow) (err error)

func (*FlowLink) Type

func (m *FlowLink) Type() string

type Gateway

type Gateway struct{}

ActionPrototypes

func (*Gateway) After

func (m *Gateway) After(message *Message, flow *Flow) (err error)

func (*Gateway) Before

func (m *Gateway) Before(message *Message, flow *Flow) (err error)

func (*Gateway) Run

func (m *Gateway) Run(message *Message, flow *Flow) (err error)

func (*Gateway) Type

func (m *Gateway) Type() string

type IGetMap

type IGetMap interface {
	GetMap() *Map
}

type Map

type Map struct {
	// contains filtered or unexported fields
}

func (*Map) GetAllElements

func (b *Map) GetAllElements() (elements []*MapElement)

func (*Map) GetDevicesStates

func (b *Map) GetDevicesStates() (states map[int64]*m.DashboardDeviceState)

func (*Map) GetElement

func (b *Map) GetElement(device *m.Device, elementName string) (element *MapElement)

func (*Map) GetElements

func (b *Map) GetElements(device *m.Device) (elements []*MapElement)

func (*Map) NewMapElement

func (b *Map) NewMapElement(device *m.Device, elementName string, state *m.DeviceState) *MapElement

func (*Map) SetElementState

func (b *Map) SetElementState(device *m.Device, elementName, systemName string)

type MapBind

type MapBind struct {
	Map *Map
}

Javascript Binding

map

.setElementState(device, elementName, newState)
.getElement(device, elementName) -> MapElementBind
.getElements(device) -> []MapElementBind

func (*MapBind) GetElement

func (e *MapBind) GetElement(device *DeviceBind, elementName string) (element *MapElementBind)

func (*MapBind) GetElements

func (e *MapBind) GetElements(device *DeviceBind) (elements []*MapElementBind)

func (*MapBind) SetElementState

func (e *MapBind) SetElementState(device *m.Device, elementName, newState string)

type MapElement

type MapElement struct {
	Map         *Map
	Options     interface{}
	Device      *m.Device
	State       *m.DeviceState
	ElementName string
}

func (*MapElement) GetOptions

func (e *MapElement) GetOptions() interface{}

func (*MapElement) GetState

func (e *MapElement) GetState() interface{}

func (*MapElement) SetOptions

func (e *MapElement) SetOptions(options interface{})

func (*MapElement) SetState

func (e *MapElement) SetState(systemName string)

type MapElementBind

type MapElementBind struct {
	// contains filtered or unexported fields
}

Javascript Binding

mapElement

.setState(name)
.getState()
.setOptions(options)
.getOptions()

func (*MapElementBind) GetOptions

func (e *MapElementBind) GetOptions() interface{}

func (*MapElementBind) GetState

func (e *MapElementBind) GetState() interface{}

func (*MapElementBind) SetOptions

func (e *MapElementBind) SetOptions(options interface{})

func (*MapElementBind) SetState

func (e *MapElementBind) SetState(name string)

type Message

type Message struct {
	Error string
	Storage
	Success   bool
	Direction bool
}

func NewMessage

func NewMessage() (m *Message)

func (*Message) Clear

func (m *Message) Clear()

func (*Message) Copy

func (m *Message) Copy() (msg *Message)

func (*Message) Ok

func (m *Message) Ok()

func (*Message) SetError

func (m *Message) SetError(err string)

func (*Message) Setdir

func (m *Message) Setdir(d bool)

type MessageEmitter

type MessageEmitter struct{}

ActionPrototypes

func (*MessageEmitter) After

func (m *MessageEmitter) After(message *Message, flow *Flow) (err error)

func (*MessageEmitter) Before

func (m *MessageEmitter) Before(message *Message, flow *Flow) (err error)

func (*MessageEmitter) Run

func (m *MessageEmitter) Run(message *Message, flow *Flow) (err error)

func (*MessageEmitter) Type

func (m *MessageEmitter) Type() string

type MessageHandler

type MessageHandler struct{}

ActionPrototypes

func (*MessageHandler) After

func (m *MessageHandler) After(message *Message, flow *Flow) (err error)

func (*MessageHandler) Before

func (m *MessageHandler) Before(message *Message, flow *Flow) (err error)

func (*MessageHandler) Run

func (m *MessageHandler) Run(message *Message, flow *Flow) (err error)

func (*MessageHandler) Type

func (m *MessageHandler) Type() string

type Node

type Node struct {
	*m.Node

	ConnStatus string

	sync.Mutex
	// contains filtered or unexported fields
}

func NewNode

func NewNode(model *m.Node,
	mqtt *mqtt.Mqtt) *Node

func (*Node) Connect

func (n *Node) Connect() *Node

func (*Node) Disconnect

func (n *Node) Disconnect()

func (*Node) IsConnected

func (n *Node) IsConnected() bool

func (*Node) Send

func (n *Node) Send(device *m.Device, command []byte) (result NodeResponse, err error)

type NodeBind

type NodeBind struct {
	// contains filtered or unexported fields
}

Javascript Binding

node

.name()
.status()
.stat()
.description()
.isConnected()

func (*NodeBind) Description

func (n *NodeBind) Description() string

func (*NodeBind) IsConnected

func (n *NodeBind) IsConnected() bool

func (*NodeBind) Name

func (n *NodeBind) Name() string

func (*NodeBind) Stat

func (n *NodeBind) Stat() *NodeStatModel

func (*NodeBind) Status

func (n *NodeBind) Status() string

type NodeMessage

type NodeMessage struct {
	DeviceId   int64             `json:"device_id"`
	DeviceType common.DeviceType `json:"device_type"`
	Properties json.RawMessage   `json:"properties"`
	Command    json.RawMessage   `json:"command"`
}

type NodeResponse

type NodeResponse struct {
	DeviceId   int64             `json:"device_id"`
	DeviceType common.DeviceType `json:"device_type"`
	Properties json.RawMessage   `json:"properties"`
	Response   json.RawMessage   `json:"response"`
	Status     string            `json:"status"`
	Time       float64           `json:"time"`
}

type NodeStatModel

type NodeStatModel struct {
	Status    NodeStatus `json:"status"`
	Thread    int        `json:"thread"`
	Rps       int64      `json:"rps"`
	Min       int64      `json:"min"`
	Max       int64      `json:"max"`
	StartedAt time.Time  `json:"started_at"`
}

type NodeStatus

type NodeStatus string

type Nodes

type Nodes []*Node

type Status

type Status string

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func NewStorage added in v0.0.17

func NewStorage() Storage

func (*Storage) GetVar

func (s *Storage) GetVar(key string) (value interface{})

func (*Storage) SetVar

func (s *Storage) SetVar(key string, value interface{})

type Task

type Task struct{}

ActionPrototypes

func (*Task) After

func (m *Task) After(message *Message, flow *Flow) (err error)

func (*Task) Before

func (m *Task) Before(message *Message, flow *Flow) (err error)

func (*Task) Run

func (m *Task) Run(message *Message, flow *Flow) (err error)

func (*Task) Type

func (m *Task) Type() string

type Worker

type Worker struct {
	Model *m.Worker

	CronTask *cr.Task

	sync.Mutex
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(model *m.Worker, flow *Flow, cron *cr.Cron) (worker *Worker)

func (*Worker) AddAction

func (w *Worker) AddAction(action *Action)

func (*Worker) Do

func (w *Worker) Do()

Run worker script, and send result to flow as message struct

func (*Worker) Start added in v0.0.17

func (w *Worker) Start()

func (*Worker) Stop added in v0.0.17

func (w *Worker) Stop()

type Workflow

type Workflow struct {
	Storage

	sync.Mutex

	Flows map[int64]*Flow
	// contains filtered or unexported fields
}

func NewWorkflow

func NewWorkflow(model *m.Workflow,
	adaptors *adaptors.Adaptors,
	scripts *scripts.ScriptService,
	cron *cr.Cron,
	core *Core) (workflow *Workflow)

func (*Workflow) AddFlow

func (wf *Workflow) AddFlow(flow *m.Flow) (err error)

Flow должен быть полный: с Connections с FlowElements с Cursor с Workers

func (*Workflow) GetFLow

func (wf *Workflow) GetFLow(flowId int64) (flow *Flow, err error)

func (*Workflow) NewScript

func (wf *Workflow) NewScript(model *m.Script) (engine *scripts.Engine, err error)

func (*Workflow) RemoveFlow

func (wf *Workflow) RemoveFlow(flow *m.Flow) (err error)

func (*Workflow) Restart

func (wf *Workflow) Restart() (err error)

func (*Workflow) Run

func (wf *Workflow) Run() (err error)

func (*Workflow) SetScenario

func (wf *Workflow) SetScenario(systemName string) (err error)

func (*Workflow) Stop

func (wf *Workflow) Stop() (err error)

func (*Workflow) UpdateFlow

func (wf *Workflow) UpdateFlow(flow *m.Flow) (err error)

func (*Workflow) UpdateScenario

func (wf *Workflow) UpdateScenario() (err error)

type WorkflowBind

type WorkflowBind struct {
	// contains filtered or unexported fields
}

Javascript Binding

IC.Workflow()

.getName()
.getDescription()
.setVar(string, interface)
.getVar(string)
.getScenario() string
.getScenarioName() string
.setScenario(string)

func (*WorkflowBind) GetDescription

func (w *WorkflowBind) GetDescription() string

func (*WorkflowBind) GetName

func (w *WorkflowBind) GetName() string

func (*WorkflowBind) GetScenario

func (w *WorkflowBind) GetScenario() string

func (*WorkflowBind) GetScenarioName

func (w *WorkflowBind) GetScenarioName() string

func (*WorkflowBind) GetVar

func (w *WorkflowBind) GetVar(key string) interface{}

func (*WorkflowBind) SetScenario

func (w *WorkflowBind) SetScenario(system_name string)

func (*WorkflowBind) SetVar

func (w *WorkflowBind) SetVar(key string, value interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL