command

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

README

EdgeX Foundry Core Command Service

license

Command Service is the conduit for other services to trigger action on devices/sensors via there managing device services. The service provides an API to get the list of commands that can be issued for all devices or a single device. Commands are divided into to groups for each device: Gets and Puts. Get commands are issued to a device/sensor get a current value for a particular attribute on the device (like the current temperature offered by a thermostat sensor, or like the on/off status of a light). Put commands are issued to a device/sensor to change the current state or status of a device or one of its attributes (like setting the speed in RPMs of a motor or setting the brightness of a dimmer light).

Install and Deploy Native

Prerequisites

Serveral EdgeX Foundry services depend on ZeroMQ for communications by default. The easiest way to get and install ZeroMQ is to use or follow the following setup script: https://gist.github.com/katopz/8b766a5cb0ca96c816658e9407e83d00.

Note: Setup of the ZeroMQ library is not supported on Windows plaforms.

Installation and Execution

To fetch the code and build the microservice execute the following:

cd $GOPATH/src
go get github.com/edgexfoundry/edgex-go
cd $GOPATH/src/github.com/edgexfoundry/edgex-go
# pull the 3rd party / vendor packages
make prepare
# build the microservice
make cmd/core-command/core-command
# get to the command microservice executable
cd cmd/core-command
# run the microservice (may require other dependent services to run correctly)
./core-command

Install and Deploy via Docker Container

This project has facilities to create and run Docker containers. A Dockerfile is included in the repo. Make sure you have already run make prepare to update the dependecies. To do a Docker build using the included Docker file, run the following:

Prerequisites

See https://docs.docker.com/install/ to learn how to obtain and install Docker.

Installation and Execution
cd $GOPATH/src
go get github.com/edgexfoundry/edgex-go
cd $GOPATH/src/github.com/edgexfoundry/edgex-go
# To create the Docker image
sudo make docker_core_command
# To create a containter from the image
sudo docker create --name "[DOCKER_CONTAINER_NAME]" --network "[DOCKER_NETWORK]" [DOCKER_IMAGE_NAME]
# To run the container
sudo docker start [DOCKER_CONTAINER_NAME]

Note - creating and running the container above requires Docker network setup, may require dependent containers to be setup on that network, and appropriate port access configuration (among other start up parameters). For this reason, EdgeX recommends use of Docker Compose for pulling, building, and running containers. See The Getting Started Guides for more detail.

Community

License

Apache-2.0

Documentation

Overview

******************************************************************************

  • Copyright 2018 Dell Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

******************************************************************************

  • Copyright 2018 Dell Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

******************************************************************************

  • Copyright 2017 Dell Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

******************************************************************************

  • Copyright 2019 Dell Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

******************************************************************************

  • Copyright 2017 Dell Inc.
  • Copyright (c) 2019 Intel Corporation *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

******************************************************************************

  • Copyright 2019 Dell Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

******************************************************************************

  • Copyright 2019 Dell Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

******************************************************************************

  • Copyright 2017 Dell Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

******************************************************************************

  • Copyright 2018 Dell Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

******************************************************************************

  • Copyright 2019 Dell Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

Index

Constants

View Source
const (
	ID               = "id"
	NAME             = "name"
	DEVICEIDURLPARAM = "{deviceId}"
	OPSTATE          = "opstate"
	URLADMINSTATE    = "adminstate"
	ADMINSTATE       = "adminState"
	YAML             = "yaml"
	COMMAND          = "command"
	COMMANDID        = "commandid"
	COMMANDNAME      = "commandname"
	DEVICE           = "device"
	KEY              = "key"
	VALUE            = "value"
	PINGRESPONSE     = "pong"
	CONTENTTYPE      = "Content-Type"
	TEXTPLAIN        = "text/plain"
	UNLOCKED         = "UNLOCKED"
	ENABLED          = "ENABLED"
)
View Source
const DefaultErrorCode = 0

DefaultErrorCode the default value used when an error has occurred and no response code was received.

Variables

View Source
var LoggingClient logger.LoggingClient

Functions

func Destruct added in v1.0.0

func Destruct()

func Init added in v1.0.0

func Init(useRegistry bool) bool

func LoadRestRoutes added in v1.0.0

func LoadRestRoutes() http.Handler

func Retry added in v1.0.0

func Retry(useRegistry bool, useProfile string, timeout int, wait *sync.WaitGroup, ch chan error)

Types

type ConfigurationStruct added in v1.0.0

type ConfigurationStruct struct {
	Writable  WritableInfo
	Clients   map[string]config.ClientInfo
	Databases map[string]config.DatabaseInfo
	Logging   config.LoggingInfo
	Registry  config.RegistryInfo
	Service   config.ServiceInfo
}
var Configuration *ConfigurationStruct

type ErrDeviceLocked added in v1.0.0

type ErrDeviceLocked struct{}

ErrDeviceLocked error indicating the locked state of a device

func (ErrDeviceLocked) Error added in v1.0.0

func (ErrDeviceLocked) Error() string

type Executor

type Executor interface {
	Execute() (string, int, error)
}

Executor interface used to execute commands

func NewGetCommand

func NewGetCommand(device contract.Device, command contract.Command, context context.Context, httpCaller internal.HttpCaller) (Executor, error)

NewGetCommand creates and Executor which can be used to execute the GET related command.

func NewPutCommand

func NewPutCommand(device contract.Device, command contract.Command, body string, context context.Context, httpCaller internal.HttpCaller) (Executor, error)

NewPutCommand creates and Executor which can be used to execute the PUT related command.

type WritableInfo added in v1.0.0

type WritableInfo struct {
	LogLevel string
}

Jump to

Keyboard shortcuts

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