readconfigparam.js 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  1. var config_gesamt = "";
  2. var config_split = [];
  3. var param = [];
  4. var category;
  5. var ref = new Array(2);
  6. var NUMBERS = new Array(0);
  7. var REFERENCES = new Array(0);
  8. var domainname_for_testing = "";
  9. /* Returns the domainname with prepended protocol.
  10. Eg. http://watermeter.fritz.box or http://192.168.1.5 */
  11. function getDomainname(){
  12. var host = window.location.hostname;
  13. if (domainname_for_testing != "") {
  14. console.log("Using pre-defined domainname for testing: " + domainname_for_testing);
  15. domainname = "http://" + domainname_for_testing;
  16. }
  17. else
  18. {
  19. domainname = window.location.protocol + "//" + host;
  20. if (window.location.port != "") {
  21. domainname = domainname + ":" + window.location.port;
  22. }
  23. }
  24. return domainname;
  25. }
  26. function getConfig() {
  27. return config_gesamt;
  28. }
  29. function loadConfig(_domainname) {
  30. config_gesamt = "";
  31. var url = _domainname + "/fileserver/config/config.ini";
  32. var xhttp = new XMLHttpRequest();
  33. xhttp.addEventListener('load', function(event) {
  34. if (xhttp.status >= 200 && xhttp.status < 300) {
  35. config_gesamt = xhttp.responseText;
  36. }
  37. else {
  38. console.warn('Response status: ${response.status}');
  39. }
  40. });
  41. try {
  42. xhttp.open("GET", url, false);
  43. xhttp.send();
  44. } catch (error) {}
  45. return true;
  46. }
  47. function loadConfig1(_domainname) {
  48. var xhttp = new XMLHttpRequest();
  49. try {
  50. url = _domainname + '/fileserver/config/config.ini';
  51. xhttp.open("GET", url, false);
  52. xhttp.send();
  53. config_gesamt = xhttp.responseText;
  54. } catch (error) {}
  55. return true;
  56. }
  57. function SaveConfigToServer(_domainname){
  58. // leere Zeilen am Ende löschen
  59. var _config_split_length = config_split.length - 1;
  60. while (config_split[_config_split_length] == "") {
  61. config_split.pop();
  62. }
  63. var _config_gesamt = "";
  64. for (var i = 0; i < config_split.length; ++i) {
  65. _config_gesamt = _config_gesamt + config_split[i] + "\n";
  66. }
  67. FileDeleteOnServer("/config/config.ini", _domainname);
  68. FileSendContent(_config_gesamt, "/config/config.ini", _domainname);
  69. }
  70. function getNUMBERSList() {
  71. _domainname = getDomainname();
  72. var namenumberslist = "";
  73. var xhttp = new XMLHttpRequest();
  74. xhttp.addEventListener('load', function(event) {
  75. if (xhttp.status >= 200 && xhttp.status < 300) {
  76. namenumberslist = xhttp.responseText;
  77. }
  78. else {
  79. console.warn(request.statusText, request.responseText);
  80. }
  81. });
  82. try {
  83. url = _domainname + '/editflow?task=namenumbers';
  84. xhttp.open("GET", url, false);
  85. xhttp.send();
  86. } catch (error) {}
  87. namenumberslist = namenumberslist.split("\t");
  88. return namenumberslist;
  89. }
  90. function getDATAList() {
  91. _domainname = getDomainname();
  92. datalist = "";
  93. var xhttp = new XMLHttpRequest();
  94. xhttp.addEventListener('load', function(event) {
  95. if (xhttp.status >= 200 && xhttp.status < 300) {
  96. datalist = xhttp.responseText;
  97. }
  98. else {
  99. console.warn(request.statusText, request.responseText);
  100. }
  101. });
  102. try {
  103. url = _domainname + '/editflow?task=data';
  104. xhttp.open("GET", url, false);
  105. xhttp.send();
  106. } catch (error) {}
  107. datalist = datalist.split("\t");
  108. datalist.pop();
  109. datalist.sort();
  110. return datalist;
  111. }
  112. function getTFLITEList() {
  113. _domainname = getDomainname();
  114. tflitelist = "";
  115. var xhttp = new XMLHttpRequest();
  116. xhttp.addEventListener('load', function(event) {
  117. if (xhttp.status >= 200 && xhttp.status < 300) {
  118. tflitelist = xhttp.responseText;
  119. }
  120. else {
  121. console.warn(request.statusText, request.responseText);
  122. }
  123. });
  124. try {
  125. url = _domainname + '/editflow?task=tflite';
  126. xhttp.open("GET", url, false);
  127. xhttp.send();
  128. } catch (error) {}
  129. tflitelist = tflitelist.split("\t");
  130. tflitelist.sort();
  131. return tflitelist;
  132. }
  133. function ParseConfig() {
  134. config_split = config_gesamt.split("\n");
  135. var aktline = 0;
  136. param = new Object();
  137. category = new Object();
  138. var catname = "TakeImage";
  139. category[catname] = new Object();
  140. category[catname]["enabled"] = false;
  141. category[catname]["found"] = false;
  142. param[catname] = new Object();
  143. ParamAddValue(param, catname, "RawImagesLocation", 1, false, "/log/source");
  144. ParamAddValue(param, catname, "RawImagesRetention", 1, false, "15");
  145. ParamAddValue(param, catname, "SaveAllFiles", 1, false, "false");
  146. ParamAddValue(param, catname, "WaitBeforeTakingPicture", 1, false, "2");
  147. ParamAddValue(param, catname, "CamXclkFreqMhz", 1, false, "20");
  148. ParamAddValue(param, catname, "CamGainceiling", 1, false, "x8"); // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128)
  149. ParamAddValue(param, catname, "CamQuality", 1, false, "10"); // 0 - 63
  150. ParamAddValue(param, catname, "CamBrightness", 1, false, "0"); // (-2 to 2) - set brightness
  151. ParamAddValue(param, catname, "CamContrast", 1, false, "0"); //-2 - 2
  152. ParamAddValue(param, catname, "CamSaturation", 1, false, "0"); //-2 - 2
  153. ParamAddValue(param, catname, "CamSharpness", 1, false, "0"); //-2 - 2
  154. ParamAddValue(param, catname, "CamAutoSharpness", 1, false, "false"); // (1 or 0)
  155. ParamAddValue(param, catname, "CamSpecialEffect", 1, false, "no_effect"); // 0 - 6
  156. ParamAddValue(param, catname, "CamWbMode", 1, false, "auto"); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
  157. ParamAddValue(param, catname, "CamAwb", 1, false, "true"); // white balance enable (0 or 1)
  158. ParamAddValue(param, catname, "CamAwbGain", 1, false, "true"); // Auto White Balance enable (0 or 1)
  159. ParamAddValue(param, catname, "CamAec", 1, false, "true"); // auto exposure off (1 or 0)
  160. ParamAddValue(param, catname, "CamAec2", 1, false, "true"); // automatic exposure sensor (0 or 1)
  161. ParamAddValue(param, catname, "CamAeLevel", 1, false, "2"); // auto exposure levels (-2 to 2)
  162. ParamAddValue(param, catname, "CamAecValue", 1, false, "600"); // set exposure manually (0-1200)
  163. ParamAddValue(param, catname, "CamAgc", 1, false, "true"); // auto gain off (1 or 0)
  164. ParamAddValue(param, catname, "CamAgcGain", 1, false, "8"); // set gain manually (0 - 30)
  165. ParamAddValue(param, catname, "CamBpc", 1, false, "true"); // black pixel correction
  166. ParamAddValue(param, catname, "CamWpc", 1, false, "true"); // white pixel correction
  167. ParamAddValue(param, catname, "CamRawGma", 1, false, "true"); // (1 or 0)
  168. ParamAddValue(param, catname, "CamLenc", 1, false, "true"); // lens correction (1 or 0)
  169. ParamAddValue(param, catname, "CamHmirror", 1, false, "false"); // (0 or 1) flip horizontally
  170. ParamAddValue(param, catname, "CamVflip", 1, false, "false"); // Invert image (0 or 1)
  171. ParamAddValue(param, catname, "CamDcw", 1, false, "true"); // downsize enable (1 or 0)
  172. ParamAddValue(param, catname, "CamDenoise", 1, false, "0"); // The OV2640 does not support it, OV3660 and OV5640 (0 to 8)
  173. ParamAddValue(param, catname, "CamZoom", 1, false, "false");
  174. ParamAddValue(param, catname, "CamZoomSize", 1, false, "0");
  175. ParamAddValue(param, catname, "CamZoomOffsetX", 1, false, "0");
  176. ParamAddValue(param, catname, "CamZoomOffsetY", 1, false, "0");
  177. ParamAddValue(param, catname, "LEDIntensity", 1, false, "50");
  178. ParamAddValue(param, catname, "Demo", 1, false, "false");
  179. var catname = "Alignment";
  180. category[catname] = new Object();
  181. category[catname]["enabled"] = false;
  182. category[catname]["found"] = false;
  183. param[catname] = new Object();
  184. ParamAddValue(param, catname, "SearchFieldX", 1, false, "20");
  185. ParamAddValue(param, catname, "SearchFieldY", 1, false, "20");
  186. ParamAddValue(param, catname, "SearchMaxAngle", 1, false, "15");
  187. ParamAddValue(param, catname, "Antialiasing", 1, false, "true");
  188. ParamAddValue(param, catname, "AlignmentAlgo", 1, false, "default");
  189. ParamAddValue(param, catname, "InitialRotate", 1, false, "0");
  190. var catname = "Digits";
  191. category[catname] = new Object();
  192. category[catname]["enabled"] = false;
  193. category[catname]["found"] = false;
  194. param[catname] = new Object();
  195. ParamAddValue(param, catname, "Model");
  196. ParamAddValue(param, catname, "CNNGoodThreshold", 1, false, "0.5");
  197. ParamAddValue(param, catname, "ROIImagesLocation", 1, false, "/log/digit");
  198. ParamAddValue(param, catname, "ROIImagesRetention", 1, false, "3");
  199. var catname = "Analog";
  200. category[catname] = new Object();
  201. category[catname]["enabled"] = false;
  202. category[catname]["found"] = false;
  203. param[catname] = new Object();
  204. ParamAddValue(param, catname, "Model");
  205. ParamAddValue(param, catname, "ROIImagesLocation", 1, false, "/log/analog");
  206. ParamAddValue(param, catname, "ROIImagesRetention", 1, false, "3");
  207. var catname = "PostProcessing";
  208. category[catname] = new Object();
  209. category[catname]["enabled"] = false;
  210. category[catname]["found"] = false;
  211. param[catname] = new Object();
  212. // ParamAddValue(param, catname, "PreValueUse", 1, true, "true");
  213. ParamAddValue(param, catname, "PreValueUse", 1, false, "true");
  214. ParamAddValue(param, catname, "PreValueAgeStartup", 1, false, "720");
  215. ParamAddValue(param, catname, "SkipErrorMessage", 1, false, "false");
  216. ParamAddValue(param, catname, "AllowNegativeRates", 1, true, "false");
  217. ParamAddValue(param, catname, "DecimalShift", 1, true, "0");
  218. ParamAddValue(param, catname, "AnalogToDigitTransitionStart", 1, true, "9.2");
  219. ParamAddValue(param, catname, "MaxFlowRate", 1, true, "4.0");
  220. ParamAddValue(param, catname, "MaxRateValue", 1, true, "0.05");
  221. ParamAddValue(param, catname, "MaxRateType", 1, true);
  222. ParamAddValue(param, catname, "ChangeRateThreshold", 1, true, "2");
  223. ParamAddValue(param, catname, "ExtendedResolution", 1, true, "false");
  224. ParamAddValue(param, catname, "IgnoreLeadingNaN", 1, true, "false");
  225. var catname = "MQTT";
  226. category[catname] = new Object();
  227. category[catname]["enabled"] = false;
  228. category[catname]["found"] = false;
  229. param[catname] = new Object();
  230. ParamAddValue(param, catname, "Uri", 1, false, "mqtt://example.com:1883");
  231. ParamAddValue(param, catname, "MainTopic", 1, false, "watermeter");
  232. ParamAddValue(param, catname, "ClientID", 1, false, "watermeter");
  233. ParamAddValue(param, catname, "user", 1, false, "USERNAME");
  234. ParamAddValue(param, catname, "password", 1, false, "PASSWORD");
  235. ParamAddValue(param, catname, "CACert", 1, false, "/config/certs/RootCA.pem");
  236. ParamAddValue(param, catname, "ClientCert", 1, false, "/config/certs/client.pem.crt");
  237. ParamAddValue(param, catname, "ClientKey", 1, false, "/config/certs/client.pem.key");
  238. ParamAddValue(param, catname, "ValidateServerCert", 1, false, "true");
  239. ParamAddValue(param, catname, "RetainMessages", 1, false, "true");
  240. ParamAddValue(param, catname, "HomeassistantDiscovery", 1, false, "true");
  241. ParamAddValue(param, catname, "DiscoveryPrefix", 1, false, "homeassistant");
  242. ParamAddValue(param, catname, "MeterType", 1, false, "other");
  243. ParamAddValue(param, catname, "DomoticzTopicIn", 1, false, "domoticz/in");
  244. ParamAddValue(param, catname, "DomoticzIDX", 1, true, "0");
  245. var catname = "InfluxDB";
  246. category[catname] = new Object();
  247. category[catname]["enabled"] = false;
  248. category[catname]["found"] = false;
  249. param[catname] = new Object();
  250. ParamAddValue(param, catname, "Uri", 1, false, "undefined");
  251. ParamAddValue(param, catname, "Database", 1, false, "undefined");
  252. ParamAddValue(param, catname, "user", 1, false, "undefined");
  253. ParamAddValue(param, catname, "password", 1, false, "undefined");
  254. ParamAddValue(param, catname, "Measurement", 1, true, "undefined");
  255. ParamAddValue(param, catname, "Field", 1, true, "undefined");
  256. var catname = "InfluxDBv2";
  257. category[catname] = new Object();
  258. category[catname]["enabled"] = false;
  259. category[catname]["found"] = false;
  260. param[catname] = new Object();
  261. ParamAddValue(param, catname, "Uri", 1, false, "undefined");
  262. ParamAddValue(param, catname, "Bucket", 1, false, "undefined");
  263. ParamAddValue(param, catname, "Org", 1, false, "undefined");
  264. ParamAddValue(param, catname, "Token", 1, false, "undefined");
  265. ParamAddValue(param, catname, "Measurement", 1, true, "undefined");
  266. ParamAddValue(param, catname, "Field", 1, true, "undefined");
  267. var catname = "Webhook";
  268. category[catname] = new Object();
  269. category[catname]["enabled"] = false;
  270. category[catname]["found"] = false;
  271. param[catname] = new Object();
  272. ParamAddValue(param, catname, "Uri", 1, false, "undefined");
  273. ParamAddValue(param, catname, "ApiKey", 1, false, "undefined");
  274. ParamAddValue(param, catname, "UploadImg", 1, false, "0");
  275. var catname = "GPIO";
  276. category[catname] = new Object();
  277. category[catname]["enabled"] = false;
  278. category[catname]["found"] = false;
  279. param[catname] = new Object();
  280. ParamAddValue(param, catname, "IO0", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
  281. ParamAddValue(param, catname, "IO1", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
  282. ParamAddValue(param, catname, "IO3", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
  283. ParamAddValue(param, catname, "IO4", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
  284. ParamAddValue(param, catname, "IO12", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
  285. ParamAddValue(param, catname, "IO13", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
  286. ParamAddValue(param, catname, "LEDType");
  287. ParamAddValue(param, catname, "LEDNumbers");
  288. ParamAddValue(param, catname, "LEDColor", 3);
  289. // Default Values, um abwärtskompatiblität zu gewährleisten
  290. param[catname]["LEDType"]["value1"] = "WS2812";
  291. param[catname]["LEDNumbers"]["value1"] = "2";
  292. param[catname]["LEDColor"]["value1"] = "50";
  293. param[catname]["LEDColor"]["value2"] = "50";
  294. param[catname]["LEDColor"]["value3"] = "50";
  295. var catname = "AutoTimer";
  296. category[catname] = new Object();
  297. category[catname]["enabled"] = false;
  298. category[catname]["found"] = false;
  299. param[catname] = new Object();
  300. //ParamAddValue(param, catname, "AutoStart", 1, false, "true");
  301. ParamAddValue(param, catname, "Interval", 1, false, "5");
  302. var catname = "DataLogging";
  303. category[catname] = new Object();
  304. category[catname]["enabled"] = false;
  305. category[catname]["found"] = false;
  306. param[catname] = new Object();
  307. ParamAddValue(param, catname, "DataLogActive", 1, false, "true");
  308. ParamAddValue(param, catname, "DataFilesRetention", 1, false, "3");
  309. var catname = "Debug";
  310. category[catname] = new Object();
  311. category[catname]["enabled"] = false;
  312. category[catname]["found"] = false;
  313. param[catname] = new Object();
  314. ParamAddValue(param, catname, "LogLevel", 1, false, "1");
  315. ParamAddValue(param, catname, "LogfilesRetention", 1, false, "3");
  316. var catname = "System";
  317. category[catname] = new Object();
  318. category[catname]["enabled"] = false;
  319. category[catname]["found"] = false;
  320. param[catname] = new Object();
  321. ParamAddValue(param, catname, "TimeZone", 1, false, "default");
  322. ParamAddValue(param, catname, "TimeServer", 1, false, "pool.ntp.org");
  323. ParamAddValue(param, catname, "Hostname", 1, false, "watermeter");
  324. ParamAddValue(param, catname, "RSSIThreshold", 1, false, "0");
  325. ParamAddValue(param, catname, "CPUFrequency", 1, false, "160");
  326. ParamAddValue(param, catname, "Tooltip", 1, false, "true");
  327. ParamAddValue(param, catname, "SetupMode", 1, false, "false");
  328. while (aktline < config_split.length){
  329. for (var cat in category) {
  330. zw = cat.toUpperCase();
  331. zw1 = "[" + zw + "]";
  332. zw2 = ";[" + zw + "]";
  333. if ((config_split[aktline].trim().toUpperCase() == zw1) || (config_split[aktline].trim().toUpperCase() == zw2)) {
  334. if (config_split[aktline].trim().toUpperCase() == zw1) {
  335. category[cat]["enabled"] = true;
  336. }
  337. category[cat]["found"] = true;
  338. category[cat]["line"] = aktline;
  339. aktline = ParseConfigParamAll(aktline, cat);
  340. continue;
  341. }
  342. }
  343. aktline++;
  344. }
  345. // Make the downward compatiblity with DataLogging
  346. if (category["DataLogging"]["found"] == false) {
  347. category["DataLogging"]["found"] = true;
  348. category["DataLogging"]["enabled"] = true;
  349. param["DataLogging"]["DataLogActive"]["found"] = true;
  350. param["DataLogging"]["DataLogActive"]["enabled"] = true;
  351. param["DataLogging"]["DataLogActive"]["value1"] = "true";
  352. param["DataLogging"]["DataFilesRetention"]["found"] = true;
  353. param["DataLogging"]["DataFilesRetention"]["enabled"] = true;
  354. param["DataLogging"]["DataFilesRetention"]["value1"] = "3";
  355. }
  356. if (category["DataLogging"]["enabled"] == false) {
  357. category["DataLogging"]["enabled"] = true
  358. }
  359. if (param["DataLogging"]["DataLogActive"]["enabled"] == false && param["DataLogging"]["DataLogActive"]["value1"] == "") {
  360. param["DataLogging"]["DataLogActive"]["found"] = true;
  361. param["DataLogging"]["DataLogActive"]["enabled"] = true;
  362. param["DataLogging"]["DataLogActive"]["value1"] = "true";
  363. }
  364. if (param["DataLogging"]["DataFilesRetention"]["enabled"] == false && param["DataLogging"]["DataFilesRetention"]["value1"] == "") {
  365. param["DataLogging"]["DataFilesRetention"]["found"] = true;
  366. param["DataLogging"]["DataFilesRetention"]["enabled"] = true;
  367. param["DataLogging"]["DataFilesRetention"]["value1"] = "3";
  368. }
  369. // Downward compatibility: Create RSSIThreshold if not available
  370. if (param["System"]["RSSIThreshold"]["found"] == false) {
  371. param["System"]["RSSIThreshold"]["found"] = true;
  372. param["System"]["RSSIThreshold"]["enabled"] = false;
  373. param["System"]["RSSIThreshold"]["value1"] = "0";
  374. }
  375. }
  376. function ParamAddValue(param, _cat, _param, _anzParam = 1, _isNUMBER = false, _defaultValue = "", _checkRegExList = null) {
  377. param[_cat][_param] = new Object();
  378. param[_cat][_param]["found"] = false;
  379. param[_cat][_param]["enabled"] = false;
  380. param[_cat][_param]["line"] = -1;
  381. param[_cat][_param]["anzParam"] = _anzParam;
  382. param[_cat][_param]["defaultValue"] = _defaultValue;
  383. param[_cat][_param]["Numbers"] = _isNUMBER;
  384. param[_cat][_param].checkRegExList = _checkRegExList;
  385. };
  386. function ParseConfigParamAll(_aktline, _catname) {
  387. ++_aktline;
  388. while ((_aktline < config_split.length) && !(config_split[_aktline][0] == "[") && !((config_split[_aktline][0] == ";") && (config_split[_aktline][1] == "["))) {
  389. var _input = config_split[_aktline];
  390. let [isCom, input] = isCommented(_input);
  391. var linesplit = split_line(input);
  392. ParamExtractValueAll(param, linesplit, _catname, _aktline, isCom);
  393. if (!isCom && (linesplit.length >= 5) && (_catname == 'Digits')) {
  394. ExtractROIs(input, "digit");
  395. }
  396. if (!isCom && (linesplit.length >= 5) && (_catname == 'Analog')) {
  397. ExtractROIs(input, "analog");
  398. }
  399. if (!isCom && (linesplit.length == 3) && (_catname == 'Alignment')) {
  400. _newref = new Object();
  401. _newref["name"] = linesplit[0];
  402. _newref["x"] = linesplit[1];
  403. _newref["y"] = linesplit[2];
  404. REFERENCES.push(_newref);
  405. }
  406. ++_aktline;
  407. }
  408. return _aktline;
  409. }
  410. function ParamExtractValue(_param, _linesplit, _catname, _paramname, _aktline, _iscom, _anzvalue = 1) {
  411. if ((_linesplit[0].toUpperCase() == _paramname.toUpperCase()) && (_linesplit.length > _anzvalue)) {
  412. _param[_catname][_paramname]["found"] = true;
  413. _param[_catname][_paramname]["enabled"] = !_iscom;
  414. _param[_catname][_paramname]["line"] = _aktline;
  415. _param[_catname][_paramname]["anzpara"] = _anzvalue;
  416. for (var j = 1; j <= _anzvalue; ++j) {
  417. _param[_catname][_paramname]["value"+j] = _linesplit[j];
  418. }
  419. }
  420. }
  421. function ParamExtractValueAll(_param, _linesplit, _catname, _aktline, _iscom) {
  422. for (var paramname in _param[_catname]) {
  423. _AktROI = "default";
  424. _AktPara = _linesplit[0];
  425. _pospunkt = _AktPara.indexOf (".");
  426. if (_pospunkt > -1) {
  427. _AktROI = _AktPara.substring(0, _pospunkt);
  428. _AktPara = _AktPara.substring(_pospunkt+1);
  429. }
  430. if (_AktPara.toUpperCase() == paramname.toUpperCase()) {
  431. while (_linesplit.length <= _param[_catname][paramname]["anzParam"]) {
  432. _linesplit.push("");
  433. }
  434. _param[_catname][paramname]["found"] = true;
  435. _param[_catname][paramname]["enabled"] = !_iscom;
  436. _param[_catname][paramname]["line"] = _aktline;
  437. if (_param[_catname][paramname]["Numbers"] == true) { // möglicher Multiusage
  438. abc = getNUMBERS(_linesplit[0]);
  439. abc[_catname][paramname] = new Object;
  440. abc[_catname][paramname]["found"] = true;
  441. abc[_catname][paramname]["enabled"] = !_iscom;
  442. for (var j = 1; j <= _param[_catname][paramname]["anzParam"]; ++j) {
  443. abc[_catname][paramname]["value"+j] = _linesplit[j];
  444. }
  445. if (abc["name"] == "default") {
  446. for (_num in NUMBERS) { // wert mit Default belegen
  447. if (NUMBERS[_num][_catname][paramname]["found"] == false) {
  448. NUMBERS[_num][_catname][paramname]["found"] = true;
  449. NUMBERS[_num][_catname][paramname]["enabled"] = !_iscom;
  450. NUMBERS[_num][_catname][paramname]["line"] = _aktline;
  451. for (var j = 1; j <= _param[_catname][paramname]["anzParam"]; ++j) {
  452. NUMBERS[_num][_catname][paramname]["value"+j] = _linesplit[j];
  453. }
  454. }
  455. }
  456. }
  457. }
  458. else {
  459. _param[_catname][paramname]["found"] = true;
  460. _param[_catname][paramname]["enabled"] = !_iscom;
  461. _param[_catname][paramname]["line"] = _aktline;
  462. for (var j = 1; j <= _param[_catname][paramname]["anzParam"]; ++j) {
  463. _param[_catname][paramname]["value"+j] = _linesplit[j];
  464. }
  465. }
  466. }
  467. }
  468. }
  469. function getCamConfig() {
  470. ParseConfig();
  471. param["System"]["Tooltip"]["enabled"] = true;
  472. param["Alignment"]["InitialRotate"]["enabled"] = true;
  473. param["TakeImage"]["WaitBeforeTakingPicture"]["enabled"] = true;
  474. param["TakeImage"]["CamGainceiling"]["enabled"] = true; // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128)
  475. param["TakeImage"]["CamQuality"]["enabled"] = true; // 0 - 63
  476. param["TakeImage"]["CamBrightness"]["enabled"] = true; // (-2 to 2) - set brightness
  477. param["TakeImage"]["CamContrast"]["enabled"] = true; //-2 - 2
  478. param["TakeImage"]["CamSaturation"]["enabled"] = true; //-2 - 2
  479. param["TakeImage"]["CamSharpness"]["enabled"] = true; //-2 - 2
  480. param["TakeImage"]["CamAutoSharpness"]["enabled"] = true; //(1 or 0)
  481. param["TakeImage"]["CamSpecialEffect"]["enabled"] = true; // 0 - 6
  482. param["TakeImage"]["CamWbMode"]["enabled"] = true; // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
  483. param["TakeImage"]["CamAwb"]["enabled"] = true; // white balance enable (0 or 1)
  484. param["TakeImage"]["CamAwbGain"]["enabled"] = true; // Auto White Balance enable (0 or 1)
  485. param["TakeImage"]["CamAec"]["enabled"] = true; // auto exposure off (1 or 0)
  486. param["TakeImage"]["CamAec2"]["enabled"] = true; // automatic exposure sensor (0 or 1)
  487. param["TakeImage"]["CamAeLevel"]["enabled"] = true; // auto exposure levels (-2 to 2)
  488. param["TakeImage"]["CamAecValue"]["enabled"] = true; // set exposure manually (0-1200)
  489. param["TakeImage"]["CamAgc"]["enabled"] = true; // auto gain off (1 or 0)
  490. param["TakeImage"]["CamAgcGain"]["enabled"] = true; // set gain manually (0 - 30)
  491. param["TakeImage"]["CamBpc"]["enabled"] = true; // black pixel correction
  492. param["TakeImage"]["CamWpc"]["enabled"] = true; // white pixel correction
  493. param["TakeImage"]["CamRawGma"]["enabled"] = true; // (1 or 0)
  494. param["TakeImage"]["CamLenc"]["enabled"] = true; // lens correction (1 or 0)
  495. param["TakeImage"]["CamHmirror"]["enabled"] = true; // (0 or 1) flip horizontally
  496. param["TakeImage"]["CamVflip"]["enabled"] = true; // Invert image (0 or 1)
  497. param["TakeImage"]["CamDcw"]["enabled"] = true; // downsize enable (1 or 0)
  498. param["TakeImage"]["CamDenoise"]["enabled"] = true; // The OV2640 does not support it, OV3660 and OV5640 (0 to 8)
  499. param["TakeImage"]["CamZoom"]["enabled"] = true;
  500. param["TakeImage"]["CamZoomOffsetX"]["enabled"] = true;
  501. param["TakeImage"]["CamZoomOffsetY"]["enabled"] = true;
  502. param["TakeImage"]["CamZoomSize"]["enabled"] = true;
  503. param["TakeImage"]["LEDIntensity"]["enabled"] = true;
  504. if (!param["System"]["Tooltip"]["found"]) {
  505. param["System"]["Tooltip"]["found"] = true;
  506. param["System"]["Tooltip"].value1 = 'true';
  507. }
  508. if (!param["Alignment"]["InitialRotate"]["found"]) {
  509. param["Alignment"]["InitialRotate"]["found"] = true;
  510. param["Alignment"]["InitialRotate"].value1 = 'false';
  511. }
  512. if (!param["TakeImage"]["WaitBeforeTakingPicture"]["found"]) {
  513. param["TakeImage"]["WaitBeforeTakingPicture"]["found"] = true;
  514. param["TakeImage"]["WaitBeforeTakingPicture"].value1 = '5';
  515. }
  516. if (!param["TakeImage"]["CamGainceiling"]["found"]) {
  517. param["TakeImage"]["CamGainceiling"]["found"] = true;
  518. // param["TakeImage"]["CamGainceiling"].value1 = '2';
  519. param["TakeImage"]["CamGainceiling"].value1 = 'x8';
  520. }
  521. if (!param["TakeImage"]["CamQuality"]["found"]) {
  522. param["TakeImage"]["CamQuality"]["found"] = true;
  523. param["TakeImage"]["CamQuality"].value1 = '10';
  524. }
  525. if (!param["TakeImage"]["CamBrightness"]["found"]) {
  526. param["TakeImage"]["CamBrightness"]["found"] = true;
  527. param["TakeImage"]["CamBrightness"].value1 = '0';
  528. }
  529. if (!param["TakeImage"]["CamContrast"]["found"]) {
  530. param["TakeImage"]["CamContrast"]["found"] = true;
  531. param["TakeImage"]["CamContrast"].value1 = '0';
  532. }
  533. if (!param["TakeImage"]["CamSaturation"]["found"]) {
  534. param["TakeImage"]["CamSaturation"]["found"] = true;
  535. param["TakeImage"]["CamSaturation"].value1 = '0';
  536. }
  537. if (!param["TakeImage"]["CamSharpness"]["found"]) {
  538. param["TakeImage"]["CamSharpness"]["found"] = true;
  539. param["TakeImage"]["CamSharpness"].value1 = '0';
  540. }
  541. if (!param["TakeImage"]["CamAutoSharpness"]["found"]) {
  542. param["TakeImage"]["CamAutoSharpness"]["found"] = true;
  543. param["TakeImage"]["CamAutoSharpness"].value1 = 'false';
  544. }
  545. if (!param["TakeImage"]["CamSpecialEffect"]["found"]) {
  546. param["TakeImage"]["CamSpecialEffect"]["found"] = true;
  547. param["TakeImage"]["CamSpecialEffect"].value1 = 'no_effect';
  548. }
  549. if (!param["TakeImage"]["CamWbMode"]["found"]) {
  550. param["TakeImage"]["CamWbMode"]["found"] = true;
  551. param["TakeImage"]["CamWbMode"].value1 = 'auto';
  552. }
  553. if (!param["TakeImage"]["CamAwb"]["found"]) {
  554. param["TakeImage"]["CamAwb"]["found"] = true;
  555. param["TakeImage"]["CamAwb"].value1 = 'true';
  556. }
  557. if (!param["TakeImage"]["CamAwbGain"]["found"]) {
  558. param["TakeImage"]["CamAwbGain"]["found"] = true;
  559. param["TakeImage"]["CamAwbGain"].value1 = 'true';
  560. }
  561. if (!param["TakeImage"]["CamAec"]["found"]) {
  562. param["TakeImage"]["CamAec"]["found"] = true;
  563. param["TakeImage"]["CamAec"].value1 = 'true';
  564. }
  565. if (!param["TakeImage"]["CamAec2"]["found"]) {
  566. param["TakeImage"]["CamAec2"]["found"] = true;
  567. param["TakeImage"]["CamAec2"].value1 = 'true';
  568. }
  569. if (!param["TakeImage"]["CamAeLevel"]["found"]) {
  570. param["TakeImage"]["CamAeLevel"]["found"] = true;
  571. param["TakeImage"]["CamAeLevel"].value1 = '2';
  572. }
  573. if (!param["TakeImage"]["CamAecValue"]["found"]) {
  574. param["TakeImage"]["CamAecValue"]["found"] = true;
  575. param["TakeImage"]["CamAecValue"].value1 = '600';
  576. }
  577. if (!param["TakeImage"]["CamAgc"]["found"]) {
  578. param["TakeImage"]["CamAgc"]["found"] = true;
  579. param["TakeImage"]["CamAgc"].value1 = 'true';
  580. }
  581. if (!param["TakeImage"]["CamAgcGain"]["found"]) {
  582. param["TakeImage"]["CamAgcGain"]["found"] = true;
  583. param["TakeImage"]["CamAgcGain"].value1 = '8';
  584. }
  585. if (!param["TakeImage"]["CamBpc"]["found"]) {
  586. param["TakeImage"]["CamBpc"]["found"] = true;
  587. param["TakeImage"]["CamBpc"].value1 = 'true';
  588. }
  589. if (!param["TakeImage"]["CamWpc"]["found"]) {
  590. param["TakeImage"]["CamWpc"]["found"] = true;
  591. param["TakeImage"]["CamWpc"].value1 = 'true';
  592. }
  593. if (!param["TakeImage"]["CamRawGma"]["found"]) {
  594. param["TakeImage"]["CamRawGma"]["found"] = true;
  595. param["TakeImage"]["CamRawGma"].value1 = 'true';
  596. }
  597. if (!param["TakeImage"]["CamLenc"]["found"]) {
  598. param["TakeImage"]["CamLenc"]["found"] = true;
  599. param["TakeImage"]["CamLenc"].value1 = 'true';
  600. }
  601. if (!param["TakeImage"]["CamHmirror"]["found"]) {
  602. param["TakeImage"]["CamHmirror"]["found"] = true;
  603. param["TakeImage"]["CamHmirror"].value1 = 'false';
  604. }
  605. if (!param["TakeImage"]["CamVflip"]["found"]) {
  606. param["TakeImage"]["CamVflip"]["found"] = true;
  607. param["TakeImage"]["CamVflip"].value1 = 'false';
  608. }
  609. if (!param["TakeImage"]["CamDcw"]["found"]) {
  610. param["TakeImage"]["CamDcw"]["found"] = true;
  611. param["TakeImage"]["CamDcw"].value1 = 'true';
  612. }
  613. if (!param["TakeImage"]["CamDenoise"]["found"]) {
  614. param["TakeImage"]["CamDenoise"]["found"] = true;
  615. param["TakeImage"]["CamDenoise"].value1 = '0';
  616. }
  617. if (!param["TakeImage"]["CamZoom"]["found"]) {
  618. param["TakeImage"]["CamZoom"]["found"] = true;
  619. param["TakeImage"]["CamZoom"].value1 = 'false';
  620. }
  621. if (!param["TakeImage"]["CamZoomOffsetX"]["found"]) {
  622. param["TakeImage"]["CamZoomOffsetX"]["found"] = true;
  623. param["TakeImage"]["CamZoomOffsetX"].value1 = '0';
  624. }
  625. if (!param["TakeImage"]["CamZoomOffsetY"]["found"]) {
  626. param["TakeImage"]["CamZoomOffsetY"]["found"] = true;
  627. param["TakeImage"]["CamZoomOffsetY"].value1 = '0';
  628. }
  629. if (!param["TakeImage"]["CamZoomSize"]["found"]) {
  630. param["TakeImage"]["CamZoomSize"]["found"] = true;
  631. param["TakeImage"]["CamZoomSize"].value1 = '0';
  632. }
  633. if (!param["TakeImage"]["LEDIntensity"]["found"]) {
  634. param["TakeImage"]["LEDIntensity"]["found"] = true;
  635. param["TakeImage"]["LEDIntensity"].value1 = '50';
  636. }
  637. return param;
  638. }
  639. function getConfigParameters() {
  640. return param;
  641. }
  642. function WriteConfigININew() {
  643. // Cleanup empty NUMBERS
  644. for (var j = 0; j < NUMBERS.length; ++j) {
  645. if ((NUMBERS[j]["digit"].length + NUMBERS[j]["analog"].length) == 0) {
  646. NUMBERS.splice(j, 1);
  647. }
  648. }
  649. config_split = new Array(0);
  650. for (var cat in param) {
  651. text = "[" + cat + "]";
  652. if (!category[cat]["enabled"]) {
  653. text = ";" + text;
  654. }
  655. config_split.push(text);
  656. for (var name in param[cat]) {
  657. if (param[cat][name]["Numbers"]) {
  658. for (_num in NUMBERS) {
  659. text = NUMBERS[_num]["name"] + "." + name;
  660. var text = text + " ="
  661. for (var j = 1; j <= param[cat][name]["anzParam"]; ++j) {
  662. if (!(typeof NUMBERS[_num][cat][name]["value"+j] == 'undefined')) {
  663. text = text + " " + NUMBERS[_num][cat][name]["value"+j];
  664. }
  665. }
  666. if (!NUMBERS[_num][cat][name]["enabled"]) {
  667. text = ";" + text;
  668. }
  669. config_split.push(text);
  670. }
  671. }
  672. else {
  673. var text = name + " ="
  674. for (var j = 1; j <= param[cat][name]["anzParam"]; ++j) {
  675. if (!(typeof param[cat][name]["value"+j] == 'undefined')) {
  676. text = text + " " + param[cat][name]["value"+j];
  677. }
  678. }
  679. if (!param[cat][name]["enabled"]) {
  680. text = ";" + text;
  681. }
  682. config_split.push(text);
  683. }
  684. }
  685. if (cat == "Digits") {
  686. for (var _roi in NUMBERS) {
  687. if (NUMBERS[_roi]["digit"].length > 0) {
  688. for (var _roiddet in NUMBERS[_roi]["digit"]) {
  689. text = NUMBERS[_roi]["name"] + "." + NUMBERS[_roi]["digit"][_roiddet]["name"];
  690. text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["x"];
  691. text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["y"];
  692. text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["dx"];
  693. text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["dy"];
  694. text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["CCW"];
  695. config_split.push(text);
  696. }
  697. }
  698. }
  699. }
  700. if (cat == "Analog") {
  701. for (var _roi in NUMBERS) {
  702. if (NUMBERS[_roi]["analog"].length > 0) {
  703. for (var _roiddet in NUMBERS[_roi]["analog"]) {
  704. text = NUMBERS[_roi]["name"] + "." + NUMBERS[_roi]["analog"][_roiddet]["name"];
  705. text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["x"];
  706. text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["y"];
  707. text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["dx"];
  708. text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["dy"];
  709. text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["CCW"];
  710. config_split.push(text);
  711. }
  712. }
  713. }
  714. }
  715. if (cat == "Alignment") {
  716. for (var _roi in REFERENCES) {
  717. text = REFERENCES[_roi]["name"];
  718. text = text + " " + REFERENCES[_roi]["x"];
  719. text = text + " " + REFERENCES[_roi]["y"];
  720. config_split.push(text);
  721. }
  722. }
  723. config_split.push("");
  724. }
  725. }
  726. function isCommented(input) {
  727. let isComment = false;
  728. if (input.charAt(0) == ';') {
  729. isComment = true;
  730. input = input.substr(1, input.length-1);
  731. }
  732. return [isComment, input];
  733. }
  734. function SaveConfigToServer(_domainname){
  735. // leere Zeilen am Ende löschen
  736. var zw = config_split.length - 1;
  737. while (config_split[zw] == "") {
  738. config_split.pop();
  739. }
  740. var config_gesamt = "";
  741. for (var i = 0; i < config_split.length; ++i)
  742. {
  743. config_gesamt = config_gesamt + config_split[i] + "\n";
  744. }
  745. FileDeleteOnServer("/config/config.ini", _domainname);
  746. FileSendContent(config_gesamt, "/config/config.ini", _domainname);
  747. }
  748. function getConfig() {
  749. return config_gesamt;
  750. }
  751. function getConfigCategory() {
  752. return category;
  753. }
  754. function ExtractROIs(_aktline, _type){
  755. var linesplit = split_line(_aktline);
  756. abc = getNUMBERS(linesplit[0], _type);
  757. abc["pos_ref"] = _aktline;
  758. abc["x"] = linesplit[1];
  759. abc["y"] = linesplit[2];
  760. abc["dx"] = linesplit[3];
  761. abc["dy"] = linesplit[4];
  762. abc["ar"] = parseFloat(linesplit[3]) / parseFloat(linesplit[4]);
  763. abc["CCW"] = "false";
  764. if (linesplit.length >= 6) {
  765. abc["CCW"] = linesplit[5];
  766. }
  767. }
  768. function getNUMBERS(_name, _type, _create = true) {
  769. _pospunkt = _name.indexOf (".");
  770. if (_pospunkt > -1) {
  771. _digit = _name.substring(0, _pospunkt);
  772. _roi = _name.substring(_pospunkt+1);
  773. }
  774. else {
  775. _digit = "default";
  776. _roi = _name;
  777. }
  778. _ret = -1;
  779. for (i = 0; i < NUMBERS.length; ++i) {
  780. if (NUMBERS[i]["name"] == _digit) {
  781. _ret = NUMBERS[i];
  782. }
  783. }
  784. if (!_create) { // nicht gefunden und soll auch nicht erzeugt werden, ggf. geht eine NULL zurück
  785. return _ret;
  786. }
  787. if (_ret == -1) {
  788. _ret = new Object();
  789. _ret["name"] = _digit;
  790. _ret['digit'] = new Array();
  791. _ret['analog'] = new Array();
  792. for (_cat in param) {
  793. for (_param in param[_cat]) {
  794. if (param[_cat][_param]["Numbers"] == true){
  795. if (typeof _ret[_cat] == 'undefined') {
  796. _ret[_cat] = new Object();
  797. }
  798. _ret[_cat][_param] = new Object();
  799. _ret[_cat][_param]["found"] = false;
  800. _ret[_cat][_param]["enabled"] = false;
  801. _ret[_cat][_param]["anzParam"] = param[_cat][_param]["anzParam"];
  802. }
  803. }
  804. }
  805. NUMBERS.push(_ret);
  806. }
  807. if (typeof _type == 'undefined') { // muss schon existieren !!! - also erst nach Digits / Analog aufrufen
  808. return _ret;
  809. }
  810. neuroi = new Object();
  811. neuroi["name"] = _roi;
  812. _ret[_type].push(neuroi);
  813. return neuroi;
  814. }
  815. function CopyReferenceToImgTmp(_domainname) {
  816. for (index = 0; index < 2; ++index) {
  817. _filenamevon = REFERENCES[index]["name"];
  818. _filenamenach = _filenamevon.replace("/config/", "/img_tmp/");
  819. FileDeleteOnServer(_filenamenach, _domainname);
  820. FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
  821. _filenamevon = _filenamevon.replace(".jpg", "_org.jpg");
  822. _filenamenach = _filenamenach.replace(".jpg", "_org.jpg");
  823. FileDeleteOnServer(_filenamenach, _domainname);
  824. FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
  825. }
  826. }
  827. function GetReferencesInfo(){
  828. return REFERENCES;
  829. }
  830. function UpdateConfigReferences(_domainname){
  831. for (var index = 0; index < 2; ++index) {
  832. _filenamenach = REFERENCES[index]["name"];
  833. _filenamevon = _filenamenach.replace("/config/", "/img_tmp/");
  834. FileDeleteOnServer(_filenamenach, _domainname);
  835. FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
  836. _filenamenach = _filenamenach.replace(".jpg", "_org.jpg");
  837. _filenamevon = _filenamevon.replace(".jpg", "_org.jpg");
  838. FileDeleteOnServer(_filenamenach, _domainname);
  839. FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
  840. }
  841. }
  842. function UpdateConfigReference(_anzneueref, _domainname){
  843. var index = 0;
  844. if (_anzneueref == 1) {
  845. index = 0;
  846. }
  847. else if (_anzneueref == 2) {
  848. index = 1;
  849. }
  850. _filenamenach = REFERENCES[index]["name"];
  851. _filenamevon = _filenamenach.replace("/config/", "/img_tmp/");
  852. FileDeleteOnServer(_filenamenach, _domainname);
  853. FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
  854. _filenamenach = _filenamenach.replace(".jpg", "_org.jpg");
  855. _filenamevon = _filenamevon.replace(".jpg", "_org.jpg");
  856. FileDeleteOnServer(_filenamenach, _domainname);
  857. FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
  858. }
  859. function getNUMBERInfo(){
  860. return NUMBERS;
  861. }
  862. function RenameNUMBER(_alt, _neu){
  863. if ((_neu.indexOf(".") >= 0) || (_neu.indexOf(",") >= 0) || (_neu.indexOf(" ") >= 0) || (_neu.indexOf("\"") >= 0)) {
  864. return "Number sequence name must not contain , . \" or a space";
  865. }
  866. index = -1;
  867. found = false;
  868. for (i = 0; i < NUMBERS.length; ++i) {
  869. if (NUMBERS[i]["name"] == _alt) {
  870. index = i;
  871. }
  872. if (NUMBERS[i]["name"] == _neu) {
  873. found = true;
  874. }
  875. }
  876. if (found) {
  877. return "Number sequence name is already existing, please choose another name";
  878. }
  879. NUMBERS[index]["name"] = _neu;
  880. return "";
  881. }
  882. function DeleteNUMBER(_delete){
  883. if (NUMBERS.length == 1) {
  884. return "One number sequence is mandatory. Therefore this cannot be deleted"
  885. }
  886. index = -1;
  887. for (i = 0; i < NUMBERS.length; ++i) {
  888. if (NUMBERS[i]["name"] == _delete) {
  889. index = i;
  890. }
  891. }
  892. if (index > -1) {
  893. NUMBERS.splice(index, 1);
  894. }
  895. return "";
  896. }
  897. function CreateNUMBER(_numbernew){
  898. found = false;
  899. for (i = 0; i < NUMBERS.length; ++i) {
  900. if (NUMBERS[i]["name"] == _numbernew) {
  901. found = true;
  902. }
  903. }
  904. if (found) {
  905. return "Number sequence name is already existing, please choose another name";
  906. }
  907. _ret = new Object();
  908. _ret["name"] = _numbernew;
  909. _ret['digit'] = new Array();
  910. _ret['analog'] = new Array();
  911. for (_cat in param) {
  912. for (_param in param[_cat]) {
  913. if (param[_cat][_param]["Numbers"] == true) {
  914. if (typeof (_ret[_cat]) === "undefined") {
  915. _ret[_cat] = new Object();
  916. }
  917. _ret[_cat][_param] = new Object();
  918. if (param[_cat][_param]["defaultValue"] === "") {
  919. _ret[_cat][_param]["found"] = false;
  920. _ret[_cat][_param]["enabled"] = false;
  921. }
  922. else {
  923. _ret[_cat][_param]["found"] = true;
  924. _ret[_cat][_param]["enabled"] = true;
  925. _ret[_cat][_param]["value1"] = param[_cat][_param]["defaultValue"];
  926. }
  927. _ret[_cat][_param]["anzParam"] = param[_cat][_param]["anzParam"];
  928. }
  929. }
  930. }
  931. NUMBERS.push(_ret);
  932. return "";
  933. }
  934. function getROIInfo(_typeROI, _number){
  935. index = -1;
  936. for (var i = 0; i < NUMBERS.length; ++i) {
  937. if (NUMBERS[i]["name"] == _number) {
  938. index = i;
  939. }
  940. }
  941. if (index != -1) {
  942. return NUMBERS[index][_typeROI];
  943. }
  944. else {
  945. return "";
  946. }
  947. }
  948. function RenameROI(_number, _type, _alt, _neu){
  949. if ((_neu.includes("=")) || (_neu.includes(".")) || (_neu.includes(":")) || (_neu.includes(",")) || (_neu.includes(";")) || (_neu.includes(" ")) || (_neu.includes("\""))) {
  950. return "ROI name must not contain . : , ; = \" or space";
  951. }
  952. index = -1;
  953. found = false;
  954. _indexnumber = -1;
  955. for (j = 0; j < NUMBERS.length; ++j) {
  956. if (NUMBERS[j]["name"] == _number) {
  957. _indexnumber = j;
  958. }
  959. }
  960. if (_indexnumber == -1) {
  961. return "Number sequence not existing. ROI cannot be renamed"
  962. }
  963. for (i = 0; i < NUMBERS[_indexnumber][_type].length; ++i) {
  964. if (NUMBERS[_indexnumber][_type][i]["name"] == _alt) {
  965. index = i;
  966. }
  967. if (NUMBERS[_indexnumber][_type][i]["name"] == _neu) {
  968. found = true;
  969. }
  970. }
  971. if (found) {
  972. return "ROI name is already existing, please choose another name";
  973. }
  974. NUMBERS[_indexnumber][_type][index]["name"] = _neu;
  975. return "";
  976. }
  977. function DeleteNUMBER(_delte) {
  978. if (NUMBERS.length == 1) {
  979. return "The last number cannot be deleted"
  980. }
  981. index = -1;
  982. for (i = 0; i < NUMBERS.length; ++i) {
  983. if (NUMBERS[i]["name"] == _delte) {
  984. index = i;
  985. }
  986. }
  987. if (index > -1) {
  988. NUMBERS.splice(index, 1);
  989. }
  990. return "";
  991. }
  992. function CreateROI(_number, _type, _pos, _roinew, _x, _y, _dx, _dy, _CCW){
  993. _indexnumber = -1;
  994. for (j = 0; j < NUMBERS.length; ++j) {
  995. if (NUMBERS[j]["name"] == _number) {
  996. _indexnumber = j;
  997. }
  998. }
  999. if (_indexnumber == -1) {
  1000. return "Number sequence not existing. ROI cannot be created"
  1001. }
  1002. found = false;
  1003. for (i = 0; i < NUMBERS[_indexnumber][_type].length; ++i) {
  1004. if (NUMBERS[_indexnumber][_type][i]["name"] == _roinew) {
  1005. found = true;
  1006. }
  1007. }
  1008. if (found) {
  1009. return "ROI name is already existing, please choose another name";
  1010. }
  1011. _ret = new Object();
  1012. _ret["name"] = _roinew;
  1013. _ret["x"] = _x;
  1014. _ret["y"] = _y;
  1015. _ret["dx"] = _dx;
  1016. _ret["dy"] = _dy;
  1017. _ret["ar"] = _dx / _dy;
  1018. _ret["CCW"] = _CCW;
  1019. NUMBERS[_indexnumber][_type].splice(_pos+1, 0, _ret);
  1020. return "";
  1021. }