Skip to content

Commit

Permalink
add HB-ES-PMSw1-USB
Browse files Browse the repository at this point in the history
  • Loading branch information
jp112sdl committed Mar 7, 2021
1 parent 0a1fc45 commit 9a7de81
Show file tree
Hide file tree
Showing 6 changed files with 898 additions and 0 deletions.
724 changes: 724 additions & 0 deletions src/addon/firmware/rftypes/hb-es-pmsw1-usb.xml

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions src/addon/install_hb-es-pmsw1-usb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

DEVICE="HB-ES-PMSw1-USB"
DEVICE_IMG=hb-es-pmsw1-usb.png
DEVICE_THUMB=hb-es-pmsw1-usb_thumb.png
DEVICE_DESC="homebrew power meter switch actuator 1-channel for USB"

### Edit DEVDB.tcl ###
devdescrFile="/www/config/devdescr/DEVDB.tcl"
devdescrSearch="array[[:space:]]*set[[:space:]]*DEV_PATHS[[:space:]]*{"

devdescrInsert="$DEVICE {{50 \/config\/img\/devices\/50\/$DEVICE_THUMB} {250 \/config\/img\/devices\/250\/$DEVICE_IMG}} "

if [ -z "`cat $devdescrFile | grep \"$DEVICE\"`" ]; then
sed -i "s/\($devdescrSearch\)/\1$devdescrInsert/g" $devdescrFile
fi

### Edit webui.js ###
webuiFile="/www/webui/webui.js"

webuiSearchBegin="DEV_HIGHLIGHT[[:space:]]*=[[:space:]]*new Array();"
webuiInsert="\n"
webuiInsert="${webuiInsert}DEV_HIGHLIGHT['$DEVICE'] = new Object();\n"
webuiInsert="${webuiInsert}DEV_LIST.push('$DEVICE');\n"
webuiInsert="${webuiInsert}DEV_DESCRIPTION['$DEVICE']='$DEVICE_DESC';\n"
webuiInsert="${webuiInsert}DEV_PATHS['$DEVICE'] = new Object();\n"
webuiInsert="${webuiInsert}DEV_PATHS['$DEVICE']['50'] = '\/config\/img\/devices\/50\/$DEVICE_THUMB';\n"
webuiInsert="${webuiInsert}DEV_PATHS['$DEVICE']['250'] = '\/config\/img\/devices\/250\/$DEVICE_IMG';"

if [ -z "`cat $webuiFile | grep \"$DEVICE\"`" ]; then
sed -i "s/\($webuiSearchBegin\)/\1$webuiInsert/g" $webuiFile
fi
17 changes: 17 additions & 0 deletions src/addon/uninstall_hb-es-pmsw1-usb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

DEVICE="HB-ES-PMSw1-USB"
DEVICE_IMG=hb-es-pmsw1-usb.png
DEVICE_THUMB=hb-es-pmsw1-usb_thumb.png
FIRMWARE_FILE=/firmware/rftypes/hb-es-pmsw1-usb.xml

devdescrFile="/www/config/devdescr/DEVDB.tcl"
devdescrSearch="$DEVICE {{50 \/config\/img\/devices\/50\/$DEVICE_THUMB} {250 \/config\/img\/devices\/250\/$DEVICE_IMG}} "
sed -i "s/\($devdescrSearch\)//g" $devdescrFile

webuiFile="/www/webui/webui.js"
sed -i "/\($DEVICE\)/d" $webuiFile

rm -f $FIRMWARE_FILE
rm -f /www/config/img/devices/250/$DEVICE_IMG
rm -f /www/config/img/devices/50/$DEVICE_THUMB
125 changes: 125 additions & 0 deletions src/addon/www/config/easymodes/hb_power_ch_master.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/bin/tclsh

source [file join $env(DOCUMENT_ROOT) config/easymodes/em_common.tcl]

proc getUnit {psDescr param} {
upvar psDescr descr
array_clear param_descr
array set param_descr $descr($param)
set unit $param_descr(UNIT)

if {$unit == "minutes"} {
set unit "\${lblMinutes}"
}

if {$unit == "K"} {
set unit "°C"
}

return "$unit"
}

proc getMinMaxValueDescr {psDescr param} {
upvar psDescr descr
array_clear param_descr
array set param_descr $descr($param)
set min $param_descr(MIN)
set max $param_descr(MAX)

# Limit float to 2 decimal places
if {[llength [split $min "."]] == 2} {
set min [format {%1.2f} $min]
set max [format {%1.2f} $max]
}
return "($min - $max)"
}

