Closed SmackyPappelroy closed 3 years ago
@mycroes Can you add a XML comment to S7Connection constructor, giving a short example for setting up the connection parameters?
I understand that you don't want to add any additional layers on top of what the S7 protocol itself does, but I think that entry hurdle is a bit steep.
Or in other words: I need to know how to plug my S7 Type, Slot and Rack number into those TSAP objects :)
@scamille I tried it out a while ago. Here is a small code snippet I used to connect. "ConnectioStatus" is a selfmade enum, not included in Sally7
class Program { public static S7Connection S7Connection; public static ConnectionStatus ConnectionStatus;
static async Task Main(string[] args) { if (S7Connection is null) S7Connection = Sally7.Plc.ConnectionFactory.GetConnection("192.168.50.115", Sally7.Plc.CpuType.S7_1500, 0, 1);
try
{
ConnectionStatus = ConnectionStatus.Connecting;
await S7Connection.OpenAsync();
ConnectionStatus = ConnectionStatus.Connected;
}
catch (Exception ex)
{
Console.WriteLine("Lyckas ej ansluta: " + Environment.NewLine + ex.Message);
ConnectionStatus = ConnectionStatus.Disconnected;
Console.ReadLine();
}
if (ConnectionStatus == ConnectionStatus.Connected)
{
while (true)
{
DataBlockDataItem<float[]> dataBlockDataItem = new DataBlockDataItem<float[]>();
dataBlockDataItem.DbNumber = 201;
dataBlockDataItem.StartByte = 1004;
dataBlockDataItem.Length = 3;
await S7Connection.ReadAsync(dataBlockDataItem);
}
}
Thanks a lot! I didn't see the connection factory at all yesterday. With this I am sure that I can pull this off.
I guess I'll just offer what I learned here as a small "How to get started" example to the readme.
I'll mention the ConnectionFactory in a comment as well.
This is the comment from 0.9.0. Thanks for your comments guys!
Do think you can include the comments in the next release? Best regards!