-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from libplctag/overload-read-write
Overload Read/Write to actually use Value directly
- Loading branch information
Showing
4 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using libplctag; | ||
using libplctag.DataTypes; | ||
using System; | ||
using System.Net; | ||
using System.Threading; | ||
|
||
namespace CSharpDotNetCore | ||
{ | ||
class SimpleExample | ||
{ | ||
public static void Run() | ||
{ | ||
//This is the absolute most simplified example code | ||
//Please see the other examples for more features/optimizations | ||
|
||
//Instantiate the tag with the proper mapper and datatype | ||
var myTag = new Tag<DintPlcMapper, int>() | ||
{ | ||
Name = "PROGRAM:SomeProgram.SomeDINT", | ||
Gateway = "10.10.10.10", | ||
Path = "1,0", | ||
PlcType = PlcType.ControlLogix, | ||
Protocol = Protocol.ab_eip, | ||
Timeout = TimeSpan.FromSeconds(5) | ||
}; | ||
|
||
//Write value to PLC | ||
//This will call Initialize internally since it's the first use of this tag | ||
//myTag.Value will be set to 3737 before being transferred to PLC | ||
myTag.Write(3737); | ||
|
||
//Read value from PLC | ||
//Value will also be accessible at myTag.Value | ||
int myDint = myTag.Read(); | ||
|
||
//Write to console | ||
Console.WriteLine(myDint); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters