();
if (returnValues.Value != null)
{
value = from val in returnValues.Value select val.Key + val.Value;
siemensItems.Dispatcher.Invoke(() => siemensItems.ItemsSource = value);
}
else
{
Console.WriteLine(String.Format("ip {0} not return value", returnValues.Key));
}
};
task.TaskStart();
```
Here are the details to use the TaskManager.
1. Initialize the task manager.
Three arguments are: the max tasks you can run in a same time; How long did the next send message call happens(milliseconds); and you should keep the connection when a single message called complete.
2. Add the addresses that you want to communicate to PLC. Area are defined in AddressTranslator in each type of communiction.
Basically you can write only Id, Area, Address, CommunicationTag, DataType and Zoom, and it should work. And there are other fields that you can use.
More important, you can extend and implement your own field in UnitExtend in every AddressUnit, and it will return in return event.
3. Add a machine to TaskManager.
Add a machine like siemens machine to the task manager.
4. Implement ReturnValues event.
The argument return values is a key value pair. The architechture is:
* Key : the link address of machine (in sample is the second parameter).
* Value : Dictionary.
* Key : CommunicationTag in AddressUnit.
* Value : ReturnUnit.
* PlcValue : The return data, all in double type.
* UnitExtend : UnitExtend in AddressUnit. You should cast this class to your own class extends by UnitExtend.