@Test public void testGetModelVariables() throws AlreadyUsedPin { HwEmulation dut = new RaspiGpioSimulator(Builder.getBuilderFor(buildProperty())); List<Fmi2ScalarVariable> variables = dut.getModelVariables(); assertEquals(3,variables.size() ); Fmi2ScalarVariable input1Var = variables.get(0); Fmi2ScalarVariable output1Var = variables.get(1); Fmi2ScalarVariable output2Var = variables.get(2); for (Fmi2ScalarVariable fmi2ScalarVariable : variables) { assertIsBooleanVariable(fmi2ScalarVariable); } assertEquals("GPIO 2",input1Var.getName() ); assertIsInputVariable(input1Var); assertEquals("GPIO 1",output1Var.getName() ); assertIsOutputVariable(output1Var); assertEquals("GPIO 3",output2Var.getName() ); assertIsOutputVariable(output2Var); }
@Override public List<Fmi2ScalarVariable> getModelVariables() { LinkedList<Fmi2ScalarVariable> list = new LinkedList<Fmi2ScalarVariable>(); for (org.raspinloop.config.Pin pin : properties.getInputPins()) { list.add(createBooleanInput(pin.getName(), "Input signal related to pin " + pin.getName(), getInputReference(pin))); } for (org.raspinloop.config.Pin pin : properties.getOutputPins()) { list.add(createBooleanOutput(pin.getName(), "Output signal related to pin " + pin.getName(), getOutputReference(pin))); } for (HardwareProperties comp : properties.getAllComponents()) { HwEmulation emulationComp = getEmulationInstance(comp); if (emulationComp != null) list.addAll(emulationComp.getModelVariables()); } return list; }
RaspiGpioSimulator implements GpioProviderHwEmulation { @Override public List<Fmi2ScalarVariable> getModelVariables() { LinkedList<Fmi2ScalarVariable> list = new LinkedList<Fmi2ScalarVariable>(); for (org.raspinloop.config.Pin pin : properties.getInputPins()) { list.add(createBooleanInput(pin.getName(), "Input signal related to pin " + pin.getName(), getInputReference(pin))); } for (org.raspinloop.config.Pin pin : properties.getOutputPins()) { list.add(createBooleanOutput(pin.getName(), "Output signal related to pin " + pin.getName(), getOutputReference(pin))); } for (HardwareProperties comp : properties.getAllComponents()) { HwEmulation emulationComp = getEmulationInstance(comp); if (emulationComp != null) list.addAll(emulationComp.getModelVariables()); } return list; } }
RaspiGpioSimulator implements GpioProviderHwEmulation { @Override public List<Fmi2ScalarVariable> getModelVariables() { LinkedList<Fmi2ScalarVariable> list = new LinkedList<Fmi2ScalarVariable>(); for (org.raspinloop.config.Pin pin : properties.getInputPins()) { list.add(createBooleanInput(pin.getName(), "Input signal related to pin " + pin.getName(), getInputReference(pin))); } for (org.raspinloop.config.Pin pin : properties.getOutputPins()) { list.add(createBooleanOutput(pin.getName(), "Output signal related to pin " + pin.getName(), getOutputReference(pin))); } for (HardwareProperties comp : properties.getAllComponents()) { HwEmulation emulationComp = getEmulationInstance(comp); if (emulationComp != null) list.addAll(emulationComp.getModelVariables()); } return list; } RaspiGpioSimulator(HardwareBuilder builder); }
RaspiGpioSimulator implements GpioProviderHwEmulation { @Override public List<Fmi2ScalarVariable> getModelVariables() { LinkedList<Fmi2ScalarVariable> list = new LinkedList<Fmi2ScalarVariable>(); for (org.raspinloop.config.Pin pin : properties.getInputPins()) { list.add(createBooleanInput(pin.getName(), "Input signal related to pin " + pin.getName(), getInputReference(pin))); } for (org.raspinloop.config.Pin pin : properties.getOutputPins()) { list.add(createBooleanOutput(pin.getName(), "Output signal related to pin " + pin.getName(), getOutputReference(pin))); } for (HardwareProperties comp : properties.getAllComponents()) { HwEmulation emulationComp = getEmulationInstance(comp); if (emulationComp != null) list.addAll(emulationComp.getModelVariables()); } return list; } RaspiGpioSimulator(HardwareBuilder builder); @Override String getType(); boolean hasPin(Pin pin); void setMode(Pin pin, PinMode mode); void setState(Pin pin, PinState state); PinState getState(Pin pin); @Override String getHWGuid(); @Override boolean enterInitialize(); @Override boolean exitInitialize(); @Override void terminate(); @Override void reset(); @Override List<Double> getReal(List<Integer> refs); @Override List<Integer> getInteger(List<Integer> refs); @Override boolean setReal(Map<Integer, Double> ref_values); @Override boolean setInteger(Map<Integer, Integer> ref_values); @Override List<Boolean> getBoolean(List<Integer> refs); PinMode getMode(Pin pin); @Override boolean setBoolean(Map<Integer, Boolean> ref_values); @Override boolean isTerminated(); @Override List<Fmi2ScalarVariable> getModelVariables(); String getName(); @Override void addListener(Pin pin, PinListener listener); @Override void removeListener(Pin pin, PinListener listener); @Override void removeAllListeners(); @Override void export(Pin pin, PinMode mode); @Override void export(Pin pin, PinMode arg1, PinState arg2); @Override void unexport(Pin pin); @Override boolean isExported(Pin pin); @Override void setPullResistance(Pin pin, PinPullResistance resistance); @Override PinPullResistance getPullResistance(Pin pin); @Override void setPwm(Pin pin, int value); @Override void setPwmRange(Pin pin, int range); @Override int getPwm(Pin pin); @Override void setValue(Pin pin, double value); @Override double getValue(Pin pin); @Override void shutdown(); @Override boolean isShutdown(); }
RaspiGpioSimulator implements GpioProviderHwEmulation { @Override public List<Fmi2ScalarVariable> getModelVariables() { LinkedList<Fmi2ScalarVariable> list = new LinkedList<Fmi2ScalarVariable>(); for (org.raspinloop.config.Pin pin : properties.getInputPins()) { list.add(createBooleanInput(pin.getName(), "Input signal related to pin " + pin.getName(), getInputReference(pin))); } for (org.raspinloop.config.Pin pin : properties.getOutputPins()) { list.add(createBooleanOutput(pin.getName(), "Output signal related to pin " + pin.getName(), getOutputReference(pin))); } for (HardwareProperties comp : properties.getAllComponents()) { HwEmulation emulationComp = getEmulationInstance(comp); if (emulationComp != null) list.addAll(emulationComp.getModelVariables()); } return list; } RaspiGpioSimulator(HardwareBuilder builder); @Override String getType(); boolean hasPin(Pin pin); void setMode(Pin pin, PinMode mode); void setState(Pin pin, PinState state); PinState getState(Pin pin); @Override String getHWGuid(); @Override boolean enterInitialize(); @Override boolean exitInitialize(); @Override void terminate(); @Override void reset(); @Override List<Double> getReal(List<Integer> refs); @Override List<Integer> getInteger(List<Integer> refs); @Override boolean setReal(Map<Integer, Double> ref_values); @Override boolean setInteger(Map<Integer, Integer> ref_values); @Override List<Boolean> getBoolean(List<Integer> refs); PinMode getMode(Pin pin); @Override boolean setBoolean(Map<Integer, Boolean> ref_values); @Override boolean isTerminated(); @Override List<Fmi2ScalarVariable> getModelVariables(); String getName(); @Override void addListener(Pin pin, PinListener listener); @Override void removeListener(Pin pin, PinListener listener); @Override void removeAllListeners(); @Override void export(Pin pin, PinMode mode); @Override void export(Pin pin, PinMode arg1, PinState arg2); @Override void unexport(Pin pin); @Override boolean isExported(Pin pin); @Override void setPullResistance(Pin pin, PinPullResistance resistance); @Override PinPullResistance getPullResistance(Pin pin); @Override void setPwm(Pin pin, int value); @Override void setPwmRange(Pin pin, int range); @Override int getPwm(Pin pin); @Override void setValue(Pin pin, double value); @Override double getValue(Pin pin); @Override void shutdown(); @Override boolean isShutdown(); static final String GUID; }