prevalue_set.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <!DOCTYPE html>
  2. <html lang="en" xml:lang="en">
  3. <head>
  4. <title>Set PreValue</title>
  5. <meta charset="UTF-8" />
  6. <style>
  7. h1 {font-size: 2em;}
  8. h2 {font-size: 1.5em; margin-block-start: 0.0em; margin-block-end: 0.2em;}
  9. h3 {font-size: 1.2em;}
  10. p {font-size: 1em;}
  11. div {
  12. padding: 3px 5px;
  13. display: inline-block;
  14. border: 1px solid #ccc;
  15. font-size: 16px;
  16. height: 20px;
  17. width: 120px;
  18. vertical-align: middle;
  19. }
  20. input[type=number] {
  21. width: 120px;
  22. margin-right: 10px;
  23. padding: 3px 5px;
  24. display: inline-block;
  25. border: 1px solid #ccc;
  26. font-size: 16px;
  27. }
  28. .invalid-input {
  29. background-color: #FFAA00;
  30. }
  31. th, td {
  32. padding: 5px 5px 5px 0px;
  33. }
  34. select {
  35. padding: 3px 5px;
  36. display: inline-block;
  37. border: 1px solid #ccc;
  38. font-size: 16px;
  39. margin-right: 10px;
  40. min-width: 100px;
  41. vertical-align: middle;
  42. }
  43. .button {
  44. padding: 5px 10px;
  45. width: 205px;
  46. font-size: 16px;
  47. }
  48. table {
  49. width: 660px;
  50. padding: 5px;
  51. }
  52. </style>
  53. </head>
  54. <body style="font-family: arial; padding: 0px 10px;">
  55. <h2>Set "Previous Value"</h2>
  56. <details id="desc_details">
  57. <summary><b>CLICK HERE</b> for usage description. More infos in documentation:
  58. <a href=https://jomjol.github.io/AI-on-the-edge-device-docs/FAQs/#pre-value target=_blank>"Previous Value"</a>
  59. </summary>
  60. <p>
  61. Set the "previous value" for consistency checks and substitution for NaN
  62. </p>
  63. <p>
  64. Previous value is a bit missleading, because normally it is the last valid value but not always the value of the previous round.
  65. The result of the the new round, as long it's a vaild result, will be promoted to the new "previous value". If the result is not usable the
  66. "previous value" will not be updated.
  67. If activated in configuration, the "previous value" will be used in the following round to check negtive rates, high rates
  68. (MaxRateValue / MaxRateType) and for the option "Check Digit Increase Consistency" (configuration paramter, only for dig-class11 models).
  69. </p>
  70. <p>
  71. The field to enter new "previous value" is prefilled with actual "raw value" because it's the most likely use case. Nevertheless every other
  72. positive value can be set as new "previous value".
  73. </p>
  74. </details>
  75. <hr />
  76. <table>
  77. <colgroup>
  78. <col span="1" style="width: 35.0%;">
  79. <col span="1" style="width: 65.0%;">
  80. </colgroup>
  81. <tr>
  82. <td style="height: 40px;">
  83. <class id="Numbers_text" style="color:black;">Number sequence:</class>
  84. </td>
  85. <td>
  86. <select id="Numbers_value1" onchange="numberChanged()"></select>
  87. </td>
  88. </tr>
  89. </table>
  90. <hr />
  91. <table>
  92. <colgroup>
  93. <col span="1" style="width: 35%;">
  94. <col span="1" style="width: 65%;">
  95. </colgroup>
  96. <tr>
  97. <td>Current "previous value":</td>
  98. <td>
  99. <div style="padding-left:5px" id="prevalue"></div>
  100. </td>
  101. </tr>
  102. <tr>
  103. <td style="vertical-align: text-top; padding-top: 12px;">Enter new "previous value":</td>
  104. <td>
  105. <input required type="number" id="myInput" name="myInput" min="0" oninput="(!validity.rangeUnderflow||(value=0));">
  106. <button class="button" type="button" onclick="setprevalue()">Update Value</button>
  107. <p style="padding-left: 5px;">NOTE: The current "raw value" is prefilled as
  108. <br>the suggested new "previous value"</p>
  109. </td>
  110. </tr>
  111. <tr>
  112. <td id="result_text">"Previous value" updated to:</td>
  113. <td>
  114. <div id="result" style="padding-left:5px;"></div>
  115. </td>
  116. </tr>
  117. </table>
  118. </body>
  119. </html>
  120. <link href="firework.css?v=$COMMIT_HASH" rel="stylesheet">
  121. <script type="text/javascript" src="jquery-3.6.0.min.js?v=$COMMIT_HASH"></script>
  122. <script type="text/javascript" src="firework.js?v=$COMMIT_HASH"></script>
  123. <script type="text/javascript" src="common.js?v=$COMMIT_HASH"></script>
  124. <script type="text/javascript" src="readconfigcommon.js?v=$COMMIT_HASH"></script>
  125. <script type="text/javascript" src="readconfigparam.js?v=$COMMIT_HASH"></script>
  126. <script type="text/javascript">
  127. var domainname = getDomainname();
  128. var NUMBERS;
  129. function setprevalue() {
  130. var inputVal = document.getElementById("myInput").value;
  131. var sel = document.getElementById("Numbers_value1");
  132. var _number = sel.options[sel.selectedIndex].text;
  133. inputVal = inputVal.replace(",", ".");
  134. var xhttp = new XMLHttpRequest();
  135. try {
  136. url = domainname + "/setPreValue?value=" + inputVal + "&numbers=" + _number;
  137. xhttp.open("GET", url, false);
  138. xhttp.send();
  139. response = xhttp.responseText;
  140. document.getElementById("result").innerHTML=response;
  141. firework.launch('New \"previous value\" set', 'success', 5000);
  142. }
  143. catch (error)
  144. {
  145. firework.launch('Failed to get data from device!', 'danger', 30000);
  146. }
  147. }
  148. function loadPrevalue(_domainname) {
  149. // Get current Pre Value
  150. var sel = document.getElementById("Numbers_value1");
  151. var _number = sel.options[sel.selectedIndex].text;
  152. var xhttp = new XMLHttpRequest();
  153. try {
  154. url = _domainname + '/setPreValue?numbers=' + _number;
  155. xhttp.open("GET", url, false);
  156. xhttp.send();
  157. response = xhttp.responseText;
  158. document.getElementById("prevalue").innerHTML=response;
  159. }
  160. catch (error)
  161. {
  162. firework.launch('Failed to get data from device!', 'danger', 30000);
  163. }
  164. // Get current RAW Value
  165. var sel = document.getElementById("Numbers_value1");
  166. var _number = sel.options[sel.selectedIndex].text;
  167. var xhttp = new XMLHttpRequest();
  168. try {
  169. url = _domainname + '/value?all=true&type=raw';
  170. xhttp.open("GET", url, false);
  171. xhttp.send();
  172. response = xhttp.responseText;
  173. lines = response.split(/\r?\n/);
  174. lines.forEach(function(line) {
  175. arr = line.split("\t");
  176. if (_number == arr[0]) {
  177. document.getElementById("myInput").value = Number(arr[1]);
  178. return;
  179. }
  180. });
  181. }
  182. catch (error)
  183. {
  184. firework.launch('Failed to get data from device!', 'danger', 30000);
  185. }
  186. }
  187. function numberChanged(){
  188. loadPrevalue(domainname);
  189. }
  190. function UpdateNUMBERS(_sel){
  191. zw = getNUMBERInfo();
  192. index = 0;
  193. var _index = document.getElementById("Numbers_value1");
  194. while (_index.length){
  195. _index.remove(0);
  196. }
  197. for (var i = 0; i < zw.length; ++i){
  198. var option = document.createElement("option");
  199. option.text = zw[i]["name"];
  200. option.value = i;
  201. _index.add(option);
  202. if (typeof _sel !== 'undefined') {
  203. if (zw[i]["name"] == _sel)
  204. index = i
  205. }
  206. }
  207. _index.selectedIndex = index;
  208. loadPrevalue(domainname);
  209. }
  210. function init(){
  211. domainname = getDomainname();
  212. loadConfig(domainname);
  213. ParseConfig();
  214. UpdateNUMBERS();
  215. loadPrevalue(domainname);
  216. }
  217. init();
  218. </script>