Write CloudTurbine-formatted data. While not a full one-to-one implementation of the Java CTwriter API, this C# version provides basic functionality for storing different types of data. Data can optionally be packed and/or ZIP'ed at the block level. Timestamps can either be represented as milliseconds or seconds since epoch. Timestamps can be auto-generated or manually set. More...
Public Member Functions | |
CTwriter (String baseCTOutputFolderI, int numBlocksPerSegmentI, int numSegmentsToKeepI, bool bOutputTimesAreMillisI, bool bPackI, bool bZipI, bool bDeleteOldDataAtStartupI, bool bVerifyOutputFolderI=true) | |
Constructor. More... | |
String | getBaseCTOutputFolder () |
Get baseCTOutputFolder. More... | |
void | UseTmpFileForZipData (bool bUseTmpZipFilesI) |
If writing output ZIP files, should we write data first to a temporary file (".tmp") and then rename this to the final ".zip" file? If false, we write directly to the output ZIP file using (what is intended to be) a quick stream operation; this has the possible advantage that an extra intermediary ".tmp" file isn't created temporarily. More... | |
void | putData (string[] channamesI, double[] dataI) |
Store an additional double data point in each of the specified channels. More... | |
void | putData (string[] channamesI, float[] dataI) |
Store an additional single-precision float data point in each of the specified channels. More... | |
void | putData (string channameI, String dataI) |
Store a new string in the given channel. More... | |
void | putData (string channameI, double dataI) |
Store a double-precision float data value for the given channel. More... | |
void | putData (string channameI, float dataI) |
Store a single-precision float data value for the given channel. More... | |
void | putData (string channameI, long dataI) |
Store a long integer data value for the given channel. More... | |
void | putData (string channameI, int dataI) |
Store an integer data value for the given channel. More... | |
void | putData (string channameI, short dataI) |
Store a short integer data value for the given channel. More... | |
void | putData (string channameI, char dataI) |
Store a character data value for the given channel. More... | |
void | putData (string channameI, byte[] dataI) |
Store binary data array for the given channel. More... | |
long | setTime () |
Set time for subsequent putData(). This method simply calls setTime(<current_time_millis>). More... | |
void | setTime (long timeI) |
Set time for subsequent putData(). To switch back to automatic timestamp mode, call this method with the argument equal to -1. More... | |
void | setTime (double timeI) |
Set time for subsequent putData(). To switch back to automatic timestamp mode, call this method with the argument equal to -1.0. More... | |
void | setAsync (bool bAsyncI) |
Specify whether flushes should be executed asynchronously. More... | |
void | flush () |
Write out all data that has been queued up for this block. | |
virtual void | close () |
Close the source. Flush any remaining data to the output source. | |
Protected Member Functions | |
virtual void | writeToStream (String outputDirI, String chanNameI, byte[] dataI) |
Low-level method to write data to the channel. More... | |
Write CloudTurbine-formatted data. While not a full one-to-one implementation of the Java CTwriter API, this C# version provides basic functionality for storing different types of data. Data can optionally be packed and/or ZIP'ed at the block level. Timestamps can either be represented as milliseconds or seconds since epoch. Timestamps can be auto-generated or manually set.
2019-03-22 JPW
Notes on referencing the standard Microsoft ZIP library from the CTrollaball Unity application: How to reference a standard Microsoft library which isn't by default included in Unity is described in the post "Using .NET 4.x in Unity" found at: https://docs.microsoft.com/en-us/visualstudio/cross-platform/unity-scripting-upgrade?view=vs-2017 For CTrollaball, we needed Unity to be able to access the System.IO.Compression library. This was accomplished as follows: 1. In Player Settings, set Scripting Runtime Version to ".NET 4.x Equivalent" 2. In Player Settings, set Api Compatibility Level to ".NET 4.x" 3. Include a "csc.rsp" file in the CTrollaball "Assets" folder which includes the following single line (w/o the quotation marks): "-r:System.IO.Compression.dll" Since we no longer need to use the "DotNetZip"/Ionic.Zip.Unity.dll library (from https://github.com/r2d2rigo/dotnetzip-for-unity), the "UNITY_5_3_OR_NEWER" sections in CTlib.cs have been removed.
|
inline |
Constructor.
baseCTOutputFolderI | The root folder where the output source is to be written. This must be at the same level as the application working directory or a sub-directory under it. |
numBlocksPerSegmentI | Number of blocks per segment in the source folder hierarchy. Use 0 to not include a segment layer. |
numSegmentsToKeepI | When using a segment layer, this specifies the number of full segments to keep. Older segments will be trimmed. Set to 0 to keep all segments. |
bOutputTimesAreMillisI | Output times should be in milliseconds? Needed if blocks are written (i.e., flush() is called) at a rate greater than 1Hz. |
bPackI | Pack data at the block folder level? Packed data times are linearly interpolated from the block start time to the time of the final datapoint in the packed channel. |
bZipI | ZIP data at the block folder level? |
bDeleteOldDataAtStartupI | Delete old data from this source at startup? |
bVerifyOutputFolderI | An optional argument, default value is true; if true, verify that baseCTOutputFolderI is at the same level as the application working directory or a sub-directory under it. Should be set false for HTTP or FTP output types. |
|
inline |
Get baseCTOutputFolder.
|
inline |
Store an additional double data point in each of the specified channels.
channamesI | The names of the channels to which new data will be added. |
dataI | Array containing one new data point per channel. |
System.ArgumentException | Thrown if the channel or data arrays are empty of their sizes don't match. |
|
inline |
Store an additional single-precision float data point in each of the specified channels.
channamesI | The names of the channels to which new data will be added. |
dataI | Array containing one new data point per channel. |
System.ArgumentException | Thrown if the channel or data arrays are empty of their sizes don't match. |
|
inline |
Store a new string in the given channel.
channameI | Channel to store the given data in. |
dataI | The data to store. |
System.ArgumentException | Re-throws any exception that is thrown by the underlying putData(string,byte[]) call. |
|
inline |
Store a double-precision float data value for the given channel.
channameI | Channel to store the given data in. |
dataI | The data to store. |
System.ArgumentException | Re-throws any exception that is thrown by the underlying putData(string,byte[]) call. |
|
inline |
Store a single-precision float data value for the given channel.
channameI | Channel to store the given data in. |
dataI | The data to store. |
System.ArgumentException | Re-throws any exception that is thrown by the underlying putData(string,byte[]) call. |
|
inline |
Store a long integer data value for the given channel.
channameI | Channel to store the given data in. |
dataI | The data to store. |
System.ArgumentException | Re-throws any exception that is thrown by the underlying putData(string,byte[]) call. |
|
inline |
Store an integer data value for the given channel.
channameI | Channel to store the given data in. |
dataI | The data to store. |
System.ArgumentException | Re-throws any exception that is thrown by the underlying putData(string,byte[]) call. |
|
inline |
Store a short integer data value for the given channel.
channameI | Channel to store the given data in. |
dataI | The data to store. |
System.ArgumentException | Re-throws any exception that is thrown by the underlying putData(string,byte[]) call. |
|
inline |
Store a character data value for the given channel.
channameI | Channel to store the given data in. |
dataI | The data to store. |
System.ArgumentException | Re-throws any exception that is thrown by the underlying putData(string,byte[]) call. |
|
inline |
Store binary data array for the given channel.
channameI | Channel to store the given data in. |
dataI | The data to store. |
System.ArgumentException | Thrown if the specified channel name or data array is empty. |
|
inline |
Specify whether flushes should be executed asynchronously.
bAsyncI | Should flush calls be asynchronous? |
|
inline |
Set time for subsequent putData(). This method simply calls setTime(<current_time_millis>).
|
inline |
Set time for subsequent putData(). To switch back to automatic timestamp mode, call this method with the argument equal to -1.
timeI | Timestamp in msec |
|
inline |
Set time for subsequent putData(). To switch back to automatic timestamp mode, call this method with the argument equal to -1.0.
timeI | Timestamp in sec |
|
inline |
If writing output ZIP files, should we write data first to a temporary file (".tmp") and then rename this to the final ".zip" file? If false, we write directly to the output ZIP file using (what is intended to be) a quick stream operation; this has the possible advantage that an extra intermediary ".tmp" file isn't created temporarily.
bUseTmpZipFilesI | Write ZIP data first to a temporary file? |
|
inlineprotectedvirtual |
Low-level method to write data to the channel.
outputDirI | |
chanNameI | |
dataI |
Reimplemented in CTlib.CThttp_base, CTlib.CThttp_HttpClient, and CTlib.CThttp.