/** * Generate the standard IES Data Format Header and write it into the output stream 'out'. * * @param filename * @param logChannelList * @return */ public String getIESDataFormatHeaderString(String filename, List<LogChannel> logChannelList) { StringBuilder sb0 = new StringBuilder(); StringBuilder sb1 = new StringBuilder(); setHeaderTop(sb0, logChannelList.get(0).getLoggingInterval(), filename); // write channel specific header informations int colNumber = 4; Iterator<LogChannel> iterator = logChannelList.listIterator(); while (iterator.hasNext()) { LogChannel logChannel = iterator.next(); appendChannelSpecificComment(sb0, logChannel, colNumber); sb1.append(logChannel.getId()); if (iterator.hasNext()) { sb1.append(Const.SEPARATOR); } ++colNumber; } appendColumnHeaderTimestamp(sb0); sb0.append(sb1); sb0.append(Const.LINESEPARATOR); return sb0.toString(); }
/** * Appends channel specific comments to a StringBuilder * * @param sb * @param logChannel * @param colNumber */ private void appendChannelSpecificComment( StringBuilder sb, LogChannel logChannel, int colNumber) { String unit = logChannel.getUnit(); if (unit.equals("")) { unit = "0"; } ValueType vType = logChannel.getValueType(); String valueType = vType.toString(); int valueTypeLength = 0; if (vType.equals(ValueType.BYTE_ARRAY) || vType.equals(ValueType.STRING)) { valueTypeLength = logChannel.getValueTypeLength(); } String description = logChannel.getDescription(); if (description.equals("")) { description = "-"; } createRow( sb, String.format("%03d", colNumber), logChannel.getId(), "FALSE", "TRUE", unit, "other", valueType, valueTypeLength, description); }