diff options
Diffstat (limited to 'SOURCE/Zasor2/LoadSetup.pde')
| -rw-r--r-- | SOURCE/Zasor2/LoadSetup.pde | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/SOURCE/Zasor2/LoadSetup.pde b/SOURCE/Zasor2/LoadSetup.pde new file mode 100644 index 0000000..4fece46 --- /dev/null +++ b/SOURCE/Zasor2/LoadSetup.pde @@ -0,0 +1,99 @@ +//***************************************************** +// чтение файла настроек и данных +// все настройки, клиенты, камазы и 1 взвешивания = data/ + +void loadSetup() { + JSONArray values; + + // Считываем путь до папки с настройками из put/sourse.json: + try { + values = loadJSONArray(put + "source.json"); // = data/ + ... // Ядиск + for (int i = 0; i < values.size(); i++) { + JSONObject animal = values.getJSONObject(i); + filePath = animal.getString("filePath"); // адрес папки с Ядиск + println(filePath); + } + } + catch (Exception e) { + printFileLog("File 'source.json' - undetected"); + selectFolder("Select a folder to process:", "folderSelected"); + while (!flagWork) { + delay(100); + } + } + + values = new JSONArray(); + JSONObject animal = new JSONObject(); + animal.setString("filePath", filePath); + values.setJSONObject(0, animal); + saveJSONArray(values, "data/" + "source.json"); + + println("NEXT--->>>"); + + try { + values = loadJSONArray(filePath + "option.json"); // = data/Custom/ + ... + for (int i = 0; i < values.size(); i++) { + animal = values.getJSONObject(i); + serialPort = animal.getInt("COMport"); // номер COM порта + portSpeed = animal.getInt("portSpeed"); // скорость порта (9600) + lf = animal.getInt("numberScales"); // кол-во символов в посылке с весов + beginIn = animal.getInt("beginIn"); // начало значащих символов посылки + vIn = animal.getString("scalesIn"); // начало не значащих символов посылки + vOut = animal.getString("scalesOut"); // конец не значащих символов посылки + vOff = animal.getString("scalesOff"); // вся посылка полностью + //filePath = animal.getString("filePath"); // Ядиск + threshold = animal.getInt("threshold"); // нижний порог для обработки з2 + stab = animal.getInt("stabWeight"); // кол-во весовых посылок для "стабильного" веса + tara = animal.getInt("tara"); // минимальная тара камаза для % + protsUmolch = animal.getInt("protsUmolch"); // % засора по умолчанию + numberReport = animal.getInt("numberReport"); // порядковый номер отчета + } + } + catch (Exception e) { + printFileLog("File 'option.json' - undetected"); + System.exit(1); + } + + try { + values = loadJSONArray(filePath + "temp.json"); + for (int i = 0; i < values.size(); ++i) { + animal = values.getJSONObject(i); + dataM1[animal.getInt("id")][1] = "" + animal.getInt("zas2"); + dataM1[animal.getInt("id")][2] = animal.getString("nomer"); + dataM1[animal.getInt("id")][3] = animal.getString("client"); + dataM1[animal.getInt("id")][4] = animal.getString("object"); + dataM1[animal.getInt("id")][5] = "" + animal.getInt("price"); + dataM1[animal.getInt("id")][6] = "" + animal.getInt("prots"); + dataM1[animal.getInt("id")][7] = "" + animal.getInt("arenda"); + dataM1[animal.getInt("id")][8] = "" + animal.getInt("dopsor"); + dataM1[animal.getInt("id")][9] = animal.getString("note"); + dataM1[animal.getInt("id")][0] = "" + animal.getInt("ves"); + dataM1[animal.getInt("id")][10] = animal.getString("time"); + dataM1[animal.getInt("id")][11] = "" + animal.getInt("1/2"); + } + } + catch (Exception e) { + printFileLog("File 'temp.json' - undetected"); + System.exit(1); + } + + String[] temp; + temp = loadStrings(filePath + "kamazy.txt"); + if (temp == null) { + printFileLog("File 'kamazy.txt' - undetected"); + } else { + kamazy = temp; + } + + temp = loadStrings(filePath + "clients.txt"); + if (temp == null) { + printFileLog("File 'clients.txt' - undetected"); + } else { + clients = temp; + } + + for (int i = 0; i < m2; ++i) { + inData[i] = ""; + } + inData[6] = str(protsUmolch); +} |
