I use the S7 library to communicate with the PLC. When I try to read or write a single variable, at times, the system crashes. What is a better solution in this use for reading or writing a few variables?
Write To DB
or like example
WriteMultiVars
public Tuple<bool, string> WriteMultipleVarsItems(List<DataItem>writeDataItem)
{
string error = string.Empty;
bool result;
try
{
plc!.Write(writeDataItem.ToArray());
result = true;
//Console.WriteLine("Write ok");
}
catch (PlcException e)
{
error = e.Message;
result = false;
Console.WriteLine(error);
}
return Tuple.Create(result, error);
}
What solution is better? I try both variants, but I'm not sure what is better.