Remarks
Y4000 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Y4000 sensor;
public async override Task Initialize()
{
Resolver.Log.Info("Initialize...");
await Task.Delay(2000);
sensor = new Y4000(Device, Device.PlatformOS.GetSerialPortName("COM4"), 0x01, Device.Pins.D09);
await sensor.Initialize();
await Task.Delay(2000);
}
public override async Task Run()
{
Resolver.Log.Info("Run...");
var isdn = await sensor.GetISDN();
Resolver.Log.Info($"Address: {isdn}");
var supplyVoltage = await sensor.GetSupplyVoltage();
Resolver.Log.Info($"Supply voltage: {supplyVoltage}");
var measurements = await sensor.Read();
Resolver.Log.Info($"Sensor data: {measurements}");
}
Sample project(s) available on GitHub
Syntax
public class Y4000 : PollingSensorBase<(ConcentrationInWater? DisolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Units.Temperature? Temperature, Voltage? OxidationReductionPotential)>, ISamplingSensor<(ConcentrationInWater? DisolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Units.Temperature? Temperature, Voltage? OxidationReductionPotential)>, ISamplingSensor<(ConcentrationInWater? DisolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Units.Temperature? Temperature, Voltage? OxidationReductionPotential)>
Constructors
Y4000(IMeadowDevice, SerialPortName, Byte, Nullable<IPin>)
Creates a new Y4000 object
Declaration
public Y4000(IMeadowDevice device, SerialPortName serialPortName, byte modbusAddress = null, IPin? enablePin = null)
Parameters
Type | Name | Description |
---|---|---|
IMeadowDevice | device | |
SerialPortName | serialPortName | |
System.Byte | modbusAddress | |
System.Nullable<IPin> | enablePin |
Y4000(IModbusBusClient, Byte)
Creates a new Y4000 object
Declaration
public Y4000(IModbusBusClient modbusClient, byte modbusAddress = null)
Parameters
Type | Name | Description |
---|---|---|
IModbusBusClient | modbusClient | |
System.Byte | modbusAddress |
Properties
BlueGreenAlgae
The current Blue Green Algae concentration
Declaration
public ConcentrationInWater? BlueGreenAlgae { get; }
Property Value
Type | Description |
---|---|
System.Nullable<ConcentrationInWater> |
Chlorophyl
The current Chlorophyl concentration
Declaration
public ConcentrationInWater? Chlorophyl { get; }
Property Value
Type | Description |
---|---|
System.Nullable<ConcentrationInWater> |
DisolvedOxygen
The current Disolved Oxygen concentration
Declaration
public ConcentrationInWater? DisolvedOxygen { get; }
Property Value
Type | Description |
---|---|
System.Nullable<ConcentrationInWater> |
ElectricalConductivity
The current Electrical Conductivity
Declaration
public Conductivity? ElectricalConductivity { get; }
Property Value
Type | Description |
---|---|
System.Nullable<Conductivity> |
ModbusAddress
The current modbus address
Declaration
public byte ModbusAddress { get; }
Property Value
Type | Description |
---|---|
System.Byte |
OxidationReductionPotential
The current Oxidation Reduction Potential (redux)
Declaration
public Voltage? OxidationReductionPotential { get; }
Property Value
Type | Description |
---|---|
System.Nullable<Voltage> |
PH
The current Potential Hydrogen (pH)
Declaration
public PotentialHydrogen? PH { get; }
Property Value
Type | Description |
---|---|
System.Nullable<PotentialHydrogen> |
Turbidity
The current Turbidity
Declaration
public Turbidity? Turbidity { get; }
Property Value
Type | Description |
---|---|
System.Nullable<Turbidity> |
Methods
GetBrushInterval()
Get the brush or wiper interval
Declaration
public Task<TimeSpan> GetBrushInterval()
Returns
Type | Description |
---|---|
Task<TimeSpan> |
GetErrorFlag()
Read the error flag from the sensor
Declaration
public Task<ushort> GetErrorFlag()
Returns
Type | Description |
---|---|
Task<System.UInt16> |
GetISDN()
Get the device ISDN (address) of the sensor Note this is a broadcast event so all Y4000 devices on the bus will respond
Declaration
public Task<byte> GetISDN()
Returns
Type | Description |
---|---|
Task<System.Byte> | The address as a byte |
GetSerialNumber()
Get the device serial number
Declaration
public Task<ushort[]> GetSerialNumber()
Returns
Type | Description |
---|---|
Task<System.UInt16[]> | The serial number as a ushort array |
GetSupplyVoltage()
Get the current supply voltage
Declaration
public Task<Voltage> GetSupplyVoltage()
Returns
Type | Description |
---|---|
Task<Voltage> |
GetVersion()
Get the device version
Declaration
public Task<ushort[]> GetVersion()
Returns
Type | Description |
---|---|
Task<System.UInt16[]> |
Initialize()
Initialize sensor
Declaration
public Task Initialize()
Returns
Type | Description |
---|---|
Task |
RaiseEventsAndNotify(IChangeResult<(Nullable<ConcentrationInWater> DisolvedOxygen, Nullable<ConcentrationInWater> Chlorophyl, Nullable<ConcentrationInWater> BlueGreenAlgae, Nullable<Conductivity> ElectricalConductivity, Nullable<PotentialHydrogen> PH, Nullable<Turbidity> Turbidity, Nullable<Units.Temperature> Temperature, Nullable<Voltage> OxidationReductionPotential)>)
Raise events for subscribers and notify of value changes
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(ConcentrationInWater? DisolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Units.Temperature? Temperature, Voltage? OxidationReductionPotential)> changeResult)
Parameters
Type | Name | Description |
---|---|---|
IChangeResult<System.ValueTuple<System.Nullable<ConcentrationInWater>, System.Nullable<ConcentrationInWater>, System.Nullable<ConcentrationInWater>, System.Nullable<Conductivity>, System.Nullable<PotentialHydrogen>, System.Nullable<Turbidity>, System.Nullable<Units.Temperature>, System.ValueTuple<System.Nullable<Voltage>>>> | changeResult | The updated sensor data |
ReadSensor()
Reads data from the sensor
Declaration
protected override Task<(ConcentrationInWater? DisolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Units.Temperature? Temperature, Voltage? OxidationReductionPotential)> ReadSensor()
Returns
Type | Description |
---|---|
Task<System.ValueTuple<System.Nullable<ConcentrationInWater>, System.Nullable<ConcentrationInWater>, System.Nullable<ConcentrationInWater>, System.Nullable<Conductivity>, System.Nullable<PotentialHydrogen>, System.Nullable<Turbidity>, System.Nullable<Units.Temperature>, System.ValueTuple<System.Nullable<Voltage>>>> | The latest sensor reading |
Overrides
SetBrushInterval(TimeSpan)
Set the brush or wiper interval (normalized to minutes)
Declaration
public Task SetBrushInterval(TimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | interval |
Returns
Type | Description |
---|---|
Task |
SetISDN(Byte)
Set the ISDN (address) of the sensor
Declaration
public Task SetISDN(byte modbusAddress)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | modbusAddress | The address |
Returns
Type | Description |
---|---|
Task |
StartBrush()
Start the brush or wiper
Declaration
public Task StartBrush()
Returns
Type | Description |
---|---|
Task |
Events
BlueGreenAlgaeUpdated
Raised when the BlueGreenAlgae value changes
Declaration
public event EventHandler<IChangeResult<ConcentrationInWater>> BlueGreenAlgaeUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<ConcentrationInWater>> |
ChlorophylUpdated
Raised when the Chlorophyl value changes
Declaration
public event EventHandler<IChangeResult<ConcentrationInWater>> ChlorophylUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<ConcentrationInWater>> |
DisolvedOxygenUpdated
Raised when the DisolvedOxygen value changes
Declaration
public event EventHandler<IChangeResult<ConcentrationInWater>> DisolvedOxygenUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<ConcentrationInWater>> |
ElectricalConductivityUpdated
Raised when the ElectricalConductivity value changes
Declaration
public event EventHandler<IChangeResult<Conductivity>> ElectricalConductivityUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Conductivity>> |
OxidationReductionPotentialUpdated
Raised when the OxidationReductionPotential (redux) value changes
Declaration
public event EventHandler<IChangeResult<Voltage>> OxidationReductionPotentialUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Voltage>> |
PHUpdated
Raised when the PotentialHydrogen (pH) value changes
Declaration
public event EventHandler<IChangeResult<PotentialHydrogen>> PHUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<PotentialHydrogen>> |
TemperatureUpdated
Raised when the Temperature value changes
Declaration
public event EventHandler<IChangeResult<Units.Temperature>> TemperatureUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Units.Temperature>> |
TurbidityUpdated
Raised when the Turbidity value changes
Declaration
public event EventHandler<IChangeResult<Turbidity>> TurbidityUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Turbidity>> |