| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211 |
- var config_gesamt = "";
- var config_split = [];
- var param = [];
- var category;
- var ref = new Array(2);
- var NUMBERS = new Array(0);
- var REFERENCES = new Array(0);
- var domainname_for_testing = "";
- /* Returns the domainname with prepended protocol.
- Eg. http://watermeter.fritz.box or http://192.168.1.5 */
- function getDomainname(){
- var host = window.location.hostname;
- if (domainname_for_testing != "") {
- console.log("Using pre-defined domainname for testing: " + domainname_for_testing);
- domainname = "http://" + domainname_for_testing;
- }
- else
- {
- domainname = window.location.protocol + "//" + host;
- if (window.location.port != "") {
- domainname = domainname + ":" + window.location.port;
- }
- }
- return domainname;
- }
- function getConfig() {
- return config_gesamt;
- }
- function loadConfig(_domainname) {
- config_gesamt = "";
- var url = _domainname + "/fileserver/config/config.ini";
-
- var xhttp = new XMLHttpRequest();
- xhttp.addEventListener('load', function(event) {
- if (xhttp.status >= 200 && xhttp.status < 300) {
- config_gesamt = xhttp.responseText;
- }
- else {
- console.warn('Response status: ${response.status}');
- }
- });
- try {
- xhttp.open("GET", url, false);
- xhttp.send();
- } catch (error) {}
-
- return true;
- }
- function loadConfig1(_domainname) {
- var xhttp = new XMLHttpRequest();
-
- try {
- url = _domainname + '/fileserver/config/config.ini';
- xhttp.open("GET", url, false);
- xhttp.send();
- config_gesamt = xhttp.responseText;
- } catch (error) {}
-
- return true;
- }
- function SaveConfigToServer(_domainname){
- // leere Zeilen am Ende löschen
- var _config_split_length = config_split.length - 1;
-
- while (config_split[_config_split_length] == "") {
- config_split.pop();
- }
- var _config_gesamt = "";
-
- for (var i = 0; i < config_split.length; ++i) {
- _config_gesamt = _config_gesamt + config_split[i] + "\n";
- }
- FileDeleteOnServer("/config/config.ini", _domainname);
- FileSendContent(_config_gesamt, "/config/config.ini", _domainname);
- }
- function getNUMBERSList() {
- _domainname = getDomainname();
- var namenumberslist = "";
- var xhttp = new XMLHttpRequest();
-
- xhttp.addEventListener('load', function(event) {
- if (xhttp.status >= 200 && xhttp.status < 300) {
- namenumberslist = xhttp.responseText;
- }
- else {
- console.warn(request.statusText, request.responseText);
- }
- });
- try {
- url = _domainname + '/editflow?task=namenumbers';
- xhttp.open("GET", url, false);
- xhttp.send();
- } catch (error) {}
- namenumberslist = namenumberslist.split("\t");
- return namenumberslist;
- }
- function getDATAList() {
- _domainname = getDomainname();
- datalist = "";
- var xhttp = new XMLHttpRequest();
-
- xhttp.addEventListener('load', function(event) {
- if (xhttp.status >= 200 && xhttp.status < 300) {
- datalist = xhttp.responseText;
- }
- else {
- console.warn(request.statusText, request.responseText);
- }
- });
- try {
- url = _domainname + '/editflow?task=data';
- xhttp.open("GET", url, false);
- xhttp.send();
- } catch (error) {}
- datalist = datalist.split("\t");
- datalist.pop();
- datalist.sort();
- return datalist;
- }
- function getTFLITEList() {
- _domainname = getDomainname();
- tflitelist = "";
- var xhttp = new XMLHttpRequest();
-
- xhttp.addEventListener('load', function(event) {
- if (xhttp.status >= 200 && xhttp.status < 300) {
- tflitelist = xhttp.responseText;
- }
- else {
- console.warn(request.statusText, request.responseText);
- }
- });
- try {
- url = _domainname + '/editflow?task=tflite';
- xhttp.open("GET", url, false);
- xhttp.send();
- } catch (error) {}
- tflitelist = tflitelist.split("\t");
- tflitelist.sort();
- return tflitelist;
- }
- function ParseConfig() {
- config_split = config_gesamt.split("\n");
- var aktline = 0;
- param = new Object();
- category = new Object();
- var catname = "TakeImage";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "RawImagesLocation", 1, false, "/log/source");
- ParamAddValue(param, catname, "RawImagesRetention", 1, false, "15");
- ParamAddValue(param, catname, "SaveAllFiles", 1, false, "false");
- ParamAddValue(param, catname, "WaitBeforeTakingPicture", 1, false, "2");
- ParamAddValue(param, catname, "CamXclkFreqMhz", 1, false, "20");
- ParamAddValue(param, catname, "CamGainceiling", 1, false, "x8"); // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128)
- ParamAddValue(param, catname, "CamQuality", 1, false, "10"); // 0 - 63
- ParamAddValue(param, catname, "CamBrightness", 1, false, "0"); // (-2 to 2) - set brightness
- ParamAddValue(param, catname, "CamContrast", 1, false, "0"); //-2 - 2
- ParamAddValue(param, catname, "CamSaturation", 1, false, "0"); //-2 - 2
- ParamAddValue(param, catname, "CamSharpness", 1, false, "0"); //-2 - 2
- ParamAddValue(param, catname, "CamAutoSharpness", 1, false, "false"); // (1 or 0)
- ParamAddValue(param, catname, "CamSpecialEffect", 1, false, "no_effect"); // 0 - 6
- ParamAddValue(param, catname, "CamWbMode", 1, false, "auto"); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
- ParamAddValue(param, catname, "CamAwb", 1, false, "true"); // white balance enable (0 or 1)
- ParamAddValue(param, catname, "CamAwbGain", 1, false, "true"); // Auto White Balance enable (0 or 1)
- ParamAddValue(param, catname, "CamAec", 1, false, "true"); // auto exposure off (1 or 0)
- ParamAddValue(param, catname, "CamAec2", 1, false, "true"); // automatic exposure sensor (0 or 1)
- ParamAddValue(param, catname, "CamAeLevel", 1, false, "2"); // auto exposure levels (-2 to 2)
- ParamAddValue(param, catname, "CamAecValue", 1, false, "600"); // set exposure manually (0-1200)
- ParamAddValue(param, catname, "CamAgc", 1, false, "true"); // auto gain off (1 or 0)
- ParamAddValue(param, catname, "CamAgcGain", 1, false, "8"); // set gain manually (0 - 30)
- ParamAddValue(param, catname, "CamBpc", 1, false, "true"); // black pixel correction
- ParamAddValue(param, catname, "CamWpc", 1, false, "true"); // white pixel correction
- ParamAddValue(param, catname, "CamRawGma", 1, false, "true"); // (1 or 0)
- ParamAddValue(param, catname, "CamLenc", 1, false, "true"); // lens correction (1 or 0)
- ParamAddValue(param, catname, "CamHmirror", 1, false, "false"); // (0 or 1) flip horizontally
- ParamAddValue(param, catname, "CamVflip", 1, false, "false"); // Invert image (0 or 1)
- ParamAddValue(param, catname, "CamDcw", 1, false, "true"); // downsize enable (1 or 0)
- ParamAddValue(param, catname, "CamDenoise", 1, false, "0"); // The OV2640 does not support it, OV3660 and OV5640 (0 to 8)
- ParamAddValue(param, catname, "CamZoom", 1, false, "false");
- ParamAddValue(param, catname, "CamZoomSize", 1, false, "0");
- ParamAddValue(param, catname, "CamZoomOffsetX", 1, false, "0");
- ParamAddValue(param, catname, "CamZoomOffsetY", 1, false, "0");
- ParamAddValue(param, catname, "LEDIntensity", 1, false, "50");
- ParamAddValue(param, catname, "Demo", 1, false, "false");
- var catname = "Alignment";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "SearchFieldX", 1, false, "20");
- ParamAddValue(param, catname, "SearchFieldY", 1, false, "20");
- ParamAddValue(param, catname, "SearchMaxAngle", 1, false, "15");
- ParamAddValue(param, catname, "Antialiasing", 1, false, "true");
- ParamAddValue(param, catname, "AlignmentAlgo", 1, false, "default");
- ParamAddValue(param, catname, "InitialRotate", 1, false, "0");
- var catname = "Digits";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "Model");
- ParamAddValue(param, catname, "CNNGoodThreshold", 1, false, "0.5");
- ParamAddValue(param, catname, "ROIImagesLocation", 1, false, "/log/digit");
- ParamAddValue(param, catname, "ROIImagesRetention", 1, false, "3");
- var catname = "Analog";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "Model");
- ParamAddValue(param, catname, "ROIImagesLocation", 1, false, "/log/analog");
- ParamAddValue(param, catname, "ROIImagesRetention", 1, false, "3");
- var catname = "PostProcessing";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- // ParamAddValue(param, catname, "PreValueUse", 1, true, "true");
- ParamAddValue(param, catname, "PreValueUse", 1, false, "true");
- ParamAddValue(param, catname, "PreValueAgeStartup", 1, false, "720");
- ParamAddValue(param, catname, "SkipErrorMessage", 1, false, "false");
- ParamAddValue(param, catname, "AllowNegativeRates", 1, true, "false");
- ParamAddValue(param, catname, "DecimalShift", 1, true, "0");
- ParamAddValue(param, catname, "AnalogToDigitTransitionStart", 1, true, "9.2");
- ParamAddValue(param, catname, "MaxFlowRate", 1, true, "4.0");
- ParamAddValue(param, catname, "MaxRateValue", 1, true, "0.05");
- ParamAddValue(param, catname, "MaxRateType", 1, true);
- ParamAddValue(param, catname, "ChangeRateThreshold", 1, true, "2");
- ParamAddValue(param, catname, "ExtendedResolution", 1, true, "false");
- ParamAddValue(param, catname, "IgnoreLeadingNaN", 1, true, "false");
- var catname = "MQTT";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "Uri", 1, false, "mqtt://example.com:1883");
- ParamAddValue(param, catname, "MainTopic", 1, false, "watermeter");
- ParamAddValue(param, catname, "ClientID", 1, false, "watermeter");
- ParamAddValue(param, catname, "user", 1, false, "USERNAME");
- ParamAddValue(param, catname, "password", 1, false, "PASSWORD");
- ParamAddValue(param, catname, "CACert", 1, false, "/config/certs/RootCA.pem");
- ParamAddValue(param, catname, "ClientCert", 1, false, "/config/certs/client.pem.crt");
- ParamAddValue(param, catname, "ClientKey", 1, false, "/config/certs/client.pem.key");
- ParamAddValue(param, catname, "ValidateServerCert", 1, false, "true");
- ParamAddValue(param, catname, "RetainMessages", 1, false, "true");
- ParamAddValue(param, catname, "HomeassistantDiscovery", 1, false, "true");
- ParamAddValue(param, catname, "DiscoveryPrefix", 1, false, "homeassistant");
- ParamAddValue(param, catname, "MeterType", 1, false, "other");
- ParamAddValue(param, catname, "DomoticzTopicIn", 1, false, "domoticz/in");
- ParamAddValue(param, catname, "DomoticzIDX", 1, true, "0");
- var catname = "InfluxDB";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "Uri", 1, false, "undefined");
- ParamAddValue(param, catname, "Database", 1, false, "undefined");
- ParamAddValue(param, catname, "user", 1, false, "undefined");
- ParamAddValue(param, catname, "password", 1, false, "undefined");
- ParamAddValue(param, catname, "Measurement", 1, true, "undefined");
- ParamAddValue(param, catname, "Field", 1, true, "undefined");
- var catname = "InfluxDBv2";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "Uri", 1, false, "undefined");
- ParamAddValue(param, catname, "Bucket", 1, false, "undefined");
- ParamAddValue(param, catname, "Org", 1, false, "undefined");
- ParamAddValue(param, catname, "Token", 1, false, "undefined");
- ParamAddValue(param, catname, "Measurement", 1, true, "undefined");
- ParamAddValue(param, catname, "Field", 1, true, "undefined");
- var catname = "Webhook";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "Uri", 1, false, "undefined");
- ParamAddValue(param, catname, "ApiKey", 1, false, "undefined");
- ParamAddValue(param, catname, "UploadImg", 1, false, "0");
- var catname = "GPIO";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "IO0", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
- ParamAddValue(param, catname, "IO1", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
- ParamAddValue(param, catname, "IO3", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
- ParamAddValue(param, catname, "IO4", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
- ParamAddValue(param, catname, "IO12", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
- ParamAddValue(param, catname, "IO13", 6, false, "", [null, null, /^[0-9]*$/, null, null, /^[a-zA-Z0-9_-]*$/]);
- ParamAddValue(param, catname, "LEDType");
- ParamAddValue(param, catname, "LEDNumbers");
- ParamAddValue(param, catname, "LEDColor", 3);
- // Default Values, um abwärtskompatiblität zu gewährleisten
- param[catname]["LEDType"]["value1"] = "WS2812";
- param[catname]["LEDNumbers"]["value1"] = "2";
- param[catname]["LEDColor"]["value1"] = "50";
- param[catname]["LEDColor"]["value2"] = "50";
- param[catname]["LEDColor"]["value3"] = "50";
- var catname = "AutoTimer";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- //ParamAddValue(param, catname, "AutoStart", 1, false, "true");
- ParamAddValue(param, catname, "Interval", 1, false, "5");
- var catname = "DataLogging";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "DataLogActive", 1, false, "true");
- ParamAddValue(param, catname, "DataFilesRetention", 1, false, "3");
- var catname = "Debug";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "LogLevel", 1, false, "1");
- ParamAddValue(param, catname, "LogfilesRetention", 1, false, "3");
- var catname = "System";
- category[catname] = new Object();
- category[catname]["enabled"] = false;
- category[catname]["found"] = false;
- param[catname] = new Object();
- ParamAddValue(param, catname, "TimeZone", 1, false, "default");
- ParamAddValue(param, catname, "TimeServer", 1, false, "pool.ntp.org");
- ParamAddValue(param, catname, "Hostname", 1, false, "watermeter");
- ParamAddValue(param, catname, "RSSIThreshold", 1, false, "0");
- ParamAddValue(param, catname, "CPUFrequency", 1, false, "160");
- ParamAddValue(param, catname, "Tooltip", 1, false, "true");
- ParamAddValue(param, catname, "SetupMode", 1, false, "false");
-
- while (aktline < config_split.length){
- for (var cat in category) {
- zw = cat.toUpperCase();
- zw1 = "[" + zw + "]";
- zw2 = ";[" + zw + "]";
-
- if ((config_split[aktline].trim().toUpperCase() == zw1) || (config_split[aktline].trim().toUpperCase() == zw2)) {
- if (config_split[aktline].trim().toUpperCase() == zw1) {
- category[cat]["enabled"] = true;
- }
-
- category[cat]["found"] = true;
- category[cat]["line"] = aktline;
- aktline = ParseConfigParamAll(aktline, cat);
- continue;
- }
- }
-
- aktline++;
- }
- // Make the downward compatiblity with DataLogging
- if (category["DataLogging"]["found"] == false) {
- category["DataLogging"]["found"] = true;
- category["DataLogging"]["enabled"] = true;
- param["DataLogging"]["DataLogActive"]["found"] = true;
- param["DataLogging"]["DataLogActive"]["enabled"] = true;
- param["DataLogging"]["DataLogActive"]["value1"] = "true";
-
- param["DataLogging"]["DataFilesRetention"]["found"] = true;
- param["DataLogging"]["DataFilesRetention"]["enabled"] = true;
- param["DataLogging"]["DataFilesRetention"]["value1"] = "3";
- }
- if (category["DataLogging"]["enabled"] == false) {
- category["DataLogging"]["enabled"] = true
- }
- if (param["DataLogging"]["DataLogActive"]["enabled"] == false && param["DataLogging"]["DataLogActive"]["value1"] == "") {
- param["DataLogging"]["DataLogActive"]["found"] = true;
- param["DataLogging"]["DataLogActive"]["enabled"] = true;
- param["DataLogging"]["DataLogActive"]["value1"] = "true";
- }
- if (param["DataLogging"]["DataFilesRetention"]["enabled"] == false && param["DataLogging"]["DataFilesRetention"]["value1"] == "") {
- param["DataLogging"]["DataFilesRetention"]["found"] = true;
- param["DataLogging"]["DataFilesRetention"]["enabled"] = true;
- param["DataLogging"]["DataFilesRetention"]["value1"] = "3";
- }
- // Downward compatibility: Create RSSIThreshold if not available
- if (param["System"]["RSSIThreshold"]["found"] == false) {
- param["System"]["RSSIThreshold"]["found"] = true;
- param["System"]["RSSIThreshold"]["enabled"] = false;
- param["System"]["RSSIThreshold"]["value1"] = "0";
- }
- }
- function ParamAddValue(param, _cat, _param, _anzParam = 1, _isNUMBER = false, _defaultValue = "", _checkRegExList = null) {
- param[_cat][_param] = new Object();
- param[_cat][_param]["found"] = false;
- param[_cat][_param]["enabled"] = false;
- param[_cat][_param]["line"] = -1;
- param[_cat][_param]["anzParam"] = _anzParam;
- param[_cat][_param]["defaultValue"] = _defaultValue;
- param[_cat][_param]["Numbers"] = _isNUMBER;
- param[_cat][_param].checkRegExList = _checkRegExList;
- };
- function ParseConfigParamAll(_aktline, _catname) {
- ++_aktline;
- while ((_aktline < config_split.length) && !(config_split[_aktline][0] == "[") && !((config_split[_aktline][0] == ";") && (config_split[_aktline][1] == "["))) {
- var _input = config_split[_aktline];
- let [isCom, input] = isCommented(_input);
- var linesplit = split_line(input);
- ParamExtractValueAll(param, linesplit, _catname, _aktline, isCom);
-
- if (!isCom && (linesplit.length >= 5) && (_catname == 'Digits')) {
- ExtractROIs(input, "digit");
- }
-
- if (!isCom && (linesplit.length >= 5) && (_catname == 'Analog')) {
- ExtractROIs(input, "analog");
- }
-
- if (!isCom && (linesplit.length == 3) && (_catname == 'Alignment')) {
- _newref = new Object();
- _newref["name"] = linesplit[0];
- _newref["x"] = linesplit[1];
- _newref["y"] = linesplit[2];
- REFERENCES.push(_newref);
- }
- ++_aktline;
- }
-
- return _aktline;
- }
- function ParamExtractValue(_param, _linesplit, _catname, _paramname, _aktline, _iscom, _anzvalue = 1) {
- if ((_linesplit[0].toUpperCase() == _paramname.toUpperCase()) && (_linesplit.length > _anzvalue)) {
- _param[_catname][_paramname]["found"] = true;
- _param[_catname][_paramname]["enabled"] = !_iscom;
- _param[_catname][_paramname]["line"] = _aktline;
- _param[_catname][_paramname]["anzpara"] = _anzvalue;
-
- for (var j = 1; j <= _anzvalue; ++j) {
- _param[_catname][_paramname]["value"+j] = _linesplit[j];
- }
- }
- }
- function ParamExtractValueAll(_param, _linesplit, _catname, _aktline, _iscom) {
- for (var paramname in _param[_catname]) {
- _AktROI = "default";
- _AktPara = _linesplit[0];
- _pospunkt = _AktPara.indexOf (".");
-
- if (_pospunkt > -1) {
- _AktROI = _AktPara.substring(0, _pospunkt);
- _AktPara = _AktPara.substring(_pospunkt+1);
- }
-
- if (_AktPara.toUpperCase() == paramname.toUpperCase()) {
- while (_linesplit.length <= _param[_catname][paramname]["anzParam"]) {
- _linesplit.push("");
- }
- _param[_catname][paramname]["found"] = true;
- _param[_catname][paramname]["enabled"] = !_iscom;
- _param[_catname][paramname]["line"] = _aktline;
-
- if (_param[_catname][paramname]["Numbers"] == true) { // möglicher Multiusage
- abc = getNUMBERS(_linesplit[0]);
- abc[_catname][paramname] = new Object;
- abc[_catname][paramname]["found"] = true;
- abc[_catname][paramname]["enabled"] = !_iscom;
-
- for (var j = 1; j <= _param[_catname][paramname]["anzParam"]; ++j) {
- abc[_catname][paramname]["value"+j] = _linesplit[j];
- }
-
- if (abc["name"] == "default") {
- for (_num in NUMBERS) { // wert mit Default belegen
- if (NUMBERS[_num][_catname][paramname]["found"] == false) {
- NUMBERS[_num][_catname][paramname]["found"] = true;
- NUMBERS[_num][_catname][paramname]["enabled"] = !_iscom;
- NUMBERS[_num][_catname][paramname]["line"] = _aktline;
-
- for (var j = 1; j <= _param[_catname][paramname]["anzParam"]; ++j) {
- NUMBERS[_num][_catname][paramname]["value"+j] = _linesplit[j];
- }
- }
- }
- }
- }
- else {
- _param[_catname][paramname]["found"] = true;
- _param[_catname][paramname]["enabled"] = !_iscom;
- _param[_catname][paramname]["line"] = _aktline;
-
- for (var j = 1; j <= _param[_catname][paramname]["anzParam"]; ++j) {
- _param[_catname][paramname]["value"+j] = _linesplit[j];
- }
- }
- }
- }
- }
- function getCamConfig() {
- ParseConfig();
- param["System"]["Tooltip"]["enabled"] = true;
- param["Alignment"]["InitialRotate"]["enabled"] = true;
-
- param["TakeImage"]["WaitBeforeTakingPicture"]["enabled"] = true;
- param["TakeImage"]["CamGainceiling"]["enabled"] = true; // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128)
- param["TakeImage"]["CamQuality"]["enabled"] = true; // 0 - 63
- param["TakeImage"]["CamBrightness"]["enabled"] = true; // (-2 to 2) - set brightness
- param["TakeImage"]["CamContrast"]["enabled"] = true; //-2 - 2
- param["TakeImage"]["CamSaturation"]["enabled"] = true; //-2 - 2
- param["TakeImage"]["CamSharpness"]["enabled"] = true; //-2 - 2
- param["TakeImage"]["CamAutoSharpness"]["enabled"] = true; //(1 or 0)
- param["TakeImage"]["CamSpecialEffect"]["enabled"] = true; // 0 - 6
- param["TakeImage"]["CamWbMode"]["enabled"] = true; // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
- param["TakeImage"]["CamAwb"]["enabled"] = true; // white balance enable (0 or 1)
- param["TakeImage"]["CamAwbGain"]["enabled"] = true; // Auto White Balance enable (0 or 1)
- param["TakeImage"]["CamAec"]["enabled"] = true; // auto exposure off (1 or 0)
- param["TakeImage"]["CamAec2"]["enabled"] = true; // automatic exposure sensor (0 or 1)
- param["TakeImage"]["CamAeLevel"]["enabled"] = true; // auto exposure levels (-2 to 2)
- param["TakeImage"]["CamAecValue"]["enabled"] = true; // set exposure manually (0-1200)
- param["TakeImage"]["CamAgc"]["enabled"] = true; // auto gain off (1 or 0)
- param["TakeImage"]["CamAgcGain"]["enabled"] = true; // set gain manually (0 - 30)
- param["TakeImage"]["CamBpc"]["enabled"] = true; // black pixel correction
- param["TakeImage"]["CamWpc"]["enabled"] = true; // white pixel correction
- param["TakeImage"]["CamRawGma"]["enabled"] = true; // (1 or 0)
- param["TakeImage"]["CamLenc"]["enabled"] = true; // lens correction (1 or 0)
- param["TakeImage"]["CamHmirror"]["enabled"] = true; // (0 or 1) flip horizontally
- param["TakeImage"]["CamVflip"]["enabled"] = true; // Invert image (0 or 1)
- param["TakeImage"]["CamDcw"]["enabled"] = true; // downsize enable (1 or 0)
- param["TakeImage"]["CamDenoise"]["enabled"] = true; // The OV2640 does not support it, OV3660 and OV5640 (0 to 8)
- param["TakeImage"]["CamZoom"]["enabled"] = true;
- param["TakeImage"]["CamZoomOffsetX"]["enabled"] = true;
- param["TakeImage"]["CamZoomOffsetY"]["enabled"] = true;
- param["TakeImage"]["CamZoomSize"]["enabled"] = true;
- param["TakeImage"]["LEDIntensity"]["enabled"] = true;
- if (!param["System"]["Tooltip"]["found"]) {
- param["System"]["Tooltip"]["found"] = true;
- param["System"]["Tooltip"].value1 = 'true';
- }
- if (!param["Alignment"]["InitialRotate"]["found"]) {
- param["Alignment"]["InitialRotate"]["found"] = true;
- param["Alignment"]["InitialRotate"].value1 = 'false';
- }
- if (!param["TakeImage"]["WaitBeforeTakingPicture"]["found"]) {
- param["TakeImage"]["WaitBeforeTakingPicture"]["found"] = true;
- param["TakeImage"]["WaitBeforeTakingPicture"].value1 = '5';
- }
- if (!param["TakeImage"]["CamGainceiling"]["found"]) {
- param["TakeImage"]["CamGainceiling"]["found"] = true;
- // param["TakeImage"]["CamGainceiling"].value1 = '2';
- param["TakeImage"]["CamGainceiling"].value1 = 'x8';
- }
- if (!param["TakeImage"]["CamQuality"]["found"]) {
- param["TakeImage"]["CamQuality"]["found"] = true;
- param["TakeImage"]["CamQuality"].value1 = '10';
- }
- if (!param["TakeImage"]["CamBrightness"]["found"]) {
- param["TakeImage"]["CamBrightness"]["found"] = true;
- param["TakeImage"]["CamBrightness"].value1 = '0';
- }
- if (!param["TakeImage"]["CamContrast"]["found"]) {
- param["TakeImage"]["CamContrast"]["found"] = true;
- param["TakeImage"]["CamContrast"].value1 = '0';
- }
- if (!param["TakeImage"]["CamSaturation"]["found"]) {
- param["TakeImage"]["CamSaturation"]["found"] = true;
- param["TakeImage"]["CamSaturation"].value1 = '0';
- }
- if (!param["TakeImage"]["CamSharpness"]["found"]) {
- param["TakeImage"]["CamSharpness"]["found"] = true;
- param["TakeImage"]["CamSharpness"].value1 = '0';
- }
- if (!param["TakeImage"]["CamAutoSharpness"]["found"]) {
- param["TakeImage"]["CamAutoSharpness"]["found"] = true;
- param["TakeImage"]["CamAutoSharpness"].value1 = 'false';
- }
- if (!param["TakeImage"]["CamSpecialEffect"]["found"]) {
- param["TakeImage"]["CamSpecialEffect"]["found"] = true;
- param["TakeImage"]["CamSpecialEffect"].value1 = 'no_effect';
- }
- if (!param["TakeImage"]["CamWbMode"]["found"]) {
- param["TakeImage"]["CamWbMode"]["found"] = true;
- param["TakeImage"]["CamWbMode"].value1 = 'auto';
- }
- if (!param["TakeImage"]["CamAwb"]["found"]) {
- param["TakeImage"]["CamAwb"]["found"] = true;
- param["TakeImage"]["CamAwb"].value1 = 'true';
- }
- if (!param["TakeImage"]["CamAwbGain"]["found"]) {
- param["TakeImage"]["CamAwbGain"]["found"] = true;
- param["TakeImage"]["CamAwbGain"].value1 = 'true';
- }
- if (!param["TakeImage"]["CamAec"]["found"]) {
- param["TakeImage"]["CamAec"]["found"] = true;
- param["TakeImage"]["CamAec"].value1 = 'true';
- }
- if (!param["TakeImage"]["CamAec2"]["found"]) {
- param["TakeImage"]["CamAec2"]["found"] = true;
- param["TakeImage"]["CamAec2"].value1 = 'true';
- }
- if (!param["TakeImage"]["CamAeLevel"]["found"]) {
- param["TakeImage"]["CamAeLevel"]["found"] = true;
- param["TakeImage"]["CamAeLevel"].value1 = '2';
- }
- if (!param["TakeImage"]["CamAecValue"]["found"]) {
- param["TakeImage"]["CamAecValue"]["found"] = true;
- param["TakeImage"]["CamAecValue"].value1 = '600';
- }
- if (!param["TakeImage"]["CamAgc"]["found"]) {
- param["TakeImage"]["CamAgc"]["found"] = true;
- param["TakeImage"]["CamAgc"].value1 = 'true';
- }
- if (!param["TakeImage"]["CamAgcGain"]["found"]) {
- param["TakeImage"]["CamAgcGain"]["found"] = true;
- param["TakeImage"]["CamAgcGain"].value1 = '8';
- }
- if (!param["TakeImage"]["CamBpc"]["found"]) {
- param["TakeImage"]["CamBpc"]["found"] = true;
- param["TakeImage"]["CamBpc"].value1 = 'true';
- }
- if (!param["TakeImage"]["CamWpc"]["found"]) {
- param["TakeImage"]["CamWpc"]["found"] = true;
- param["TakeImage"]["CamWpc"].value1 = 'true';
- }
- if (!param["TakeImage"]["CamRawGma"]["found"]) {
- param["TakeImage"]["CamRawGma"]["found"] = true;
- param["TakeImage"]["CamRawGma"].value1 = 'true';
- }
- if (!param["TakeImage"]["CamLenc"]["found"]) {
- param["TakeImage"]["CamLenc"]["found"] = true;
- param["TakeImage"]["CamLenc"].value1 = 'true';
- }
- if (!param["TakeImage"]["CamHmirror"]["found"]) {
- param["TakeImage"]["CamHmirror"]["found"] = true;
- param["TakeImage"]["CamHmirror"].value1 = 'false';
- }
- if (!param["TakeImage"]["CamVflip"]["found"]) {
- param["TakeImage"]["CamVflip"]["found"] = true;
- param["TakeImage"]["CamVflip"].value1 = 'false';
- }
- if (!param["TakeImage"]["CamDcw"]["found"]) {
- param["TakeImage"]["CamDcw"]["found"] = true;
- param["TakeImage"]["CamDcw"].value1 = 'true';
- }
- if (!param["TakeImage"]["CamDenoise"]["found"]) {
- param["TakeImage"]["CamDenoise"]["found"] = true;
- param["TakeImage"]["CamDenoise"].value1 = '0';
- }
- if (!param["TakeImage"]["CamZoom"]["found"]) {
- param["TakeImage"]["CamZoom"]["found"] = true;
- param["TakeImage"]["CamZoom"].value1 = 'false';
- }
- if (!param["TakeImage"]["CamZoomOffsetX"]["found"]) {
- param["TakeImage"]["CamZoomOffsetX"]["found"] = true;
- param["TakeImage"]["CamZoomOffsetX"].value1 = '0';
- }
- if (!param["TakeImage"]["CamZoomOffsetY"]["found"]) {
- param["TakeImage"]["CamZoomOffsetY"]["found"] = true;
- param["TakeImage"]["CamZoomOffsetY"].value1 = '0';
- }
- if (!param["TakeImage"]["CamZoomSize"]["found"]) {
- param["TakeImage"]["CamZoomSize"]["found"] = true;
- param["TakeImage"]["CamZoomSize"].value1 = '0';
- }
- if (!param["TakeImage"]["LEDIntensity"]["found"]) {
- param["TakeImage"]["LEDIntensity"]["found"] = true;
- param["TakeImage"]["LEDIntensity"].value1 = '50';
- }
- return param;
- }
- function getConfigParameters() {
- return param;
- }
- function WriteConfigININew() {
- // Cleanup empty NUMBERS
- for (var j = 0; j < NUMBERS.length; ++j) {
- if ((NUMBERS[j]["digit"].length + NUMBERS[j]["analog"].length) == 0) {
- NUMBERS.splice(j, 1);
- }
- }
- config_split = new Array(0);
- for (var cat in param) {
- text = "[" + cat + "]";
-
- if (!category[cat]["enabled"]) {
- text = ";" + text;
- }
-
- config_split.push(text);
- for (var name in param[cat]) {
- if (param[cat][name]["Numbers"]) {
- for (_num in NUMBERS) {
- text = NUMBERS[_num]["name"] + "." + name;
- var text = text + " ="
-
- for (var j = 1; j <= param[cat][name]["anzParam"]; ++j) {
- if (!(typeof NUMBERS[_num][cat][name]["value"+j] == 'undefined')) {
- text = text + " " + NUMBERS[_num][cat][name]["value"+j];
- }
- }
-
- if (!NUMBERS[_num][cat][name]["enabled"]) {
- text = ";" + text;
- }
-
- config_split.push(text);
- }
- }
- else {
- var text = name + " ="
-
- for (var j = 1; j <= param[cat][name]["anzParam"]; ++j) {
- if (!(typeof param[cat][name]["value"+j] == 'undefined')) {
- text = text + " " + param[cat][name]["value"+j];
- }
- }
-
- if (!param[cat][name]["enabled"]) {
- text = ";" + text;
- }
-
- config_split.push(text);
- }
- }
-
- if (cat == "Digits") {
- for (var _roi in NUMBERS) {
- if (NUMBERS[_roi]["digit"].length > 0) {
- for (var _roiddet in NUMBERS[_roi]["digit"]) {
- text = NUMBERS[_roi]["name"] + "." + NUMBERS[_roi]["digit"][_roiddet]["name"];
- text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["x"];
- text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["y"];
- text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["dx"];
- text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["dy"];
- text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["CCW"];
- config_split.push(text);
- }
- }
- }
- }
-
- if (cat == "Analog") {
- for (var _roi in NUMBERS) {
- if (NUMBERS[_roi]["analog"].length > 0) {
- for (var _roiddet in NUMBERS[_roi]["analog"]) {
- text = NUMBERS[_roi]["name"] + "." + NUMBERS[_roi]["analog"][_roiddet]["name"];
- text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["x"];
- text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["y"];
- text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["dx"];
- text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["dy"];
- text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["CCW"];
- config_split.push(text);
- }
- }
- }
- }
-
- if (cat == "Alignment") {
- for (var _roi in REFERENCES) {
- text = REFERENCES[_roi]["name"];
- text = text + " " + REFERENCES[_roi]["x"];
- text = text + " " + REFERENCES[_roi]["y"];
- config_split.push(text);
- }
- }
- config_split.push("");
- }
- }
- function isCommented(input) {
- let isComment = false;
-
- if (input.charAt(0) == ';') {
- isComment = true;
- input = input.substr(1, input.length-1);
- }
-
- return [isComment, input];
- }
- function SaveConfigToServer(_domainname){
- // leere Zeilen am Ende löschen
- var zw = config_split.length - 1;
-
- while (config_split[zw] == "") {
- config_split.pop();
- }
- var config_gesamt = "";
-
- for (var i = 0; i < config_split.length; ++i)
- {
- config_gesamt = config_gesamt + config_split[i] + "\n";
- }
- FileDeleteOnServer("/config/config.ini", _domainname);
- FileSendContent(config_gesamt, "/config/config.ini", _domainname);
- }
- function getConfig() {
- return config_gesamt;
- }
- function getConfigCategory() {
- return category;
- }
- function ExtractROIs(_aktline, _type){
- var linesplit = split_line(_aktline);
- abc = getNUMBERS(linesplit[0], _type);
- abc["pos_ref"] = _aktline;
- abc["x"] = linesplit[1];
- abc["y"] = linesplit[2];
- abc["dx"] = linesplit[3];
- abc["dy"] = linesplit[4];
- abc["ar"] = parseFloat(linesplit[3]) / parseFloat(linesplit[4]);
- abc["CCW"] = "false";
-
- if (linesplit.length >= 6) {
- abc["CCW"] = linesplit[5];
- }
- }
- function getNUMBERS(_name, _type, _create = true) {
- _pospunkt = _name.indexOf (".");
-
- if (_pospunkt > -1) {
- _digit = _name.substring(0, _pospunkt);
- _roi = _name.substring(_pospunkt+1);
- }
- else {
- _digit = "default";
- _roi = _name;
- }
- _ret = -1;
- for (i = 0; i < NUMBERS.length; ++i) {
- if (NUMBERS[i]["name"] == _digit) {
- _ret = NUMBERS[i];
- }
- }
- if (!_create) { // nicht gefunden und soll auch nicht erzeugt werden, ggf. geht eine NULL zurück
- return _ret;
- }
- if (_ret == -1) {
- _ret = new Object();
- _ret["name"] = _digit;
- _ret['digit'] = new Array();
- _ret['analog'] = new Array();
- for (_cat in param) {
- for (_param in param[_cat]) {
- if (param[_cat][_param]["Numbers"] == true){
- if (typeof _ret[_cat] == 'undefined') {
- _ret[_cat] = new Object();
- }
-
- _ret[_cat][_param] = new Object();
- _ret[_cat][_param]["found"] = false;
- _ret[_cat][_param]["enabled"] = false;
- _ret[_cat][_param]["anzParam"] = param[_cat][_param]["anzParam"];
- }
- }
- }
- NUMBERS.push(_ret);
- }
- if (typeof _type == 'undefined') { // muss schon existieren !!! - also erst nach Digits / Analog aufrufen
- return _ret;
- }
- neuroi = new Object();
- neuroi["name"] = _roi;
- _ret[_type].push(neuroi);
- return neuroi;
- }
- function CopyReferenceToImgTmp(_domainname) {
- for (index = 0; index < 2; ++index) {
- _filenamevon = REFERENCES[index]["name"];
- _filenamenach = _filenamevon.replace("/config/", "/img_tmp/");
- FileDeleteOnServer(_filenamenach, _domainname);
- FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
-
- _filenamevon = _filenamevon.replace(".jpg", "_org.jpg");
- _filenamenach = _filenamenach.replace(".jpg", "_org.jpg");
- FileDeleteOnServer(_filenamenach, _domainname);
- FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
- }
- }
- function GetReferencesInfo(){
- return REFERENCES;
- }
- function UpdateConfigReferences(_domainname){
- for (var index = 0; index < 2; ++index) {
- _filenamenach = REFERENCES[index]["name"];
- _filenamevon = _filenamenach.replace("/config/", "/img_tmp/");
- FileDeleteOnServer(_filenamenach, _domainname);
- FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
-
- _filenamenach = _filenamenach.replace(".jpg", "_org.jpg");
- _filenamevon = _filenamevon.replace(".jpg", "_org.jpg");
- FileDeleteOnServer(_filenamenach, _domainname);
- FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
- }
- }
- function UpdateConfigReference(_anzneueref, _domainname){
- var index = 0;
- if (_anzneueref == 1) {
- index = 0;
- }
- else if (_anzneueref == 2) {
- index = 1;
- }
- _filenamenach = REFERENCES[index]["name"];
- _filenamevon = _filenamenach.replace("/config/", "/img_tmp/");
- FileDeleteOnServer(_filenamenach, _domainname);
- FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
- _filenamenach = _filenamenach.replace(".jpg", "_org.jpg");
- _filenamevon = _filenamevon.replace(".jpg", "_org.jpg");
- FileDeleteOnServer(_filenamenach, _domainname);
- FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
- }
- function getNUMBERInfo(){
- return NUMBERS;
- }
- function RenameNUMBER(_alt, _neu){
- if ((_neu.indexOf(".") >= 0) || (_neu.indexOf(",") >= 0) || (_neu.indexOf(" ") >= 0) || (_neu.indexOf("\"") >= 0)) {
- return "Number sequence name must not contain , . \" or a space";
- }
- index = -1;
- found = false;
-
- for (i = 0; i < NUMBERS.length; ++i) {
- if (NUMBERS[i]["name"] == _alt) {
- index = i;
- }
-
- if (NUMBERS[i]["name"] == _neu) {
- found = true;
- }
- }
- if (found) {
- return "Number sequence name is already existing, please choose another name";
- }
- NUMBERS[index]["name"] = _neu;
-
- return "";
- }
- function DeleteNUMBER(_delete){
- if (NUMBERS.length == 1) {
- return "One number sequence is mandatory. Therefore this cannot be deleted"
- }
-
- index = -1;
-
- for (i = 0; i < NUMBERS.length; ++i) {
- if (NUMBERS[i]["name"] == _delete) {
- index = i;
- }
- }
- if (index > -1) {
- NUMBERS.splice(index, 1);
- }
- return "";
- }
- function CreateNUMBER(_numbernew){
- found = false;
-
- for (i = 0; i < NUMBERS.length; ++i) {
- if (NUMBERS[i]["name"] == _numbernew) {
- found = true;
- }
- }
- if (found) {
- return "Number sequence name is already existing, please choose another name";
- }
- _ret = new Object();
- _ret["name"] = _numbernew;
- _ret['digit'] = new Array();
- _ret['analog'] = new Array();
- for (_cat in param) {
- for (_param in param[_cat]) {
- if (param[_cat][_param]["Numbers"] == true) {
- if (typeof (_ret[_cat]) === "undefined") {
- _ret[_cat] = new Object();
- }
-
- _ret[_cat][_param] = new Object();
-
- if (param[_cat][_param]["defaultValue"] === "") {
- _ret[_cat][_param]["found"] = false;
- _ret[_cat][_param]["enabled"] = false;
- }
- else {
- _ret[_cat][_param]["found"] = true;
- _ret[_cat][_param]["enabled"] = true;
- _ret[_cat][_param]["value1"] = param[_cat][_param]["defaultValue"];
- }
-
- _ret[_cat][_param]["anzParam"] = param[_cat][_param]["anzParam"];
- }
- }
- }
- NUMBERS.push(_ret);
- return "";
- }
- function getROIInfo(_typeROI, _number){
- index = -1;
-
- for (var i = 0; i < NUMBERS.length; ++i) {
- if (NUMBERS[i]["name"] == _number) {
- index = i;
- }
- }
- if (index != -1) {
- return NUMBERS[index][_typeROI];
- }
- else {
- return "";
- }
- }
- function RenameROI(_number, _type, _alt, _neu){
- if ((_neu.includes("=")) || (_neu.includes(".")) || (_neu.includes(":")) || (_neu.includes(",")) || (_neu.includes(";")) || (_neu.includes(" ")) || (_neu.includes("\""))) {
- return "ROI name must not contain . : , ; = \" or space";
- }
- index = -1;
- found = false;
- _indexnumber = -1;
-
- for (j = 0; j < NUMBERS.length; ++j) {
- if (NUMBERS[j]["name"] == _number) {
- _indexnumber = j;
- }
- }
- if (_indexnumber == -1) {
- return "Number sequence not existing. ROI cannot be renamed"
- }
- for (i = 0; i < NUMBERS[_indexnumber][_type].length; ++i) {
- if (NUMBERS[_indexnumber][_type][i]["name"] == _alt) {
- index = i;
- }
-
- if (NUMBERS[_indexnumber][_type][i]["name"] == _neu) {
- found = true;
- }
- }
- if (found) {
- return "ROI name is already existing, please choose another name";
- }
- NUMBERS[_indexnumber][_type][index]["name"] = _neu;
-
- return "";
- }
- function DeleteNUMBER(_delte) {
- if (NUMBERS.length == 1) {
- return "The last number cannot be deleted"
- }
-
- index = -1;
-
- for (i = 0; i < NUMBERS.length; ++i) {
- if (NUMBERS[i]["name"] == _delte) {
- index = i;
- }
- }
- if (index > -1) {
- NUMBERS.splice(index, 1);
- }
- return "";
- }
- function CreateROI(_number, _type, _pos, _roinew, _x, _y, _dx, _dy, _CCW){
- _indexnumber = -1;
-
- for (j = 0; j < NUMBERS.length; ++j) {
- if (NUMBERS[j]["name"] == _number) {
- _indexnumber = j;
- }
- }
- if (_indexnumber == -1) {
- return "Number sequence not existing. ROI cannot be created"
- }
- found = false;
-
- for (i = 0; i < NUMBERS[_indexnumber][_type].length; ++i) {
- if (NUMBERS[_indexnumber][_type][i]["name"] == _roinew) {
- found = true;
- }
- }
- if (found) {
- return "ROI name is already existing, please choose another name";
- }
- _ret = new Object();
- _ret["name"] = _roinew;
- _ret["x"] = _x;
- _ret["y"] = _y;
- _ret["dx"] = _dx;
- _ret["dy"] = _dy;
- _ret["ar"] = _dx / _dy;
- _ret["CCW"] = _CCW;
- NUMBERS[_indexnumber][_type].splice(_pos+1, 0, _ret);
- return "";
- }
|