@Override public void run() { log.AddToDisplay.Display("Selectra Junior handler started...", DisplayMessageType.TITLE); log.AddToDisplay.Display( "Checking available ports on this system...", DisplayMessageType.INFORMATION); String[] ports = Manager.getSerialPorts(); log.AddToDisplay.Display("Avaliable ports:", DisplayMessageType.TITLE); for (int i = 0; i < ports.length; i++) { log.AddToDisplay.Display(ports[i], log.DisplayMessageType.INFORMATION); } log.AddToDisplay.Display( "Now connecting to port " + RS232Settings.COMPORT, DisplayMessageType.TITLE); if (Manager.openPortforData("Selectra Junior")) { log.AddToDisplay.Display("Connected sucessfully", DisplayMessageType.INFORMATION); setTestIDs(); setCalcTestIDs(); TestStart = Integer.parseInt(getSpecimenFilter(7)); // SelectraJunior.HandleDataInput("{R;JUNIOR;N;2014110403 ; ; // ;M; 5;UREA;4.9 ; ;mmol/l;CREA;25 ; N // ;umol/l;HDL ;0.55 ; D N ;mmol/l;TRIG;1.79 ; N // ;mmol/l;CHOL;3.7 ; ;mmol/l;}"); } }
private static void processMessage() { if (null == datarecieved.toString() || datarecieved.toString().isEmpty()) return; String[] DataParts = datarecieved.toString().split(";"); if (DataParts.length > 5) { String Type = DataParts[2].trim(); int mID = 0; float value = 0; boolean flag = false; String specimen_id = DataParts[3].trim(); for (int i = TestStart; i < DataParts.length; i += 4) { mID = getMeasureID(DataParts[i].trim()); if (mID > 0) { try { value = Float.parseFloat(DataParts[i + 1].trim()); } catch (NumberFormatException e) { try { value = 0; } catch (NumberFormatException ex) { } } PrepareCalcTests(DataParts[i].trim(), value); if (SaveResults(specimen_id, mID, value)) { flag = true; } } } /// now work on the calculated tests and send to BLIS for (int i = 0; i < calctestIDs.size(); i++) { mID = getMeasureID(calctestIDs.get(i).split(";")[0].trim()); if (mID > 0) { try { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("JavaScript"); value = Float.parseFloat(String.valueOf(engine.eval(calctestIDs.get(i).split(";")[1]))); } catch (NumberFormatException e) { value = 0; } catch (ScriptException ex) { log.logger.Logger("Could not perform calculation:" + calctestIDs.get(i).split(";")[1]); // log.logger.PrintStackTrace(ex); value = 0; } // PrepareCalcTests(DataParts[i].trim(),value); if (SaveResults(specimen_id, mID, value)) { flag = true; } } } if (flag) { log.AddToDisplay.Display( "Results with Code: " + specimen_id + " sent to BLIS sucessfully", DisplayMessageType.INFORMATION); } else { log.AddToDisplay.Display( "Test with Code: " + specimen_id + " not Found on BLIS", DisplayMessageType.WARNING); } } }
public void Stop() { if (Manager.closeOpenedPort()) { log.AddToDisplay.Display("Port Closed sucessfully", log.DisplayMessageType.INFORMATION); } }