PhantomLib (.NET)
PhantomLib lets your application receive PHANTOM® sensor data straight from
the gateway on your network, without a web service in between. It is written
in C# and runs on Windows and on Linux under Mono.
It is message-based: you start listening threads, hand them a callback, and the library invokes it every time a message arrives.
The delegate is invoked from the context of different threads. To update a
UI or serialise the messages you need to marshal back to the main thread —
Invoke or a queue.
Messages
Section titled “Messages”Phantom.Messages constant |
Payload class | Carries |
|---|---|---|
RECEIVED_PHANTOM_ACCEL_DATA |
MessageDataEIMONanoAccel |
Vibration waveforms |
RECEIVED_PHANTOM_ACCEL_STATE |
MessageEIMONanoAccelState |
RMS, battery, temperature |
RECEIVED_PHANTOM_ACCEL_SETTINGS |
MessageEIMONanoAccelSettings |
Current node settings |
RECEIVED_PHANTOM_TEMP_DATA |
MessageDataEIMONanoTemp |
Thermocouple / infrared |
RECEIVED_PHANTOM_CURRENT_DATA |
MessageEIMONanoCurrentData |
Current, 3 channels |
RECEIVED_PHANTOM_CURRENT_DATAV2 |
MessageEIMONanoCurrentDataV2 |
Current v2, min/max/avg |
RECEIVED_PHANTOM_ACCUMULATED_CURRENT_DATA |
MessageEIMONanoAccumulatedCurrentData |
Accumulated current in Ah |
RECEIVED_PHANTOM_RPM_DATA |
MessageEIMONanoRPMData |
RPM |
RECEIVED_PHANTOM_420_DATA |
MessageData420 |
4-20 mA, as voltage |
RECEIVED_PHANTOM_THERMAL_IMAGE |
ThermalCameraImage |
Thermal image |
RECEIVED_PHANTOM_THERMAL_DATA |
ThermalCameraData |
Thermal camera state |
Vibration data
Section titled “Vibration data”public class MessageDataEIMONanoAccel : MessageData { public Reason recording_reason; public string phantom_code; public float temperature; public short[] channel1; public short[] channel2; public short[] channel3; public double calibration; public int sample_rate;}channel1–channel3are signed 16-bit samples. Multiply each bycalibrationto get G (9.8 m/s²).channel3is null on biaxial nodes — check before dereferencing.temperatureis the node’s internal radio transmitter temperature in °C, not the machine temperature.
public enum Reason { REQUESTED = 1, SCHEDULED = 2, ALARM = 3 }State and settings
Section titled “State and settings”public class MessageEIMONanoAccelState : MessageData { public string phantom_code; public float battery; // V public float temperature; // °C, radio transmitter public float rms1, rms2, rms3; // velocity RMS in mm/s}
public class MessageEIMONanoAccelSettings : MessageData { public string phantom_code; public int send_interval; // minutes, full acceleration data public int sample_rate; public int samples_to_get; public int range; // G public float alarm1, alarm2, alarm3; // mm/s public int alarmcheck_interval; // seconds}Temperature
Section titled “Temperature”public class MessageDataEIMONanoTemp : MessageData { public Reason recording_reason; public string phantom_code; public TemperatureType type; public float temperature; // thermocouple module public float battery; public float ambient_temperature; // measured by the infrared module public float module_temperature; // radio transmitter}
public enum TemperatureType { THERMOCOUPLE = 1, INFRARED = 2 }Current
Section titled “Current”public class MessageEIMONanoCurrentData : MessageData { public string phantom_code; public float battery; public float module_temperature; public float current1, current2, current3; // A}
public class MessageEIMONanoCurrentDataV2 : MessageData { public float battery; public float module_temperature; public float min_current1, min_current2, min_current3, min_current4; public float max_current1, max_current2, max_current3, max_current4; public float avg_current1, avg_current2, avg_current3, avg_current4; public uint version;}
public class MessageEIMONanoAccumulatedCurrentData : MessageData { public float accumulated_current1, accumulated_current2, accumulated_current3, accumulated_current4; // Ah public DateTime startPeriod; public DateTime endPeriod;}The v2 module reports minimum, maximum and average since the last message.
Accumulated current is in ampere-hours since the sensor started, over the
period the two DateTime fields delimit.
RPM and 4-20 mA
Section titled “RPM and 4-20 mA”public class MessageEIMONanoRPMData : MessageData { public string phantom_code; public float battery; public float module_temperature; public float rpm;}
public class MessageData420 : MessageData { public string phantom_code; public float battery; public float module_temperature; public float channel1_voltage, channel2_voltage, channel3_voltage, channel4_voltage; public uint version;}4-20 mA channels report voltage, measured across a 100 Ω resistor to ground: 20 mA reads 2.0 V and 4 mA reads 0.4 V.
Thermal camera
Section titled “Thermal camera”public class ThermalCameraImage : MessageData { public Reason recording_reason; public uint version; public uint sequence; public float[,,] temp_data; // [frames, width, height], °C per pixel public int image_rows; public int image_columns; public int image_frames;}
public class ThermalCameraData : MessageData { public float battery; public float module_temperature; public float average_frame_temperature; public float average_roi_temperature; public uint version;}temp_data is three-dimensional: frames, then width, then height, with each
value the temperature of that pixel in Celsius.
average_roi_temperature is documented as not used right now.
Changing sensor settings
Section titled “Changing sensor settings”public void send_einano_accel_config( string ip_address, string phantom_code, int send_interval, float alarm1, float alarm2, float alarm3, int alarmcheck_interval)| Parameter | Notes |
|---|---|
ip_address |
The gateway’s IP, not the sensor’s. It is shown on the gateway’s own LED display |
send_interval |
Minutes between full acceleration sends. Affects battery life |
alarm1–alarm3 |
Thresholds in mm/s |
alarmcheck_interval |
Seconds between alarm checks. Affects battery life |
The gateway shows its own IP address on its LED display — read it from the unit itself.
If the gateway is on DHCP that address can change, which would silently break
a hard-coded ip_address. The Modbus integration requires
a static IP for the same reason; setting one is worth it here too.
The request goes to the gateway, which stores it and passes it to the node the
next time the node connects to ask for its configuration. Expect a delay
before it takes effect — the same deferred model the
PHANTOM® Web Service uses for saveSettings.
Known issues in the source documentation
Section titled “Known issues in the source documentation”The SDK document is v1.7 while the distributed library is 1.8, so it may lag behind the assembly. These specific defects were found while transcribing it, and are reproduced above as published rather than silently corrected:
RECEIVED_PHANTOM_420_DATAandRECEIVED_PHANTOM_THERMAL_DATAare both described as “the data of the Phantom RPM node” — copy-paste errorsThermalCameraDataprose refers to atemperaturefield, but the class declaresmodule_temperatureThermalCameraImage,MessageEIMONanoCurrentDataV2andMessageEIMONanoAccumulatedCurrentDataare described as havingphantom_code, but none declares it — presumably it lives on theMessageDatabase class, which the document never defines
Packaging
Section titled “Packaging”The library ships as PhantomLib-1.8.zip, a Visual Studio working folder that
includes .vs/, bin/ and obj/ build artifacts, plus a console example
(PhantomLibExample) and Newtonsoft.Json 13.0.1. Target framework is .NET
Framework 4.5.2.
Publishing it as a NuGet package would make consuming and updating it considerably easier than distributing a zipped solution folder.