package art.servers.rtzserver.controller; import art.library.interop.InteropParameters; import art.library.interop.InteropResponse; import art.library.interop.serialization.Serialization; import art.library.interop.serialization.SerializationException; import art.library.model.devices.DeviceAction; import art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerConfiguration; import art.library.model.devices.colors.controller.RTZ32.commands.RTZ32_Commands_Configuration_Write; import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration; import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Group; import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Program; import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Program_Group; import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Program_Trolley_Retractable; import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Program_VariablePhase; import art.library.model.devices.colors.controller.RTZ32.information.RTZ32_Information_Program; import art.library.model.devices.colors.controller.RTZ32.information.RTZ32_Information_Programs; import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Calculate_TMAX_TIMF_Result; import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Persistent_Configuration; import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Persistent_Configurations; import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Report_Information; import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Validation_Result; import art.library.model.devices.etd.EtdStatus; import art.servers.ServerException; import art.servers.Shared; import art.servers.rtzserver.types.RTZ32_CalculationPhase; import art.servers.rtzserver.utils.VALIDATION; import art.servers.types.HttpAuthentication; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; public class ListenerImplementation extends art.servers.controller.ListenerImplementation { public InteropResponse print(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String deviceIdentifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; String format = (String) parameters.getParameterValue("format"); String type = (String) parameters.getParameterValue("type"); Controller_RTZ32 controller = (art.servers.rtzserver.controller.Controller_RTZ32)Shared.getDeviceController(deviceIdentifier); if (format.equalsIgnoreCase("xls")) { RTZ32_Report_Information reportInformation = parameters.getBodyContentValue(RTZ32_Report_Information.class); byte[] data = controller.printConfiguration(reportInformation, format, language); InteropResponse response = new InteropResponse(data); if (format.equalsIgnoreCase("xlsx")) { response.mime = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } if (format.equalsIgnoreCase("xls")) { response.mime = "application/vnd.ms-excel"; } if (format.equalsIgnoreCase("xlsm")) { response.mime = "application/application/vnd.ms-excel.sheet.macroEnabled.12"; } if (format.equalsIgnoreCase("pdf")) { response.mime = "application/pdf"; } if (format.equalsIgnoreCase("csv")) { response.mime = "application/csv"; } response.name = deviceIdentifier + "." + format; return(response); } if (format.equalsIgnoreCase("pdf")) { if (type.equalsIgnoreCase("CCT") == true) { RTZ32_Report_Information reportInformation = parameters.getBodyContentValue(RTZ32_Report_Information.class); byte[] data = controller.printCCT(reportInformation, format, language); InteropResponse response = new InteropResponse(data); if (format.equalsIgnoreCase("xlsx")) { response.mime = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } if (format.equalsIgnoreCase("xls")) { response.mime = "application/vnd.ms-excel"; } if (format.equalsIgnoreCase("xlsm")) { response.mime = "application/application/vnd.ms-excel.sheet.macroEnabled.12"; } if (format.equalsIgnoreCase("pdf")) { response.mime = "application/pdf"; } if (format.equalsIgnoreCase("csv")) { response.mime = "application/csv"; } response.name = deviceIdentifier + "." + format; return(response); } RTZ32_Report_Information reportInformation = parameters.getBodyContentValue(RTZ32_Report_Information.class); byte[] data = controller.printJuzgados(reportInformation, format, language); InteropResponse response = new InteropResponse(data); if (format.equalsIgnoreCase("xlsx")) { response.mime = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } if (format.equalsIgnoreCase("xls")) { response.mime = "application/vnd.ms-excel"; } if (format.equalsIgnoreCase("xlsm")) { response.mime = "application/application/vnd.ms-excel.sheet.macroEnabled.12"; } if (format.equalsIgnoreCase("pdf")) { response.mime = "application/pdf"; } if (format.equalsIgnoreCase("csv")) { response.mime = "application/csv"; } response.name = deviceIdentifier + "." + format; return(response); } throw new Exception("Not implemented format"); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse sendCommands(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String identifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; Controller_RTZ32 controller = (art.servers.rtzserver.controller.Controller_RTZ32)Shared.getDeviceController(identifier); DeviceAction[] laction = controller.sendCommands(parameters); return(new InteropResponse(laction)); } catch (ServerException exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage())); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse getTrafficData(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String identifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; long timestamp = (parameters.hasParameter("timestamp") == true) ? getTimestamp((String)parameters.getParameterValue("timestamp")) : 0; Controller_RTZ32 controller = (art.servers.rtzserver.controller.Controller_RTZ32)Shared.getDeviceController(identifier); List ldata = controller.getTrafficData(timestamp); return(new InteropResponse(ldata.toArray())); } catch (ServerException exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage())); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } // public InteropResponse listPrograms(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String deviceIdentifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; RTZ32_Information_Programs programs = Controller_RTZ32_Database.listPrograms(deviceIdentifier); return(new InteropResponse(programs, false)); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse getProgram(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String deviceIdentifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; String programNumber = (String)parameters.getParameterValue("program"); RTZ32_Information_Program program = Controller_RTZ32_Database.getProgram(deviceIdentifier, programNumber); return(new InteropResponse(program, false)); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse addProgram(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { RTZ32_Information_Program program = parameters.getBodyContentValue(RTZ32_Information_Program.class); return(new InteropResponse(Controller_RTZ32_Database.addProgram(program), false)); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse deleteProgram(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String deviceIdentifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; String programIdentifier = (String)parameters.getParameterValue("program"); return(new InteropResponse(Controller_RTZ32_Database.deleteProgram(deviceIdentifier, programIdentifier), false)); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse saveProgram(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { RTZ32_Information_Program program = parameters.getBodyContentValue(RTZ32_Information_Program.class); String identifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; String username = (parameters.hasParameter("username") == true) ? (String)parameters.getParameterValue("username") : "?"; //none,normal,eprom String type = (parameters.hasParameter("type") == true) ? (String)parameters.getParameterValue("type") : "?"; Controller_RTZ32 controller = (art.servers.rtzserver.controller.Controller_RTZ32)Shared.getDeviceController(identifier); RTZ32_Information_Program program0 = Controller_RTZ32_Database.getProgram(identifier, "0"); if (program0 == null) { program0 = Serialization.clone(program); program0.program = 0; Controller_RTZ32_Database.addProgram(program0); } if (program.program == 0) { program0 = program; } RTZ32_Validation_Result resultNormalValidation = null; RTZ32_Validation_Result resultEpromValidation = null; if (type.equalsIgnoreCase("none") == true) { resultNormalValidation = new RTZ32_Validation_Result(); resultEpromValidation = new RTZ32_Validation_Result(); } else if (type.equalsIgnoreCase("normal") == true) { resultNormalValidation = VALIDATION.validate(controller.getDevice(), program, language); resultEpromValidation = new RTZ32_Validation_Result(); } else if (type.equalsIgnoreCase("eprom") == true) { resultNormalValidation = new RTZ32_Validation_Result(); resultEpromValidation = VALIDATION.eprom(controller.getDevice(), program, language); } RTZ32_Validation_Result result = new RTZ32_Validation_Result(); result.errors.addAll(resultNormalValidation.errors); result.errors.addAll(resultEpromValidation.errors); result.warnings.addAll(resultNormalValidation.warnings); result.warnings.addAll(resultEpromValidation.warnings); if (result.hasErrors() == true) { if (type.equalsIgnoreCase("none") == true) { program.validated = false; program.username = username; if (program.program != program0.program) controller.adjustConfiguration(program, program0); Controller_RTZ32_Database.addProgram(program); if (program.program == 0) controller.adjustConfigurationPrograms(program); } return new InteropResponse(result, false); } else { if (type.equalsIgnoreCase("none") == true) { program.validated = false; program.username = username; Controller_RTZ32_Database.addProgram(program); if (program.program == 0) controller.adjustConfigurationPrograms(program); } else if (type.equalsIgnoreCase("normal") == true) { program.validated = true; program.username = username; Controller_RTZ32_Database.addProgram(program); if (program.program == 0) controller.adjustConfigurationPrograms(program); } } if (program.program != program0.program) controller.adjustConfiguration(program, program0); return new InteropResponse(result, false); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } // // public InteropResponse validateProgramNormal(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { RTZ32_Information_Program program = parameters.getBodyContentValue(RTZ32_Information_Program.class); String identifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; Controller_RTZ32 controller = (art.servers.rtzserver.controller.Controller_RTZ32)Shared.getDeviceController(identifier); return new InteropResponse(VALIDATION.validate(controller.getDevice(), program, language), false); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse validateProgramEPROM(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { RTZ32_Information_Program program = parameters.getBodyContentValue(RTZ32_Information_Program.class); String identifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; Controller_RTZ32 controller = (art.servers.rtzserver.controller.Controller_RTZ32)Shared.getDeviceController(identifier); return new InteropResponse(VALIDATION.eprom(controller.getDevice(), program, language), false); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } // // public InteropResponse listConfigurations(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String deviceIdentifier = (String)parameters.getParameterValue("device"); long timestamp1 = (parameters.hasParameter("from") == true) ? getTimestamp((String)parameters.getParameterValue("from")) : 0; long timestamp2 = (parameters.hasParameter("to") == true) ? getTimestamp((String)parameters.getParameterValue("to")) : System.currentTimeMillis(); RTZ32_Persistent_Configurations configurations = Controller_RTZ32_Database.listConfigurations(deviceIdentifier, timestamp1, timestamp2); return(new InteropResponse(configurations, false)); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse getConfiguration(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String deviceIdentifier = (String)parameters.getParameterValue("device"); long timestamp = getTimestamp((String)parameters.getParameterValue("timestamp")); RTZ32_Persistent_Configuration configuration = Controller_RTZ32_Database.getConfiguration(deviceIdentifier, timestamp); return(new InteropResponse(configuration, false)); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse addConfiguration(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { RTZ32_Persistent_Configuration configuration = parameters.getBodyContentValue(RTZ32_Persistent_Configuration.class); configuration.username = (String)parameters.getParameterValue("username"); return(new InteropResponse(Controller_RTZ32_Database.addConfiguration(configuration), false)); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse deleteConfiguration(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); HttpAuthentication authentication = getHttpAuthentication(parameters); try { String deviceIdentifier = (String)parameters.getParameterValue("device"); long timestamp = getTimestamp((String)parameters.getParameterValue("timestamp")); InteropResponse response = new InteropResponse(Controller_RTZ32_Database.deleteConfiguration(deviceIdentifier, timestamp), false); Controller_RTZ32 controller = (art.servers.rtzserver.controller.Controller_RTZ32)Shared.getDeviceController(deviceIdentifier); Shared.traceInformation(Shared.getApplicationName(), "Delete configuration", controller.name + ", " + new Date(timestamp), authentication, language); return response; } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse previewConfiguration(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String identifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; Controller_RTZ32 controller = (art.servers.rtzserver.controller.Controller_RTZ32)Shared.getDeviceController(identifier); RTZ32_Commands_Configuration_Write commands = parameters.getBodyContentValue(RTZ32_Commands_Configuration_Write.class); RTZ32_ControllerConfiguration configurationCurrent = Serialization.clone(controller.getController().getDeviceConfiguration()); RTZ32_Configuration configurationSelected = commands.configuration; Controller_RTZ32_Factory_Configuration factoryCurrent = new Controller_RTZ32_Factory_Configuration(configurationCurrent.rtz32); Controller_RTZ32_Factory_Configuration factorySelected = new Controller_RTZ32_Factory_Configuration(configurationSelected); factoryCurrent.serialize(); factorySelected.serialize(); if (commands.operationTables == false) { // for (int i=5; i<=7; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); for (int i=33; i<=34; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); for (int i=38; i<=40; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); for (int i=41; i<=45; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); for (int i=50; i<=60; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); for (int i=64; i<=69; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); for (int i=31; i<=32; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); for (int i=70; i<=71; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); factorySelected.tables.put(75, factoryCurrent.tables.get(75)); factorySelected.tables.put(78, factoryCurrent.tables.get(78)); // factorySelected.tables.put(80, factoryCurrent.tables.get(80)); for (int i=81; i<=85; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); } if (commands.distributionTables == true) { // for (int i=1; i<=4; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); // for (int i=35; i<=37; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); // for (int i=72; i<=74; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); // Se ha de calcular factorySelected.tables.put(46, factoryCurrent.tables.get(46)); factorySelected.tables.put(79, factoryCurrent.tables.get(79)); // factorySelected.tables.put(80, factoryCurrent.tables.get(80)); // factorySelected.tables.put(95, factoryCurrent.tables.get(95)); if ((commands.programs == null) || (commands.programs.size() == 0)) { // for (int i=11; i<=28; i++) factorySelected.tables.put(i, factoryCurrent.tables.get(i)); } else { for(int i=1; i<=18; i++) { boolean existe = false; for(Integer programNumber : commands.programs) { if (programNumber == i) existe = true; } if (existe == false) { factorySelected.tables.put(i + 10, factoryCurrent.tables.get(i + 10)); } } } } return new InteropResponse(factorySelected.deserialize(), false); } catch (Exception exception) { exception.printStackTrace(); throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse calculateTimes(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { RTZ32_Information_Program program = parameters.getBodyContentValue(RTZ32_Information_Program.class); String identifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; Controller_RTZ32 controller = (art.servers.rtzserver.controller.Controller_RTZ32)Shared.getDeviceController(identifier); RTZ32_Information_Program program0 = Controller_RTZ32_Database.getProgram(identifier, "0"); RTZ32_Calculate_TMAX_TIMF_Result result = new RTZ32_Calculate_TMAX_TIMF_Result(); result.ltmax = new ArrayList(); result.ltimf = new ArrayList(); RTZ32_Configuration_Program programCfg = program.configuration.rtz32.getProgram(program.program); int numberOfVariablePhase = 0; for (int i=0; i calculationPhase[i].endtime) { if ( ((calculationPhase[i].starttime <= calculationPhase[i].tInicioVerdeTranviasiguiente1) && (calculationPhase[i].tInicioVerdeTranviasiguiente1 <= programCfg.cycle)) || ((calculationPhase[i].starttime <= calculationPhase[i].tInicioVerdeTranviasiguiente3) && (calculationPhase[i].tInicioVerdeTranviasiguiente3 <= programCfg.cycle)) || ((0 <= calculationPhase[i].tInicioVerdeTranviasiguiente1) && (calculationPhase[i].tInicioVerdeTranviasiguiente1 <= calculationPhase[i].endtime)) || ((0 <= calculationPhase[i].tInicioVerdeTranviasiguiente3) && (calculationPhase[i].tInicioVerdeTranviasiguiente3 <= calculationPhase[i].endtime)) ) { // Determine the type of the phase for (int r=0; r=calculationPhase.length) i2 = 0; int i3 = i2+1; if (i3>=calculationPhase.length) i3 = 0; int i4 = i3+1; if (i4>=calculationPhase.length) i4 = 0; RTZ32_CalculationPhase phase1 = calculationPhase[i1]; RTZ32_CalculationPhase phase2 = calculationPhase[i2]; RTZ32_CalculationPhase phase3 = calculationPhase[i3]; RTZ32_CalculationPhase phase4 = calculationPhase[i4]; switch (phase1.type) { case RTZ32_CalculationPhase.TYPE_NO_TRANVIA: { switch (phase2.type) { case RTZ32_CalculationPhase.TYPE_NO_TRANVIA: { // Nothing to do } break; case RTZ32_CalculationPhase.TYPE_TRANVIA_ESCAMOTEABLE: { // Caso 1 for (int r=0; r result.general_timf) result.general_timf = calculationPhase[i].timF; result.ltmax.add(calculationPhase[i].tmaxWaitTime); result.ltimf.add(calculationPhase[i].timF); } return new InteropResponse(result, false); } catch (Exception exception) { Shared.printstack(language, exception); throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } private boolean inRange (int starttime1, int endtime1, int time) { try { int starttime = starttime1; int endtime = endtime1; if (starttime > endtime) { starttime = endtime1; endtime = starttime1; } return((starttime <= time) && (time <= endtime)); } catch (Exception e) { return(false); } } // // public InteropResponse listMaps(InteropParameters parameters) throws SerializationException { String language = parameters.getParameterValue("language"); try { String identifier = (String)parameters.getParameterValue("controller"); if (identifier == null) identifier = (String)parameters.getParameterValue("identifier"); if (identifier == null) identifier = (String)parameters.getParameterValue("device"); List maps = new ArrayList(); File folder = new File("data/" + Shared.getApplicationName() + "/maps/" + identifier + "/"); if (folder.exists() == false) throw new SerializationException(Shared.getMessage(language, "No maps")); for (File file : folder.listFiles()) maps.add(file.getName().replace(".svg", "")); InteropResponse response = new InteropResponse(maps.toArray(new String[maps.size()]), true); Object[] object = response.getResponse(); return response; } catch (SerializationException exception) { throw exception; } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse getMap(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String identifier = (String)parameters.getParameterValue("controller"); if (identifier == null) identifier = (String)parameters.getParameterValue("identifier"); if (identifier == null) identifier = (String)parameters.getParameterValue("device"); String name = (String)parameters.getParameterValue("name"); File file = new File("data/" + Shared.getApplicationName() + "/maps/" + identifier + "/" + name + ".svg"); if (file.exists() == false) throw new SerializationException(Shared.getMessage(language, "Map does not exists")); byte[] data = new byte[(int)file.length()]; FileInputStream fis = new FileInputStream(file); fis.read(data); fis.close(); InteropResponse response = new InteropResponse(data); response.mime = "image/svg+xml"; return response; } catch (SerializationException exception) { throw exception; } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse addMap(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String identifier = (String)parameters.getParameterValue("controller"); if (identifier == null) identifier = (String)parameters.getParameterValue("identifier"); if (identifier == null) identifier = (String)parameters.getParameterValue("device"); String name = parameters.getParameterValue("name"); String newIdentifier = identifier.substring(0, identifier.length()-1); newIdentifier = newIdentifier + "0"; byte[] data = parameters.getBodyContentValue(byte[].class); File file = new File("data/" + Shared.getApplicationName() + "/maps/" + identifier + "/" + name + ".svg"); file.getParentFile().mkdirs(); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file)); bos.write(data); bos.close(); return new InteropResponse(new Boolean(true)); } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } public InteropResponse deleteMap(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { String identifier = (String)parameters.getParameterValue("controller"); if (identifier == null) identifier = (String)parameters.getParameterValue("identifier"); if (identifier == null) identifier = (String)parameters.getParameterValue("device"); String name = parameters.getParameterValue("name"); String newIdentifier = identifier.substring(0, identifier.length()-1); newIdentifier = newIdentifier + "0"; File file = new File("data/" + Shared.getApplicationName() + "/maps/" + identifier + "/" + name + ".svg"); if (file.exists() == true) return new InteropResponse(new Boolean(file.delete())); throw new SerializationException(Shared.getMessage(language, "Map does not exists")); } catch (SerializationException exception) { throw exception; } catch (Exception exception) { throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } // // https://172.16.11.210:8002/art?operation=getDevices×tamp=0&token=test,test // https://172.16.11.210:8002/art?operation=listConfigurations&device=controller-zaragoza-90020&&token=test,test // https://172.16.11.210:8002/art?operation=getConfiguration&device=controller-zaragoza-90020×tamp=2021-07-08T10:27:44.905Z&token=test,test } /* public InteropResponse calculateTimes(InteropParameters parameters) throws SerializationException { String language = (String)parameters.getParameterValue("language"); try { RTZ32_Information_Program program = parameters.getBodyContentValue(RTZ32_Information_Program.class); String identifier = (parameters.hasParameter("device") == true) ? (String)parameters.getParameterValue("device") : null; Controller_RTZ32 controller = (art.servers.rtzserver.controller.Controller_RTZ32)Shared.getDeviceController(identifier); RTZ32_Information_Program program0 = Controller_RTZ32_Database.getProgram(identifier, "0"); RTZ32_Calculate_TMAX_TIMF_Result result = new RTZ32_Calculate_TMAX_TIMF_Result(); RTZ32_Configuration_Program programCfg = program.configuration.rtz32.getProgram(program.program); int numberOfVariablePhase = 0; for (int i=0; i calculationPhase[i].endtime) { if ( ((calculationPhase[i].starttime <= calculationPhase[i].tInicioVerdeTranviasiguiente1) && (calculationPhase[i].tInicioVerdeTranviasiguiente1 <= programCfg.cycle)) || ((calculationPhase[i].starttime <= calculationPhase[i].tInicioVerdeTranviasiguiente3) && (calculationPhase[i].tInicioVerdeTranviasiguiente3 <= programCfg.cycle)) || ((0 <= calculationPhase[i].tInicioVerdeTranviasiguiente1) && (calculationPhase[i].tInicioVerdeTranviasiguiente1 <= calculationPhase[i].endtime)) || ((0 <= calculationPhase[i].tInicioVerdeTranviasiguiente3) && (calculationPhase[i].tInicioVerdeTranviasiguiente3 <= calculationPhase[i].endtime)) ) { // Determine the type of the phase for (int r=0; r=calculationPhase.length) i2 = 0; int i3 = i2+1; if (i3>=calculationPhase.length) i3 = 0; int i4 = i3+1; if (i4>=calculationPhase.length) i4 = 0; RTZ32_CalculationPhase phase1 = calculationPhase[i1]; RTZ32_CalculationPhase phase2 = calculationPhase[i2]; RTZ32_CalculationPhase phase3 = calculationPhase[i3]; RTZ32_CalculationPhase phase4 = calculationPhase[i4]; switch (phase1.type) { case RTZ32_CalculationPhase.TYPE_NO_TRANVIA: { switch (phase2.type) { case RTZ32_CalculationPhase.TYPE_NO_TRANVIA: { // Nothing to do } break; case RTZ32_CalculationPhase.TYPE_TRANVIA_ESCAMOTEABLE: { System.out.println(phase1.number + " - " + phase1.starttime + " --> " + phase1.endtime); System.out.println(phase2.number + " - " + phase2.starttime + " --> " + phase2.endtime); for (int r=0; r " + retractable.endTime); } } phase1.tfijoSiguiente2 = phase3.starttime - phase2.endtime; } break; case RTZ32_CalculationPhase.TYPE_TRANVIA_NO_ESCAMOTEABLE: { calculationPhase[i].tmaxWaitTime = 0; calculationPhase[i].timF = 0; } break; } } break; case RTZ32_CalculationPhase.TYPE_TRANVIA_ESCAMOTEABLE: { switch (phase2.type) { case RTZ32_CalculationPhase.TYPE_NO_TRANVIA: { } break; case RTZ32_CalculationPhase.TYPE_TRANVIA_ESCAMOTEABLE: { // Nothing to do } break; case RTZ32_CalculationPhase.TYPE_TRANVIA_NO_ESCAMOTEABLE: { // Nothing to do } break; } } break; case RTZ32_CalculationPhase.TYPE_TRANVIA_NO_ESCAMOTEABLE: { switch (phase2.type) { case RTZ32_CalculationPhase.TYPE_NO_TRANVIA: { } break; case RTZ32_CalculationPhase.TYPE_TRANVIA_ESCAMOTEABLE: { // Nothing to do } break; case RTZ32_CalculationPhase.TYPE_TRANVIA_NO_ESCAMOTEABLE: { calculationPhase[i].tmaxWaitTime = 0; calculationPhase[i].timF = 0; } break; } } break; } } return new InteropResponse(result, false); } catch (Exception exception) { Shared.printstack(language, exception); throw new SerializationException(Shared.getMessage(language, exception.getMessage()), exception); } } */