@@ -168,6 +168,52 @@ function addDeviceToDeviceList(device, pinList, addManual){
168168 applyDeviceSettings ( device . nr ) ;
169169 } ) ;
170170
171+ // add actuator control buttons buttons
172+ if ( device . t == 5 ) // manual actuator
173+ {
174+ if ( device . h == 4 ) { // DS2408, used for values
175+ var $valveOpenButton = $ ( "<button class='apply'>Open</button>" ) ;
176+ $valveOpenButton . appendTo ( $nameAndApply ) ;
177+ $valveOpenButton . button ( { icons : { primary : "ui-icon-arrowthick-2-e-w" } } ) ;
178+ $valveOpenButton . click ( function ( ) {
179+ $ . post ( 'socketmessage.php' , {
180+ messageType : String ( "writeDevice" ) ,
181+ message : String ( '{"i": ' + device . i . toString ( ) + ',"w":1}' )
182+ } ) ;
183+ } ) ;
184+
185+ var $valveCloseButton = $ ( "<button class='apply'>Close</button>" ) ;
186+ $valveCloseButton . appendTo ( $nameAndApply ) ;
187+ $valveCloseButton . button ( { icons : { primary : "ui-icon-arrowthickstop-1-e" } } ) ;
188+ $valveCloseButton . click ( function ( ) {
189+ $ . post ( 'socketmessage.php' , {
190+ messageType : String ( "writeDevice" ) ,
191+ message : String ( '{"i": ' + device . i . toString ( ) + ',"w":2}' )
192+ } ) ;
193+ } ) ;
194+ }
195+ if ( device . h == 1 || device . h == 3 ) { // digital pin or DS2413
196+ var $onButton = $ ( "<button class='apply'>ON</button>" ) ;
197+ $onButton . appendTo ( $nameAndApply ) ;
198+ $onButton . button ( { icons : { primary : "ui-icon-radio-on" } } ) ;
199+ $onButton . click ( function ( ) {
200+ $ . post ( 'socketmessage.php' , {
201+ messageType : String ( "writeDevice" ) ,
202+ message : String ( '{"i": ' + device . i . toString ( ) + ',"w":1}' )
203+ } ) ;
204+ } ) ;
205+
206+ var $offButton = $ ( "<button class='apply'>OFF</button>" ) ;
207+ $offButton . appendTo ( $nameAndApply ) ;
208+ $offButton . button ( { icons : { primary : "ui-icon-radio-off" } } ) ;
209+ $offButton . click ( function ( ) {
210+ $ . post ( 'socketmessage.php' , {
211+ messageType : String ( "writeDevice" ) ,
212+ message : String ( '{"i": ' + device . i . toString ( ) + ',"w":0}' )
213+ } ) ;
214+ } ) ;
215+ }
216+ }
171217
172218
173219 var $settings = $ ( "<div class='device-all-settings'><div>" ) ;
@@ -258,9 +304,9 @@ function addDeviceToDeviceList(device, pinList, addManual){
258304
259305 if ( ( typeof device . n !== "undefined" ) ) {
260306 $settings . append ( generateDeviceSettingContainer (
261- "DS2413 pin " ,
262- "ds2413-pin " ,
263- generateSelect ( [ { val : 0 , text : 'pin 0 ' } , { val : 1 , text : 'pin 1 ' } ] , device . n ) ) ) ;
307+ "Output " ,
308+ "output-nr " ,
309+ generateSelect ( [ { val : 0 , text : 'Output A ' } , { val : 1 , text : 'Output B ' } ] , device . n ) ) ) ;
264310 }
265311 if ( ( typeof device . v !== "undefined" ) ) {
266312 var value = device . v ;
@@ -273,6 +319,15 @@ function addDeviceToDeviceList(device, pinList, addManual){
273319 value = "Active" ;
274320 }
275321 }
322+ if ( parseInt ( device . t , 10 ) === 5 ) {
323+ // Device type is valve/switch actuator
324+ if ( value === 0 ) {
325+ value = "Inactive" ;
326+ }
327+ else if ( value === 1 ) {
328+ value = "Active" ;
329+ }
330+ }
276331 if ( parseInt ( value , 10 ) === - 64 ) {
277332 value = "Disconnected" ;
278333 }
@@ -296,23 +351,25 @@ function findPinInList(pinList, pinNr){
296351function pinTypeToFunctionList ( pinType , hwType ) {
297352 "use strict" ;
298353 var functionList = [ ] ;
299- var actFunctions = [ 2 , 3 , 4 , 7 ] ;
354+ var actFunctions = [ 2 , 3 , 4 , 7 , 8 ] ;
300355
301356 switch ( pinType ) {
302357 case 'act' :
303358 functionList = actFunctions ; // all actuator functions
304359 break ;
305360 case 'free' :
306- functionList = [ 1 , 2 , 3 , 4 , 7 ] ; // all actuator functions + door
361+ functionList = [ 1 , 2 , 3 , 4 , 7 , 8 ] ; // all actuator functions + door
307362 break ;
308363 case 'onewire' :
309- if ( hwType !== 3 )
364+ if ( hwType == 2 )
310365 functionList = [ 5 , 6 , 9 ] ;
311- else
366+ else if ( hwType == 3 )
312367 functionList = actFunctions ; // ds2413 actuator
368+ else if ( hwType == 4 )
369+ functionList = [ 8 ] ; // ds2408 actuator
313370 break ;
314371 case 'door' :
315- functionList = [ 1 , 2 , 3 , 4 , 7 ] ; // all actuator functions + door
372+ functionList = [ 1 , 2 , 3 , 4 , 7 , 8 ] ; // all actuator functions + door
316373 break ;
317374 }
318375 return functionList ;
@@ -324,6 +381,7 @@ function functionToPinTypes(functionType){
324381 var pinTypes ;
325382 switch ( functionType ) {
326383 case 0 : // none
384+ case 8 : // Manual actuator
327385 pinTypes = [ 'free' , 'act' , 'onewire' , 'door' ] ;
328386 break ;
329387 case 1 : // door
@@ -340,6 +398,7 @@ function functionToPinTypes(functionType){
340398 case 9 : // beer temp
341399 pinTypes = [ 'onewire' ] ;
342400 break ;
401+
343402 default : // unknown function
344403 pinTypes = [ ] ;
345404 break ;
@@ -359,7 +418,7 @@ function getDeviceFunctionList(){
359418 { val : 5 , text : 'Chamber Temp' } ,
360419 { val : 6 , text : 'Room Temp' } ,
361420 { val : 7 , text : 'Chamber Fan' } ,
362- /* {val : 8, text: 'Chamber Reserved 1 '},*/
421+ { val : 8 , text : 'Manual Actuator ' } ,
363422 { val : 9 , text : 'Beer Temp' } /*,
364423 {val : 10, text: 'Beer Temperature 2'},
365424 {val : 11, text: 'Beer Heater'},
@@ -390,18 +449,21 @@ function getDeviceHwTypeList(){
390449 { val : 0 , text : 'None' } ,
391450 { val : 1 , text : 'Digital Pin' } ,
392451 { val : 2 , text : 'Temp Sensor' } ,
393- { val : 3 , text : 'DS2413' }
452+ { val : 3 , text : 'DS2413' } ,
453+ { val : 4 , text : 'DS2408/Valve' } ,
394454 ] ;
395455}
396456
397- function getDeviceTypeList ( ) {
457+ function getDeviceTypeList ( ) {
398458 "use strict" ;
399459 // currently unsupported/unused devices commented out
400460 return [
401- { val : 0 , text : 'None' } ,
402- { val : 1 , text : 'Temp Sensor' } ,
403- { val : 2 , text : 'Switch Sensor' } ,
404- { val : 3 , text : 'Switch Actuator' }
461+ { val : 0 , text : 'None' } ,
462+ { val : 1 , text : 'Temp Sensor' } ,
463+ { val : 2 , text : 'Switch Sensor' } ,
464+ { val : 3 , text : 'Switch Actuator' } ,
465+ { val : 4 , text : 'PWM Actuator' } ,
466+ { val : 5 , text : 'Manual Actuator' }
405467 ] ;
406468}
407469
@@ -418,7 +480,7 @@ function getLimitedPinList(pinList, pinTypes){
418480
419481function getDeviceSlotList ( ) {
420482 "use strict" ;
421- var maxDevices = 15 ;
483+ var maxDevices = 25 ;
422484 var list = [ { val : - 1 , text : 'Unassigned' } ] ;
423485 for ( var i = 0 ; i <= maxDevices ; i ++ ) {
424486 list . push ( { val : i , text : i . toString ( ) } ) ;
@@ -528,7 +590,7 @@ function getDeviceConfigString(deviceNr){
528590 }
529591 configString = addToConfigString ( configString , "x" , $deviceContainer . find ( ".pin-type select" ) . val ( ) ) ;
530592 configString = addToConfigString ( configString , "a" , $deviceContainer . find ( "span.onewire-address" ) . text ( ) ) ;
531- configString = addToConfigString ( configString , "n" , $deviceContainer . find ( ".ds2413-pin select" ) . val ( ) ) ;
593+ configString = addToConfigString ( configString , "n" , $deviceContainer . find ( ".output-nr select" ) . val ( ) ) ;
532594
533595 //configString = addToConfigString(configString,"d", 0); // hardwire deactivate for now
534596 //configString = addToConfigString(configString,"j", 0); // hardwire calibration for now
0 commit comments