NuGet package (binary only):
https://www.nuget.org/packages/CaSharpServer/
Download the server library here (server directory):
https://sourceforge.net/p/epicssharp/code/
Add the reference of the CaSharpServer assembly to your project.
To use it:
class Program { static int counter = 0; static CAIntRecord intRecord; static CAIntArrayRecord intArray; static CAStringRecord strRecord; static void Main(string[] args) { CAServer server = new CAServer(IPAddress.Parse("127.0.0.1"), 5064, 5064); intRecord = server.CreateRecord<CAIntRecord>("PCTOTO2:INT"); intRecord.PrepareRecord += new EventHandler(intRecord_PrepareRecord); intRecord.Scan = CaSharpServer.Constants.ScanAlgorithm.HZ10; intArray = server.CreateArrayRecord<CAIntArrayRecord>("PCTOTO2:ARR",1000); for (int i = 0; i < intArray.Length; i++) intArray.Value[i] = i; strRecord = server.CreateRecord<CAStringRecord>("PCTOTO2:STR"); strRecord.Value = "Default"; Console.ReadLine(); } static void intRecord_PrepareRecord(object sender, EventArgs e) { counter++; intRecord.Value = counter; } }
The constructor defines on which IP and on which ports the CA server must listen. You may run multiple servers on the same machine as long as the TCP port is different each time while sharing the same UDP port. However in this configuration you will reach the servers only while broadcasting the search request.
After the creation of the server object, simply instantiate any number of epics variables you want through the call of server.CreateRecord<TType>("channel-name") where TType is a CARecord derived type.
You can either set the values directly to the epics variables or on callback at the refresh rate you define.
It's possible to define your own objects type and use them in the server library as long as you derive from CARecord.