device

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: BSD-3-Clause Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CommandRegistry = cli.NewCommandRegistry()
)
View Source
var DeviceFuncMap = template.FuncMap{

	"val": func(name string, value interface{}) map[string]interface{} {

		val := make(map[string]interface{}, 1)
		val[name] = value

		return val
	},

	"setting": func(ctx interface{}, key string) string {
		config := ctx.(WithSettings)
		return config.GetSetting(key)
	},

	"settingb": func(ctx interface{}, key string) bool {
		config := ctx.(WithSettings)
		val, _ := strconv.ParseBool(config.GetSetting(key))
		return val
	},

	"debug": func(ctx interface{}) bool {
		config := ctx.(WithSettings)
		debug := config.GetSetting("device:debug")
		return debug == "true"
	},
}

Functions

func BuildDevice

func BuildDevice(env Project, options *BuildOptions) (err error)

BuildDevice build the flogo application

func CreateDevice

func CreateDevice(project Project, deviceJson string, deviceDir string, deviceName string) error

CreateDevice creates an device project from the specified json device descriptor

func InstallContribution

func InstallContribution(project Project, path string, version string) error

InstallDependency install a dependency

func InstallLibs

func InstallLibs(project Project, libs []*Lib) error

func PrepareDevice

func PrepareDevice(project Project, options *PrepareOptions) (err error)

PrepareDevice do all pre-build setup and pre-processing

func RenderTemplate

func RenderTemplate(w io.Writer, tpl string, data interface{}) error

RenderFileTemplate renders the specified template

func UploadDevice

func UploadDevice(env Project) error

UploadDevice upload the device application

func Usage

func Usage()

Types

type ActionConfig

type ActionConfig struct {
	Id   string          `json:"id"`
	Ref  string          `json:"ref"`
	Data json.RawMessage `json:"data"`
}

Config is the configuration for the Action

type ActionContrib

type ActionContrib struct {
	Ref      string
	Template string
	// contains filtered or unexported fields
}

func LoadActionContrib

func LoadActionContrib(proj Project, ref string) (*ActionContrib, error)

func RegisterActionContrib

func RegisterActionContrib(ref string, tpl string) *ActionContrib

todo move to contrib contributions

func (*ActionContrib) GetActivities

func (ac *ActionContrib) GetActivities(tree *FlowTree) []*ActivityContrib

type ActivityActionConfig

type ActivityActionConfig struct {
	UseTriggerVal bool            `json:"useTriggerVal"`
	Activity      *ActivityConfig `json:"activity"`
}

todo hardcoded for now, should be generated from action-ref

type ActivityConfig

type ActivityConfig struct {
	Id         string            `json:"id"`
	Ref        string            `json:"ref"`
	Attributes map[string]string `json:"attributes"`
}

func (*ActivityConfig) GetSetting

func (ac *ActivityConfig) GetSetting(key string) string

type ActivityContrib

type ActivityContrib struct {
	Template   string
	Descriptor *ActivityDescriptor
}

func LoadActivityContrib

func LoadActivityContrib(proj Project, ref string) (*ActivityContrib, error)

func (*ActivityContrib) Libs

func (ac *ActivityContrib) Libs() []*Lib

type ActivityDescriptor

type ActivityDescriptor struct {
	*Descriptor

	Ref           string                  `json:"ref"`
	Libs          []*Lib                  `json:"libs"`
	Settings      []*Setting              `json:"settings"`
	DeviceSupport []*DeviceSupportDetails `json:"device_support"`
}

func ParseActivityDescriptor

func ParseActivityDescriptor(contribJson string) (contrib *ActivityDescriptor, err error)

ParseActivityDescriptor parse the device activity descriptor

type BuildOptions

type BuildOptions struct {
	*PrepareOptions

	SkipPrepare bool
}

type BuildPreProcessor

type BuildPreProcessor interface {
	PrepareForBuild(env Project) error
}

BuildPreProcessor interface for build pre-processors

type Descriptor

type Descriptor struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Description string `json:"description"`
	Type        string `json:"type"`
}

type DeviceDetails

type DeviceDetails struct {
	Profile     string            `json:"profile"`
	MqttEnabled bool              `json:"mqtt_enabled"`
	Settings    map[string]string `json:"settings"`

	Actions  []*ActionConfig  `json:"actions"`
	Triggers []*TriggerConfig `json:"triggers"`
}

FlogoAppDescriptor is the descriptor for a Flogo application

type DevicePlatform

type DevicePlatform struct {
	*Descriptor

	Framework    string             `json:"arduino"`
	MainTemplate string             `json:"main_template"`
	WifiDetails  []*PlatformFeature `json:"wifi"`
	MqttDetails  *PlatformFeature   `json:"mqtt"`
}

func GetDevicePlatform

func GetDevicePlatform(proj Project, ref string) (*DevicePlatform, error)

func ParseDevicePlatform

func ParseDevicePlatform(platformJson string) (*DevicePlatform, error)

ParseDeviceProfile parse the device platform

type DeviceProfile

type DeviceProfile struct {
	*Descriptor

	Board        string `json:"board"`
	Platform     string `json:"platform"`
	PlatformWifi string `json:"platform_wifi"`
}

func GetDeviceProfile

func GetDeviceProfile(proj Project, ref string) (*DeviceProfile, error)

func ParseDeviceProfile

func ParseDeviceProfile(profileJson string) (*DeviceProfile, error)

ParseDeviceProfile parse the device profile

type DeviceSupportDetails

