More Skynet integration
commit
9e4e5dc213
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Farmbot Decision Support System
|
||||
|
||||
This Repo is the Web based side of the decision support system. It is the glue that ties together all other farmbot components and services.
|
||||
This Repo is the Web based side of the decision support system. It is the glue that ties together all other farmbot components and services. **ITS NOT STABLE. WE ARE IN PRE ALPHA.**
|
||||
|
||||
# Developer setup
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# The overview controller provides an indepth view of a device as well as fine-
|
||||
# grained controll options.
|
||||
# grained controll options. Needs a better name.
|
||||
|
||||
#TODO: Indicator that lets user see Skynet connection status.
|
||||
|
||||
angular.module('FarmBot').controller "OverviewController", [
|
||||
'$scope'
|
||||
|
@ -8,7 +10,19 @@ angular.module('FarmBot').controller "OverviewController", [
|
|||
($scope, Restangular, Skynet) ->
|
||||
Restangular.all('devices').getList().then (data) ->
|
||||
$scope.devices = data
|
||||
$scope.device = #new Skynet(dvc.uuid, dvc.token)
|
||||
$scope.device = data[0]
|
||||
# DANGER, WARNING! Insecure code below. Just goofing around
|
||||
# before launch. This MUST be replaced.
|
||||
$scope.myUuid = "4bb4a961-e8e6-11e3-93f8-f3e7e8d1cce9"
|
||||
$scope.myToken = "jce90gf7szxxyldihii1m3xv5d9jatt9"
|
||||
$scope.connectToSkyNet()
|
||||
$scope.goHome = ->
|
||||
debugger
|
||||
uuid = $scope.device.uuid
|
||||
message = {}
|
||||
$scope.skynet.send(message, uuid)
|
||||
$scope.connectToSkyNet = ->
|
||||
creds =
|
||||
uuid: $scope.myUuid
|
||||
token: $scope.myToken
|
||||
$scope.skynet = new Skynet(creds)
|
||||
]
|
||||
|
|
|
@ -2,15 +2,33 @@
|
|||
# cnxn = new Skynet(device.uuid, device.token, device.message)
|
||||
Skynet = () ->
|
||||
class Skynet
|
||||
constructor: (uuid, token) ->
|
||||
config =
|
||||
uuid: uuid
|
||||
token: token
|
||||
constructor: ({@uuid, @token}) ->
|
||||
@config =
|
||||
uuid: @uuid
|
||||
token: @token
|
||||
type: "farmbot"
|
||||
protocol: "websocket"
|
||||
send: (message) ->
|
||||
|
||||
skynet @config, (e, socket) =>
|
||||
throw e if e
|
||||
@socket = socket
|
||||
socket.on "message", (message) =>
|
||||
console.log "message received", message
|
||||
@parse(message)
|
||||
|
||||
send: (message, uuid) ->
|
||||
|
||||
envelope =
|
||||
devices: uuid
|
||||
payload: message
|
||||
|
||||
callback = (data) -> parse(data)
|
||||
|
||||
@socket.emit "message", envelope, callback
|
||||
|
||||
parse: (message) ->
|
||||
debugger
|
||||
|
||||
angular.module('FarmBot').service 'Skynet',[
|
||||
Skynet
|
||||
]
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ window.fake_message2 =
|
|||
window.start_skynet = ->
|
||||
device = prompt 'Which device are you using? 1 or 2'
|
||||
device = eval("device#{device}")
|
||||
skynet device, (e, socket) ->
|
||||
skynet config, (e, socket) ->
|
||||
throw e if e
|
||||
window.skynet_socket = socket
|
||||
socket.on "message", (message) ->
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
%li{class: ("active" if current_page? page_path('dashboard'))}
|
||||
= link_to 'STUB', page_path('dashboard')
|
||||
%li{class: ("active" if current_page? page_path('#/settings'))}
|
||||
= link_to 'Device Overview', '/dashboard#/overview'
|
||||
= link_to 'Control', '/dashboard#/overview'
|
||||
// TODO: Add CSS rul based on hash fragment.
|
||||
%li{class: ("active" if current_page? page_path('#/settings'))}
|
||||
= link_to 'Device Settings', '/dashboard#/settings'
|
||||
= link_to 'Settings', '/dashboard#/settings'
|
||||
%li{class: ("active" if current_page? page_path('help'))}
|
||||
= link_to 'Help', page_path('help')
|
||||
|
||||
|
|
Loading…
Reference in New Issue