WIP on device
This commit is contained in:
parent
f2e90634c5
commit
af4636598a
|
@ -9,10 +9,20 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = class Device
|
module.exports = class Device
|
||||||
constructor: (opts) ->
|
constructor: (opts = {}) ->
|
||||||
|
@parent = opts.parent
|
||||||
@name = opts.name
|
@name = opts.name
|
||||||
@driver = opts.driver
|
@connection = @determineConnection(opts.connection) or @defaultConnection
|
||||||
|
@driver = @requireDriver(opts.driver)
|
||||||
|
|
||||||
start: ->
|
start: ->
|
||||||
console.log "started"
|
console.log "started"
|
||||||
|
|
||||||
|
determineConnection: (c) ->
|
||||||
|
@parent.connections(c) if c
|
||||||
|
|
||||||
|
defaultConnection: ->
|
||||||
|
@parent.connections.first
|
||||||
|
|
||||||
|
requireDriver: (driverName) ->
|
||||||
|
console.log "dynamic load driver"
|
||||||
|
|
|
@ -8,7 +8,5 @@ describe "devices", ->
|
||||||
it "should have a name", ->
|
it "should have a name", ->
|
||||||
device.name.should.be.equal 'devisive'
|
device.name.should.be.equal 'devisive'
|
||||||
|
|
||||||
it "should have an driver", ->
|
it "should have a connection"
|
||||||
device.driver.should.be.equal 'driving'
|
it "should have an driver"
|
||||||
|
|
||||||
it "should be able to require an external driver module"
|
|
||||||
|
|
Loading…
Reference in New Issue