Merge pull request #51 from rickcarlino/master

May 31st
pull/52/head
Rick Carlino 2014-05-31 10:39:27 -07:00
commit 3ef7b8bc37
7 changed files with 52 additions and 17 deletions

View File

@ -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

View File

@ -8,9 +8,7 @@
//= require angular/angular-route
//= require ng-rails-csrf
//= require farmbot_app/farmbot
//= require_tree ./farmbot_app/services
//= require_tree ./farmbot_app/controllers
//= require_tree ./farmbot_app
//bootstrap the alert box plugin
$(document).foundation('alert');

View File

@ -1,9 +1,28 @@
# 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'
'Restangular'
($scope, Restangular) ->
$scope.device = {}
'Skynet'
($scope, Restangular, Skynet) ->
Restangular.all('devices').getList().then (data) ->
$scope.devices = data
$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 = ->
uuid = $scope.device.uuid
message = {}
$scope.skynet.send(message, uuid)
$scope.connectToSkyNet = ->
creds =
uuid: $scope.myUuid
token: $scope.myToken
$scope.skynet = new Skynet(creds)
]

View File

@ -2,15 +2,33 @@
# cnxn = new Skynet(device.uuid, device.token, device.message)
Skynet = () ->
class Skynet
constructor: (uuid, token, callback) ->
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
]

View File

@ -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) ->

View File

@ -37,7 +37,7 @@
%br/
%ul.button-group.even-3
%li
%a.button.small{href: "#"} Jog to Home
%a.button.small{href: "", 'ng-click' => 'goHome()'} Jog to Home
%li
%a.button.small{href: "#"} Calibrate
%li

View File

@ -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')