type DeviceSupportDetails struct {
	Framework    string `json:"framework"`
	TemplateFile string `json:"template"`
}

type FlogoDeviceDescriptor

type FlogoDeviceDescriptor struct {
	*Descriptor

	Device   *DeviceDetails   `json:"device"`
	Actions  []*ActionConfig  `json:"actions"`
	Triggers []*TriggerConfig `json:"triggers"`
}

FlogoAppDescriptor is the descriptor for a Flogo application

func ParseDeviceDescriptor

func ParseDeviceDescriptor(deviceJson string) (*FlogoDeviceDescriptor, error)

ParseDeviceDescriptor parse the device descriptor

type FlowActionConfig

type FlowActionConfig struct {
	Flow map[string]interface{} `json:"flow"`
}

todo hardcoded for now, should be generated from action-ref

type FlowTree

type FlowTree struct {
	Id        string
	FirstTask *Task
	AllTasks  []*Task
}

type Lib

type Lib struct {
	Name    string `json:"name"`
	LibType string `json:"type"`
	Ref     string `json:"ref"`
}

type PioProject

type PioProject struct {
	RootDir         string
	LibDir          string
	SourceDir       string
	ContributionDir string
}

func (*PioProject) Build

func (*PioProject) Build() error

func (*PioProject) Clean

func (*PioProject) Clean() error

func (*PioProject) Create

func (p *PioProject) Create() error

func (*PioProject) GetContributionDir

func (p *PioProject) GetContributionDir() string

func (*PioProject) GetLibDir

func (p *PioProject) GetLibDir() string

func (*PioProject) GetRootDir

func (p *PioProject) GetRootDir() string

func (*PioProject) GetSourceDir

func (p *PioProject) GetSourceDir() string

func (*PioProject) Init

func (p *PioProject) Init(basePath string) error

func (*PioProject) InstallContribution

func (p *PioProject) InstallContribution(depPath string, version string) error

func (*PioProject) InstallLib

func (p *PioProject) InstallLib(name string, id int) error

func (*PioProject) Open

func (p *PioProject) Open() error

func (*PioProject) Setup

func (p *PioProject) Setup(board string) error

func (*PioProject) UninstallContribution

func (p *PioProject) UninstallContribution(depPath string) error

func (*PioProject) Upload

func (*PioProject) Upload() error

type PlatformFeature

type PlatformFeature struct {
	Name     string `json:"name"`
	Template string `json:"template"`
	Header   string `json:"header"`
	Libs     []*Lib `json:"libs"`
}

type PrepareOptions

type PrepareOptions struct {
	PreProcessor BuildPreProcessor
}

type Project

type Project interface {

	// GetRootDir get the root directory of the project
	GetRootDir() string

	// GetSourceDir get the source directory of the project
	GetSourceDir() string

	// GetLibDir get the lib directory of the project
	GetLibDir() string

	// GetContributionDir get the contribution directory of the project
	GetContributionDir() string

	// Init initializes the project settings an validates it requirements
	Init(path string) error

	// Create the project directory and its structure
	Create() error

	// Setup the project directory
	Setup(board string) error

	// Open the project directory and validate its structure
	Open() error

	InstallLib(name string, id int) error

	// InstallContribution install a contribution
	InstallContribution(path string, version string) error

	// UninstallContribution uninstall a contribution
	UninstallContribution(path string) error

	Build() error

	Upload() error

	Clean() error
}

func NewPlatformIoProject

func NewPlatformIoProject() Project

func SetupExistingProjectEnv

func SetupExistingProjectEnv(appDir string) Project

func SetupNewProjectEnv

func SetupNewProjectEnv() Project

type Setting

type Setting struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type SettingsConfig

type SettingsConfig struct {
	DeviceName string
	Id         string
	Settings   map[string]string
}

func (*SettingsConfig) GetSetting

func (s *SettingsConfig) GetSetting(key string) string

type Task

type Task struct {
	Id           int
	FlowId       string
	ActivityRef  string
	Attributes   map[string]string
	Precondition string
	NextTasks    []*Task
	// contains filtered or unexported fields
}

func (*Task) GetSetting

func (t *Task) GetSetting(key string) string

type TriggerConfig

type TriggerConfig struct {
	Id       string            `json:"id"`
	Ref      string            `json:"ref"`
	ActionId string            `json:"actionId"`
	Settings map[string]string `json:"settings"`
}

TriggerConfig is the configuration for a Trigger

func (*TriggerConfig) GetSetting

func (tc *TriggerConfig) GetSetting(key string) string

type TriggerContrib

type TriggerContrib struct {
	Template   string
	Descriptor *TriggerDescriptor
}

func LoadTriggerContrib

func LoadTriggerContrib(proj Project, ref string) (*TriggerContrib, error)

func (*TriggerContrib) Libs

func (tc *TriggerContrib) Libs() []*Lib

type TriggerDescriptor

type TriggerDescriptor struct {
	*Descriptor

	Ref           string                  `json:"ref"`
	Libs          []*Lib                  `json:"libs"`
	Settings      []*Setting              `json:"settings"`
	Outputs       []*Setting              `json:"outputs"`
	DeviceSupport []*DeviceSupportDetails `json:"device_support"`
}

func ParseTriggerDescriptor

func ParseTriggerDescriptor(contribJson string) (contrib *TriggerDescriptor, err error)

ParseTriggerDescriptor parse the device trigger descriptor

type WithSettings

type WithSettings interface {
	GetSetting(key string) string
}

Jump to

Keyboard shortcuts

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