Marklar
Zalozeni Projektu
- Prerequisities
- Prvni kroky
- Experiment
- Grafika
- Logika Experimentu
Struktura
- marklar-core
- marklar-fx-common
- marklar-driver-modbus
- marklar-pardWeight
- plastometer
- dilatometer
- lbm
- dokuwiki
Implementace Instrument
je jiz komplikovanejsi. Instrument
definuje sve Device
, prirazuje jim Component
a stara se o vycitani udaju z Component
.
Instrument
s sebou nese i sve vlastni nastaveni (metoda getSettingsService()
), ktere je popsano v nasledujici casti.
Instrument
je rovnez vazan k ExperimentType
, coz je deklarovano v konstruktoru (ExperimentType
s sebou nese deklaraci spousty trid a budu se mu venovat az pozdeji).
public class DokuwikiInstrument extends Instrument { Eurotherm eurotherm = new Eurotherm(); LabJackT7 labjack = new LabJackT7(); private DoubleValueIntAddrComponent thermometer; private DoubleValueIntAddrComponent tempSetPoint; private IntValueStringAddrComponent counter; public DokuwikiInstrument() { super(); setDefaultExpType(new DokuwikiExpType()); initEurotherm(); initLabJack(); } private void initEurotherm() { List<Component> components = new ArrayList<Component>(); // setting Address = 1; Divisor = 10 thermometer = new DoubleValueIntAddrComponent(eurotherm, 1, 10); thermometer.addGetCondition(new IntervalCondition(0, 1000)); thermometer.setName("Loop.1.Main.PV"); thermometer.setDescription("corrected temperature [˚C]"); setTempCorrectioner(); components.add(thermometer); tempSetPoint = new DoubleValueIntAddrComponent(eurotherm, 2, 10); tempSetPoint.addGetCondition(new IntervalCondition(0, 600)); tempSetPoint.addSetCondition(new IntervalCondition(0, 600)); tempSetPoint.setName("Loop.1.Main.TargetSP"); tempSetPoint.setDescription("temp setPoint [˚C]"); components.add(tempSetPoint); eurotherm.setComponents(components); eurotherm.setName("Eurotherm e3508"); this.addDevice(eurotherm); } private void setTempCorrectioner() { DokuwikiInstrumentSettingsService instrumentSS = (DokuwikiInstrumentSettingsService) this.getSettingsService(); thermometer.setCorrectioner(new Correctioner(instrumentSS.getTempCorrectioner())); } private void initLabJack() { List<Component> components = new ArrayList<Component>(); counter = new IntValueStringAddrComponent(labjack, "DIO18_EF_READ_A"); counter.addGetCondition(new GreaterThanCondition(0.)); counter.setName("CIO2 counter"); counter.setDescription("pulse counter"); components.add(counter); labjack.setComponents(components); labjack.setName("LabJack T7"); this.addDevice(labjack); } public Eurotherm getEurotherm() { return eurotherm; } public LabJackT7 getLabjack() { return labjack; } public double getTemperature() throws IOException, GetValueException, Exception { return thermometer.readValue(true); } public void setSetPoint(double setPoint) throws IOException, SetValueException, Exception { tempSetPoint.writeValue(setPoint); } public int getCounter() throws IOException, GetValueException, Exception { return counter.readValue(false); } @Override public InstrumentSettingsService getSettingsService() { return new DokuwikiInstrumentSettingsService(this); } @Override public void terminateProcedure() { // TODO Auto-generated method stub } }
Jak muze byt videt u deklarace jednotlivych Comopnent
, kazda Componenta
pouziva tridu, ktera definuje, jaky typ hodnoty z adresy jakeho typu tato Componenta
vycita.
private DoubleValueIntAddrComponent thermometer; private DoubleValueIntAddrComponent tempSetPoint; private IntValueStringAddrComponent counter;
Pri inicializaci Device
se tyto Componenty
deklaruji. Nejzajimavejsi je metoda setTempCorrectioner()
, ktera z nastaveni Instrumentu
pretahne Correctioner
na komponentu thermometer
.