User Tools

Site Tools


struktura:marklar-fx-common:settings:korekce

Korekce

Korekce je zalozka, ktera umoznuje zadavat korekcni krivky merenym fyzikalnim velicinam. Pokud je napr. teplotni senzor zkalibrovan, ma uzivatel k dispozici tabulku podobne te na obrazku (tj. pokud senzor ukazuje urcitou hodnout, skutecna hodnota muze byt trochu jina).

Grafika pro tuto zalozku se bere z ExperimentTypeGraphicFactory prostrednictvim metody

public GraphicControllerDTO getCorrectionersGraphics(Instrument actualInstrument);

Samotny GraphicControllerDTO by mel vracet controller odvozeny z InstrumentCorrectionPaneController, ktery ma implementovanu metodu getCorrectionTabController(), ktera vraci GraphicControllerDTO s CorrectionTabControllerem (tj. uz konkretni grafiku + controller toho, co je na obrazku)

public abstract class InstrumentCorrectionPaneController implements Initializable, Savable {
 
  protected Instrument instrument;
 
  public Instrument getInstrument() {
    return instrument;
  }
 
  public void setInstrument(Instrument instrument) {
    this.instrument = instrument;
  }
 
  protected GraphicControllerDTO getCorrectionTabController() {
    GraphicControllerDTO gcDTO = AnchorPaneHelper.loadFXPaneByName(CorrectionTabController.class.getResource("CorrectionTab.fxml"));
    return gcDTO;
  } 
}

CorrectionTabController obsahuje dve dulezite metody

public class CorrectionTabController implements Initializable {
  public void setCorrectioner(String corrString);
  public Correctioner getCorrectioner();
}

marklar-fx-common poskytuje grafiku pro korekce (tj. tabulka + tooly pro pridani/editaci/mazani radku v tabulce). Corekci samotnou provadi trida Correctioner, ktera se nechazi v marklar-core. Tato trida obsahuje nasledujici metody postacujici pro hlavni pouziti

public class Correctioner {
  public Correctioner(String fromString);
  public String toString();
  public double correct(double value);
}

Je treba poznamenat, ze kazda Component obsahuje prazdny Correctioner (tj. Correctioner neprovadejici zadnou korekci).

Vsechno to zni celkem komplikovane, ale konkretni implementace je dost jednoducha

public class PlastCorrectionerPaneController extends InstrumentCorrectionPaneController {
 
  @FXML
  private AnchorPane paneCorrection;
 
  private PlastInstrumentSettingsService instrumentSS;
 
  private CorrectionTabController correctionerControlelr;
 
  @Override
  public void initialize(URL location, ResourceBundle resources) {
  }
 
  @Override
  public void save() {
    instrumentSS.saveTempCorrectioner(correctionerControlelr.getCorrectioner().toString());
    ServiceLocator.getInstance().getLogicModuleManager().raiseEvent(new PlastTempCorrectionerEvent(), instrument);
  }
 
  @Override
  public void setInstrument(Instrument instrument) {
    super.setInstrument(instrument);
    instrumentSS = (PlastInstrumentSettingsService) instrument.getSettingsService();
 
    GraphicControllerDTO gcDTO = getCorrectionTabController();
    correctionerControlelr = (CorrectionTabController) gcDTO.getController();
    AnchorPaneHelper.insertNodeToContent(gcDTO.getGraphic(), paneCorrection);
    correctionerControlelr.setCorrectioner(instrumentSS.getTempCorrectioner());
  }
 
}
struktura/marklar-fx-common/settings/korekce.txt · Last modified: 2016/07/21 11:36 by jlochman