sync before adding submodules
This commit is contained in:
@@ -8,44 +8,27 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
foreach (var property in typeof(Pam).GetFields(BindingFlags.Public | BindingFlags.Static))
|
||||
{
|
||||
Console.WriteLine($"{property.Name}: {property.GetValue(null)}");
|
||||
}
|
||||
var client = new SIRTClient("COM6");
|
||||
|
||||
//var client = new SIRTClient("COM6");
|
||||
|
||||
//client.OpenConnection();
|
||||
//Console.ReadKey();
|
||||
//client.CloseConnection();
|
||||
client.OpenConnection();
|
||||
Console.ReadKey();
|
||||
client.CloseConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public class SIRTClient
|
||||
{
|
||||
private readonly ConcurrentDictionary<uint, EregisterTask> activateable;
|
||||
private readonly ConcurrentDictionary<uint, EregisterTask> tasks;
|
||||
private readonly SIRTBroadcaster broadcaster;
|
||||
|
||||
public SIRTClient(string comPort)
|
||||
{
|
||||
this.activateable = new ConcurrentDictionary<uint, EregisterTask>(new Dictionary<uint, EregisterTask>
|
||||
{
|
||||
// 433
|
||||
{ 875770417, null },
|
||||
{ 4291267283, null },
|
||||
{ 4291317405, null },
|
||||
// 868
|
||||
// { 4291631647, null },
|
||||
});
|
||||
this.tasks = new ConcurrentDictionary<uint, EregisterTask>();
|
||||
this.broadcaster = new SIRTBroadcaster(comPort);
|
||||
this.broadcaster.Activated += this.Broadcaster_Activated;
|
||||
@@ -55,59 +38,46 @@
|
||||
this.broadcaster.MessageReceived += this.Broadcaster_MessageReceived;
|
||||
}
|
||||
|
||||
internal void CloseConnection()
|
||||
{
|
||||
this.broadcaster.Close();
|
||||
}
|
||||
internal void CloseConnection() => this.broadcaster.Close();
|
||||
|
||||
internal void OpenConnection()
|
||||
{
|
||||
this.broadcaster.Open();
|
||||
}
|
||||
internal void OpenConnection() => this.broadcaster.Open();
|
||||
|
||||
private void Broadcaster_Activated()
|
||||
{
|
||||
Console.WriteLine(nameof(Broadcaster_Activated));
|
||||
|
||||
foreach (var kvp in this.activateable)
|
||||
this.tasks.GetOrAdd(4291796386, _ =>
|
||||
{
|
||||
this.tasks.GetOrAdd(kvp.Key, _ =>
|
||||
var task = new EregisterTask(868)
|
||||
{
|
||||
var task = new EregisterTask(433, 3000)
|
||||
Cmd = SIRTMessage.W_PAM,
|
||||
P1 = new P811
|
||||
{
|
||||
Cmd = SIRTMessage.W_PAM,
|
||||
P1 = new P811
|
||||
{
|
||||
DelPamSemi = true,
|
||||
},
|
||||
Data = new OpticalTelegram
|
||||
{
|
||||
Minutes = 1
|
||||
}.Append(new ProvidePin
|
||||
{
|
||||
AuthLevel = AuthLevel.III
|
||||
}),
|
||||
RequestAddress = kvp.Key
|
||||
};
|
||||
DelPamSemi = true,
|
||||
},
|
||||
Data = new ChangeRadioId
|
||||
{
|
||||
Address = 309030150
|
||||
|
||||
task.Completed += this.Task_Completed;
|
||||
}.Append(new ProvidePin
|
||||
{
|
||||
AuthLevel = AuthLevel.III
|
||||
}),
|
||||
RequestAddress = 4291796386,
|
||||
ResponseAddress = 309030150
|
||||
};
|
||||
|
||||
this.broadcaster.EnqueueTask(task);
|
||||
task.Completed += this.Task_Completed;
|
||||
|
||||
return task;
|
||||
});
|
||||
}
|
||||
this.broadcaster.EnqueueTask(task);
|
||||
|
||||
return task;
|
||||
});
|
||||
}
|
||||
|
||||
private void Broadcaster_Connected()
|
||||
{
|
||||
Console.WriteLine(nameof(Broadcaster_Connected));
|
||||
}
|
||||
private void Broadcaster_Connected() => Console.WriteLine(nameof(Broadcaster_Connected));
|
||||
|
||||
private void Broadcaster_Disconnected()
|
||||
{
|
||||
Console.WriteLine(nameof(Broadcaster_Disconnected));
|
||||
}
|
||||
private void Broadcaster_Disconnected() => Console.WriteLine(nameof(Broadcaster_Disconnected));
|
||||
|
||||
private void Broadcaster_Logging(string message)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user