@Donpi Dear myself, try this way :
static void Main(string[] args)
{
Console.WriteLine("Début");
Console.WriteLine("Connection");
SubscribeConnection oCon = new SubscribeConnection();
try
{
Task oTaskCon = oCon.Connect(SubscriptionMode.Full,"/var/run/dsf/dcs.sock");
oTaskCon.Wait();
}
catch (Exception oE)
{
Console.WriteLine("-----------------------------");
Console.WriteLine("---- erreur de connection ---");
Console.WriteLine("-----------------------------");
throw oE;
}
if (oCon.IsConnected)
Console.WriteLine("Connection OK");
else
Console.WriteLine("Connection échouée");
Console.WriteLine("Recupération du modèle");
Task<MachineModel> oTask = oCon.GetMachineModel();
oTask.Wait();
MachineModel oModel = oTask.Result;
Console.WriteLine("Lecture des capteurs");
Sensors oSensors = oModel.Sensors;
Console.WriteLine(oSensors.Analog.Count.ToString() + " Analog sensors");
Console.WriteLine(oSensors.Endstops.Count.ToString() + " Endstops sensors");
Console.WriteLine(oSensors.FilamentMonitors.Count.ToString() + " FilamentMonitors sensors");
Console.WriteLine(oSensors.GpIn.Count.ToString() + " GpIn sensors");
Console.WriteLine(oSensors.Probes.Count.ToString() + " Probes sensors");
Console.WriteLine("Capteurs Analogiques");
AnalogSensor oMCU = oSensors.Analog[3];
oMCU.PropertyChanged += OMCU_PropertyChanged;
Console.WriteLine(oMCU.Name + " : " + oMCU.LastReading + " C°");
Console.WriteLine("Updating model");
while (true)
{
Task<JsonDocument> oTaskPatch = oCon.GetMachineModelPatch();
oTaskPatch.Wait();
oModel.UpdateFromJson(oTaskPatch.Result.RootElement);
Thread.Sleep(250);
}
}
private static void OMCU_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
AnalogSensor oMCU = sender as AnalogSensor;
Console.WriteLine(oMCU.Name + " : " + oMCU.LastReading + " C° from event");
}