Class CSVOutputAdapter
java.lang.Object
net.simplace.sim.io.FWSimIOAdapter
net.simplace.sim.io.output.FWSimOutputAdapter
net.simplace.sim.io.output.adapter.CSVOutputAdapter
- All Implemented Interfaces:
FWSimFieldContainer
Output adapter writing the output of an
FWSimOutput to a CSV file (CSVInterface). The file name may
contain tokens (e.g. ${projectid}); the file is determined again for each project (see
updateFile(FWSimVarMap, long)). The header line is written before the first data line.- Author:
- Andreas Enders
-
Nested Class Summary
Nested classes/interfaces inherited from class FWSimIOAdapter
FWSimIOAdapter.FREQUENCE -
Field Summary
Fields inherited from class FWSimOutputAdapter
iCacheSize, iQueueFields inherited from class FWSimIOAdapter
iArrayMode, iFieldcount, iFrequence, iHeaderVariables, iInterface, iJexlRule, iKeyMap, iName, iOrderNumber, iProcessTime, iResourceElement, iSession, iSourceKey -
Constructor Summary
ConstructorsConstructorDescriptionCSVOutputAdapter(String aFile, String aName, String aDivider, int aOrderNumber, FWSimIOAdapter.FREQUENCE aFrequence, String aCacheSize, ProcessTime aProcessTime, FWSimSession aSession) Creates the adapter from the graph panel with its own CSV interface (column mode).CSVOutputAdapter(FWSimOutputAdapter aOldAdapter, CSVInterface aInterface) Copy constructor used when the interface is replaced.CSVOutputAdapter(org.jdom2.Element aResourceElement, int aOrderNumber, FWSimVarMap aVarMap) Creates the adapter from anoutputelement. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinalize()Closes the files of the file pool.protected voidinit(FWSimVarMap aVarMap) Registers the output file and builds the header line: one column per header variable, optionally with its unit in brackets.booleanupdateFile(FWSimVarMap aVarMap, long aSkipAboveSize) Determines the output file for the current project; if it differs from the current file, the adapter is initialized for the new file.protected voidwriteData(FWSimQueueObjectMap aObjectToWrite) Writes an output line to the CSV file (in the writer thread); the header line is written first if necessary.Methods inherited from class FWSimOutputAdapter
createAdapter, createOutputFromObservable, getContentType, getInputVariables, getInterface, getOutputVariables, getQueueLenth, getResetScript, getStatistics, getStatisticsAdapter, getStatisticsHeaderVariables, getStatisticsResultCache, getVarMap, hasStatistics, initialize, isActive, isWriting, receiveData, toHTMLTablestring, toXML, updateAdapter, writeDataMethods inherited from class FWSimIOAdapter
addProcessTime, addVariable, checkCondition, createFormFields, createVariables, getCreateFormXML, getEditFormXML, getFieldMap, getFrequence, getHeaderVariables, getHeaderXML, getJexlRule, getKeyMap, getName, getOrderNumber, getVariable, isArrayMode, isConditionCheck, removeVariable, setFrequenceAndRule, setInterface, setOrderNumber, toString, writeHeaderList
-
Constructor Details
-
CSVOutputAdapter
Creates the adapter from anoutputelement.- Parameters:
aResourceElement- theoutputelementaOrderNumber- order number of the adapteraVarMap- template variable map of the solution
-
CSVOutputAdapter
public CSVOutputAdapter(String aFile, String aName, String aDivider, int aOrderNumber, FWSimIOAdapter.FREQUENCE aFrequence, String aCacheSize, ProcessTime aProcessTime, FWSimSession aSession) Creates the adapter from the graph panel with its own CSV interface (column mode).- Parameters:
aFile- output fileaName- name of the adapter; the interface is named<name>_INTERFACEaDivider- column divideraOrderNumber- order number of the adapteraFrequence- frequency of the outputaCacheSize- capacity of the queueaProcessTime- runtime statistics of the adapteraSession- the session
-
CSVOutputAdapter
Copy constructor used when the interface is replaced.- Parameters:
aOldAdapter- the adapter to copyaInterface- the new interface
-
-
Method Details
-
init
Registers the output file and builds the header line: one column per header variable, optionally with its unit in brackets. In array mode with column layout, an array variable gets one column per selected element (_1,_2, ...,_LASTfor the last element: count99999, stored 0-based as 99998, orlast, stored as 99999 - like inFWSimOutputCache).- Specified by:
initin classFWSimOutputAdapter- Parameters:
aVarMap- variable map used for replacing tokens
-
writeData
Writes an output line to the CSV file (in the writer thread); the header line is written first if necessary.- Specified by:
writeDatain classFWSimOutputAdapter- Parameters:
aObjectToWrite- the output line- See Also:
-
finalize
Closes the files of the file pool.- Overrides:
finalizein classFWSimIOAdapter- Throws:
Exception- if closing fails- See Also:
-
updateFile
Determines the output file for the current project; if it differs from the current file, the adapter is initialized for the new file.- Parameters:
aVarMap- variable map of the first simulation of the projectaSkipAboveSize- size limit in bytes, or 0 for no limit- Returns:
trueif the file changed and already exists with a size above the limit (the project can be skipped)
-