-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated 0157-WebUI-Fix-WrongJSONQuotes WebUI patch to integrate more
JSON related quoting fixes and also modify the SysVar.* json methods to make sure that all these apply to system variable objects only and not generally to all objects throughout rega (programs, devices, etc.). This refs eq-3/occu#117 and eq-3/occu#118
- Loading branch information
Showing
13 changed files
with
541 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...nal/patches/occu/0157-WebUI-Fix-WrongJSONQuotes/occu/WebUI/www/api/methods/sysvar/get.tcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
## | ||
# SysVar.get | ||
# Liefert Detailinformationen zu einer Systemvariablen. | ||
# | ||
# Parameter: | ||
# id: [string] Id der betreffenden Systemvariablen | ||
# | ||
# Rückgabewert: [object] | ||
# Jedes Element ist ein Objekt mit den folgenden allgemeinen Feldern: | ||
# id : [string] Id der Systemvariable | ||
# name : [string] Bezeichnung der Systemvariable | ||
# type : [string] Datentyp | ||
# [LOGIC, LIST, NUMBER, ALARM, STRING] | ||
# value : [string] aktueller Wert | ||
# unit : [string] Maßeinheit | ||
# channelId : [string] Id des zugeordneten Kanals | ||
# (ungültig bei "0" und "65535") | ||
# isVisible : [bool] Gibt an, ob die Systemvariablen sichtbar ist | ||
# isLogged : [bool] Gibt an, ob Wertänderungen protokolliert werden | ||
# isInternal: [bool] Gibt an, ob die Systemvariable intern verwendet wird | ||
# | ||
# Zusätzliche Felder für type == LOGIC und type == ALARM: | ||
# valueName0: [string] Bezeichnung des Wertes 0 | ||
# valueName1: [string] Bezeichnung des Wertes 1 | ||
# | ||
# Zusätzliche Felder für type == LIST: | ||
# valueList: [string] Werteliste (Separator: ";") | ||
# | ||
# Zusätzliche Felder für type == NUMBER: | ||
# minValue : [number] minimaler Wert | ||
# maxValue : [number] maximaler Wert | ||
## | ||
|
||
set script { | ||
var sv = dom.GetObject(ID_SYSTEM_VARIABLES).Get(id); | ||
if (sv) | ||
{ | ||
var sv_type = "UNKNOWN"; | ||
if (sv.ValueSubType() == istAlarm ) { sv_type = "ALARM"; } | ||
if (sv.ValueSubType() == istBool ) { sv_type = "LOGIC"; } | ||
if (sv.ValueSubType() == istEnum ) { sv_type = "LIST"; } | ||
if (sv.ValueSubType() == istGeneric ) { sv_type = "NUMBER"; } | ||
if (sv.ValueSubType() == istChar8859) { sv_type = "STRING"; } | ||
|
||
WriteLine("ID {" # sv.ID() # "}"); | ||
WriteLine("NAME {" # sv.Name() # "}"); | ||
WriteLine("TYPE {" # sv_type # "}"); | ||
WriteLine("UNIT {" # sv.ValueUnit() # "}"); | ||
WriteLine("VALUE {" # sv.Value() # "}"); | ||
WriteLine("LOGGED {" # sv.DPArchive() # "}"); | ||
WriteLine("VISIBLE {" # sv.Visible() # "}"); | ||
WriteLine("INTERNAL {" # sv.Internal() # "}"); | ||
WriteLine("CHANNEL_ID {" # sv.Channel() # "}"); | ||
WriteLine("VALUE_MIN {" # sv.ValueMin() # "}"); | ||
WriteLine("VALUE_MAX {" # sv.ValueMax() # "}"); | ||
WriteLine("VALUE_LIST {" # sv.ValueList() # "}"); | ||
WriteLine("VALUE_NAME_0 {" # sv.ValueName0() # "}"); | ||
WriteLine("VALUE_NAME_1 {" # sv.ValueName1() # "}"); | ||
} | ||
} | ||
|
||
array set _sv_ [hmscript $script args] | ||
|
||
set type $_sv_(TYPE) | ||
|
||
set result "\{" | ||
append result "\"id\":[json_toString $_sv_(ID)]," | ||
append result "\"name\":[json_toString $_sv_(NAME)]," | ||
append result "\"type\":[json_toString $_sv_(TYPE)]," | ||
append result "\"unit\":[json_toString $_sv_(UNIT)]," | ||
append result "\"value\":[json_toString $_sv_(VALUE)]," | ||
append result "\"channelId\":[json_toString $_sv_(CHANNEL_ID)]," | ||
|
||
if { ("ALARM" == $type) || ("LOGIC" == $type) } then { | ||
append result "\"valueName0\":[json_toString $_sv_(VALUE_NAME_0)]," | ||
append result "\"valueName1\":[json_toString $_sv_(VALUE_NAME_1)]," | ||
} | ||
|
||
if { "LIST" == $type } then { | ||
append result "\"valueList\":[json_toString $_sv_(VALUE_LIST)]," | ||
} | ||
|
||
if { "NUMBER" == $type } then { | ||
append result "\"minValue\":[json_toString $_sv_(VALUE_MIN)]," | ||
append result "\"maxValue\":[json_toString $_sv_(VALUE_MAX)]," | ||
} | ||
|
||
append result "\"isLogged\":$_sv_(LOGGED)," | ||
append result "\"isVisible\":$_sv_(VISIBLE)," | ||
append result "\"isInternal\":$_sv_(INTERNAL)" | ||
append result "\}" | ||
|
||
jsonrpc_response $result |
93 changes: 93 additions & 0 deletions
93
...atches/occu/0157-WebUI-Fix-WrongJSONQuotes/occu/WebUI/www/api/methods/sysvar/get.tcl.orig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
## | ||
# SysVar.get | ||
# Liefert Detailinformationen zu einer Systemvariablen. | ||
# | ||
# Parameter: | ||
# id: [string] Id der betreffenden Systemvariablen | ||
# | ||
# R�ckgabewert: [object] | ||
# Jedes Element ist ein Objekt mit den folgenden allgemeinen Feldern: | ||
# id : [string] Id der Systemvariable | ||
# name : [string] Bezeichnung der Systemvariable | ||
# type : [string] Datentyp | ||
# [LOGIC, LIST, NUMBER, ALARM, STRING] | ||
# value : [string] aktueller Wert | ||
# unit : [string] Ma�einheit | ||
# channelId : [string] Id des zugeordneten Kanals | ||
# (ung�ltig bei "0" und "65535") | ||
# isVisible : [bool] Gibt an, ob die Systemvariablen sichtbar ist | ||
# isLogged : [bool] Gibt an, ob Wert�nderungen protokolliert werden | ||
# isInternal: [bool] Gibt an, ob die Systemvariable intern verwendet wird | ||
# | ||
# Zus�tzliche Felder f�r type == LOGIC und type == ALARM: | ||
# valueName0: [string] Bezeichnung des Wertes 0 | ||
# valueName1: [string] Bezeichnung des Wertes 1 | ||
# | ||
# Zus�tzliche Felder f�r type == LIST: | ||
# valueList: [string] Werteliste (Separator: ";") | ||
# | ||
# Zus�tzliche Felder f�r type == NUMBER: | ||
# minValue : [number] minimaler Wert | ||
# maxValue : [number] maximaler Wert | ||
## | ||
|
||
set script { | ||
var sv = dom.GetObject(id); | ||
if (sv) | ||
{ | ||
var sv_type = "UNKNOWN"; | ||
if (sv.ValueSubType() == istAlarm ) { sv_type = "ALARM"; } | ||
if (sv.ValueSubType() == istBool ) { sv_type = "LOGIC"; } | ||
if (sv.ValueSubType() == istEnum ) { sv_type = "LIST"; } | ||
if (sv.ValueSubType() == istGeneric ) { sv_type = "NUMBER"; } | ||
if (sv.ValueSubType() == istChar8859) { sv_type = "STRING"; } | ||
|
||
WriteLine("ID {" # sv.ID() # "}"); | ||
WriteLine("NAME {" # sv.Name() # "}"); | ||
WriteLine("TYPE {" # sv_type # "}"); | ||
WriteLine("UNIT {" # sv.ValueUnit() # "}"); | ||
WriteLine("VALUE {" # sv.Value() # "}"); | ||
WriteLine("LOGGED {" # sv.DPArchive() # "}"); | ||
WriteLine("VISIBLE {" # sv.Visible() # "}"); | ||
WriteLine("INTERNAL {" # sv.Internal() # "}"); | ||
WriteLine("CHANNEL_ID {" # sv.Channel() # "}"); | ||
WriteLine("VALUE_MIN {" # sv.ValueMin() # "}"); | ||
WriteLine("VALUE_MAX {" # sv.ValueMax() # "}"); | ||
WriteLine("VALUE_LIST {" # sv.ValueList() # "}"); | ||
WriteLine("VALUE_NAME_0 {" # sv.ValueName0() # "}"); | ||
WriteLine("VALUE_NAME_1 {" # sv.ValueName1() # "}"); | ||
} | ||
} | ||
|
||
array set _sv_ [hmscript $script args] | ||
|
||
set type $_sv_(TYPE) | ||
|
||
set result "\{" | ||
append result "\"id\":[json_toString $_sv_(ID)]," | ||
append result "\"name\":[json_toString $_sv_(NAME)]," | ||
append result "\"type\":[json_toString $_sv_(TYPE)]," | ||
append result "\"unit\":[json_toString $_sv_(UNIT)]," | ||
append result "\"value\":[json_toString $_sv_(VALUE)]," | ||
append result "\"channelId\":[json_toString $_sv_(CHANNEL_ID)]," | ||
|
||
if { ("ALARM" == $type) || ("LOGIC" == $type) } then { | ||
append result "\"valueName0\":[json_toString $_sv_(VALUE_NAME_0)]," | ||
append result "\"valueName1\":[json_toString $_sv_(VALUE_NAME_1)]," | ||
} | ||
|
||
if { "LIST" == $type } then { | ||
append result "\"valueList\":[json_toString $_sv_(VALUE_LIST)]," | ||
} | ||
|
||
if { "NUMBER" == $type } then { | ||
append result "\"minValue\":[json_toString $_sv_(VALUE_MIN)]," | ||
append result "\"maxValue\":[json_toString $_sv_(VALUE_MAX)]," | ||
} | ||
|
||
append result "\"isLogged\":$_sv_(LOGGED)," | ||
append result "\"isVisible\":$_sv_(VISIBLE)," | ||
append result "\"isInternal\":$_sv_(INTERNAL)" | ||
append result "\}" | ||
|
||
jsonrpc_response $result |
21 changes: 21 additions & 0 deletions
21
...atches/occu/0157-WebUI-Fix-WrongJSONQuotes/occu/WebUI/www/api/methods/sysvar/getvalue.tcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## | ||
# SysVar.getValue | ||
# Liefert den aktuellen Wert einer Systemvariablen. | ||
# | ||
# Parameter: | ||
# id: [string] Id der betreffenden Systemvariablen. | ||
# | ||
# Rückgabewert: [string] | ||
# Aktueller Wert der Systemvariablen. | ||
## | ||
|
||
set script { | ||
var sv = dom.GetObject(ID_SYSTEM_VARIABLES).Get(id); | ||
|
||
if (sv) | ||
{ | ||
Write(sv.Value()); | ||
} | ||
} | ||
|
||
jsonrpc_response [json_toString [hmscript $script args]] |
21 changes: 21 additions & 0 deletions
21
...s/occu/0157-WebUI-Fix-WrongJSONQuotes/occu/WebUI/www/api/methods/sysvar/getvalue.tcl.orig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## | ||
# SysVar.getValue | ||
# Liefert den aktuellen Wert einer Systemvariablen. | ||
# | ||
# Parameter: | ||
# id: [string] Id der betreffenden Systemvariablen. | ||
# | ||
# R�ckgabewert: [string] | ||
# Aktueller Wert der Systemvariablen. | ||
## | ||
|
||
set script { | ||
var sv = dom.GetObject(id); | ||
|
||
if (sv) | ||
{ | ||
Write(sv.Value()); | ||
} | ||
} | ||
|
||
jsonrpc_response [json_toString [hmscript $script args]] |
21 changes: 21 additions & 0 deletions
21
.../occu/0157-WebUI-Fix-WrongJSONQuotes/occu/WebUI/www/api/methods/sysvar/getvaluebyname.tcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## | ||
# SysVar.getValueByName | ||
# Ermittelt den Wert einer Systemvariable mit bestimmten Namen. | ||
# | ||
# Parameter: | ||
# name: [string] Name der Systemvariablen | ||
# | ||
# Rückgabewert: [string] | ||
# Wert der Systemvariablen. | ||
## | ||
|
||
|
||
set script { | ||
var sv = dom.GetObject(ID_SYSTEM_VARIABLES).Get(name); | ||
if (sv) | ||
{ | ||
Write(sv.Value()); | ||
} | ||
} | ||
|
||
jsonrpc_response [json_toString [hmscript $script args]] |
21 changes: 21 additions & 0 deletions
21
.../0157-WebUI-Fix-WrongJSONQuotes/occu/WebUI/www/api/methods/sysvar/getvaluebyname.tcl.orig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## | ||
# SysVar.getValueByName | ||
# Ermittelt den Wert einer Systemvariable mit bestimmten Namen. | ||
# | ||
# Parameter: | ||
# name: [string] Name der Systemvariablen | ||
# | ||
# R�ckgabewert: [string] | ||
# Wert der Systemvariablen. | ||
## | ||
|
||
|
||
set script { | ||
var sv = dom.GetObject(name); | ||
if (sv) | ||
{ | ||
Write(sv.Value()); | ||
} | ||
} | ||
|
||
jsonrpc_response [json_toString [hmscript $script args]] |
Oops, something went wrong.