proc getTextField {type param value inputId} {
set elemId '$inputId'
# Limit float to 2 decimal places
if {[llength [split $value "."]] == 2} {
set value [format {%1.2f} $value]
}

set s "<input id=$elemId type=\"text\" size=\"5\" value=$value name=$param/>"
return $s
}

proc getComboBox {param prn special_input_id} {
global psDescr
upvar ps ps
set CHANNEL "CHANNEL"

array_clear options
set options(0) "\${stringTableNotUsed}"
set options($ps($param)) "\${optionEnterValue}"


append s "<td>"
append s "[get_ComboBox options $param option_${special_input_id}_$prn ps $param "onchange=\";document.getElementById('field_$prn').style.visibility=(this.selectedIndex < 1)?'hidden':'visible';document.getElementById('separate_CHANNEL_2_$prn').value=parseFloat(this.options\[this.selectedIndex\].value);\""]"
append s "</td>"
append s "<td><span id=\"field_$prn\">[getTextField $CHANNEL '$param' $ps($param) separate_${special_input_id}_$prn]&nbsp;[getUnit psDescr $param]&nbsp;[getMinMaxValueDescr psDescr $param]</span></td>"
append s "<script type=\"text/javascript\">"
append s "if ($ps($param) > 0) {document.getElementById('option_CHANNEL_2_$prn').options\[1\].selected = true;document.getElementById('field_$prn').style.visibility='visible';} else {document.getElementById('option_CHANNEL_2_$prn').options\[0\].selected = true;document.getElementById('field_$prn').style.visibility='hidden';}"
append s "</script>"
return $s
}

catch {unset internalKey}

proc set_htmlParams {iface address pps pps_descr special_input_id peer_type} {

global env iface_url psDescr

#upvar PROFILES_MAP PROFILES_MAP
upvar HTML_PARAMS HTML_PARAMS
#upvar PROFILE_PNAME PROFILE_PNAME
upvar $pps ps
upvar $pps_descr ps_descr

set CHANNEL "CHANNEL"

array set psDescr [xmlrpc $iface_url($iface) getParamsetDescription [list string $address] [list string MASTER]]

append HTML_PARAMS(separate_1) "<table class=\"ProfileTbl\">"

append HTML_PARAMS(separate_1) "<tr><td colspan='2'><b>\${PMSwChannel2Header}<b/><br/><br/></td></tr>"

set prn 1
set param AVERAGING
append HTML_PARAMS(separate_1) "<tr>"
append HTML_PARAMS(separate_1) "<td>\${PMSwAveraging}</td>"
append HTML_PARAMS(separate_1) "<td>[getTextField $CHANNEL '$param' $ps($param) separate_${special_input_id}_$prn]&nbsp;[getUnit psDescr $param]&nbsp;[getMinMaxValueDescr psDescr $param]</td>"
append HTML_PARAMS(separate_1) "</tr>"

append HTML_PARAMS(separate_1) "<tr><td colspan='2'><br/><br/>\${PMSwChannel2HintHeader}</td></tr>"

incr prn
set param TX_THRESHOLD_CURRENT
append HTML_PARAMS(separate_1) "<tr>"
append HTML_PARAMS(separate_1) "<td>\${PMSwChannel2Hint_Current}</td>"
append HTML_PARAMS(separate_1) [getComboBox $param $prn $special_input_id]
append HTML_PARAMS(separate_1) "</tr>"

incr prn
set param TX_THRESHOLD_VOLTAGE
append HTML_PARAMS(separate_1) "<tr>"
append HTML_PARAMS(separate_1) "<td>\${PMSwChannel2Hint_Voltage}</td>"
append HTML_PARAMS(separate_1) [getComboBox $param $prn $special_input_id]
append HTML_PARAMS(separate_1) "</tr>"

append HTML_PARAMS(separate_1) "<tr><td>\${PMSwChannel2Hint_Footer}<br/><br/></td></tr>"

incr prn
set param TX_MINDELAY
append HTML_PARAMS(separate_1) "<tr>"
append HTML_PARAMS(separate_1) "<td>\${PMSwChannel2MinDelay}</td>"
append HTML_PARAMS(separate_1) "<td>[getTextField $CHANNEL '$param' $ps($param) separate_${special_input_id}_$prn]&nbsp;[getUnit psDescr $param]&nbsp;[getMinMaxValueDescr psDescr $param]</td>"
append HTML_PARAMS(separate_1) "</tr>"

append HTML_PARAMS(separate_1) "</table>"
}

constructor


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9a7de81

Please sign in to comment.