/** * print the file header, with the node name the raw data and the feature field * * @param out stream where write the feature data * @param f feature that this close will dump */ protected void printHeader(Formatter out, Feature f) { Field fields[] = f.getFieldsDesc(); out.format("Log start on," + DATE_FORMAT_TO_HEADER.format(mStartLog) + "\n"); out.format("Feature," + f.getName() + "\n"); out.format("Nodes,"); if (mNodeList != null) for (Node n : mNodeList) out.format(n.getFriendlyName() + ", "); out.format("\n"); out.format( HOST_TIMESTAMP_COLUMN + " (ms)," + NODE_NAME_COLUMN + "," + NODE_TIMESTAMP_COLUMN + "," + "" + NODE_RAW_DATA_COLUMN + ","); for (Field field : fields) { out.format(field.getName()); String unit = field.getUnit(); if (unit != null && !unit.isEmpty()) out.format(" (%s)", field.getUnit()); out.format(","); } // for out.format("\n"); out.flush(); } // printHeader
@Test public void testUpdateOffset() throws Throwable { Feature f = new FeatureMicLevel(null); byte data[] = new byte[] {0, 0, 0, 1, 2, 3}; UpdateFeatureUtil.callUpdate(f, 2, data, 3); Assert.assertEquals( new Feature.Sample(2, new Byte[] {data[3], data[4], data[5]}, new Field[] {}), f.getSample()); Assert.assertEquals(data.length - 3, f.getFieldsDesc().length); }
@Test public void testUpdate() throws Throwable { Feature f = new FeatureMicLevel(null); byte data[] = new byte[] {1, 2, 3}; UpdateFeatureUtil.callUpdate(f, 1, data, 0); Assert.assertEquals( new Feature.Sample(1, new Byte[] {data[0], data[1], data[2]}, new Field[] {}), f.getSample()); Assert.assertEquals(data.length, f.getFieldsDesc().length); }
/** * create a string with the path where store the log. the name will have a timestamp for be unique * * @param f feature to log * @return file path where store the log for that feature */ protected String logFeatureFileName(Feature f) { return String.format("%s/%s_%s.csv", mDirectoryPath, logSessionPrefix(), f.getName()); }