internal Searcher(EpicsClient client) { Client = client; searchThread = new Thread(SearchChannels); searchThread.IsBackground = true; searchThread.Start(); }
internal static DataPipe CreateTcp(EpicsClient client, System.Net.IPEndPoint iPEndPoint) { DataPipe res = PopulatePipe(TcpChainList, client); ((TcpReceiver)res[0]).Start(iPEndPoint); return(res); }
/// <summary> /// Initializes a new instance of the <see cref="EpicsClientUDPConnection"/> class. /// </summary> /// <param name="client"> /// The client. /// </param> /// <param name="port"> /// The port. /// </param> public EpicsClientUDPConnection(EpicsClient client, int port) : base(port) { this.Client = client; this.UDPSocket.SendBufferSize = client.Config.UDPBufferSize; this.UDPSocket.ReceiveBufferSize = client.Config.UDPBufferSize; }
static EpicsProxy() { epicsClient = new EpicsClient(); epicsClient.Configuration.WaitTimeout = 5000; cleanup = new Thread(CleanOldChannels); cleanup.IsBackground = true; cleanup.Start(); }
static void Main(string[] args) { EpicsClient client = new EpicsClient(); EpicsChannel<int> test_channel_1 = client.CreateChannel<int>("NDW1033:dpk62:SIMPLE:VALUE1"); int PV_value = test_channel_1.Get<int>(); Console.WriteLine(PV_value); test_channel_1.Put<int>(2); }
static void Main(string[] args) { EpicsClient client = new EpicsClient(); string channelName = ""; bool usingMonitor = false; for (int i = 0; i < args.Length; i++) { if (args[i] == "-e") { i++; client.Configuration.SearchAddress = args[i]; } else if (args[i] == "-m") usingMonitor = true; else channelName = args[i]; } client.Configuration.DebugTiming = true; Console.WriteLine("EPICS Configuration: " + client.Configuration.SearchAddress); Console.WriteLine("Trying to read " + channelName); EpicsChannel<string> channel = client.CreateChannel<string>(channelName); if (usingMonitor) { Console.WriteLine("Monitor and wait for the first value back."); channel.MonitorChanged += new EpicsDelegate<string>(channel_MonitorChanged); gotMonitorValue.WaitOne(5000); } else { Console.WriteLine("Get and waits the value back."); try { Console.WriteLine(channel.Get()); } catch { } } Console.WriteLine(channel.Status.ToString()); TimeSpan? prevTime = null; foreach (var i in channel.ElapsedTimings) { if (!prevTime.HasValue) Console.WriteLine(i.Key + ": " + i.Value.ToString()); else Console.WriteLine(i.Key + ": " + (i.Value - prevTime).ToString()); prevTime = i.Value; } Console.WriteLine("Total: " + prevTime.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="EpicsClientUDPConnection"/> class. /// </summary> /// <param name="client"> /// The client. /// </param> public EpicsClientUDPConnection(EpicsClient client) { this.Client = client; this.Client.Config.ConfigChanged += this.config_ConfigChanged; this.UDPSocket.SendBufferSize = client.Config.UDPBufferSize; this.UDPSocket.ReceiveBufferSize = client.Config.UDPBufferSize; // just be sure it's set this.wrapTargetList(this.Client.Config.ServerList.getStringList()); }
/// <summary> /// Initializes a new instance of the <see cref="EpicsClientTCPConnection"/> class. /// </summary> /// <param name="iep"> /// The iep. /// </param> /// <param name="client"> /// The client. /// </param> internal EpicsClientTCPConnection(IPEndPoint iep, EpicsClient client) : base(iep) { this.Client = client; this.TCPMaxSendSize = client.Config.TCPMaxSendSize; this.TCPSocket.ReceiveBufferSize = client.Config.TCPBufferSize; this.TCPSocket.SendBufferSize = client.Config.TCPBufferSize; this.Send(EpicsCodec.CTCPGreet); this.sent = true; }
static DataPipe PopulatePipe(Type[] types, EpicsClient client) { DataPipe pipe = new DataPipe(); foreach (Type t in types) { DataFilter w = (DataFilter)t.GetConstructor(new Type[] { }).Invoke(new object[] { }); w.Client = client; w.Pipe = pipe; pipe.Add(w); } return pipe; }
static DataPipe PopulatePipe(Type[] types, EpicsClient client) { DataPipe pipe = new DataPipe(); foreach (Type t in types) { DataFilter w = (DataFilter)t.GetConstructor(new Type[] { }).Invoke(new object[] { }); w.Client = client; w.Pipe = pipe; pipe.Add(w); } return(pipe); }
static void Main(string[] args) { EpicsClient client = new EpicsClient(); /*client.Config.ServerList.Add("129.129.130.87:5432"); EpicsChannel<sbyte[]> screen = client.CreateChannel<sbyte[]>("PBGW:LOGVIEW");*/ client.Configuration.SearchAddress="172.22.200.117:5062"; EpicsChannel<sbyte[]> screen = client.CreateChannel<sbyte[]>("HIPA-TEST-GW:LOGVIEW"); screen.MonitorChanged += new EpicsDelegate<sbyte[]>(screen_MonitorChanged); Console.WindowWidth = 200; Console.WindowHeight = 100; Console.Clear(); Console.ReadKey(); }
static void Main(string[] args) { string[] channelNames = File.ReadAllLines(Directory.GetParent(Assembly.GetEntryAssembly().Location).FullName + "\\channel_list.txt"); EpicsClient client = new EpicsClient(); //client.Configuration.SearchAddress = "129.129.130.219:5062"; client.Configuration.SearchAddress = "fin-cagw02:5062"; /*List<EpicsChannel<string>> channels = channelNames.Select(client.CreateChannel<string>).ToList(); foreach(var i in channels) i.MonitorChanged += new EpicsDelegate<string>(Channel_MonitorChanged); channels = channelNames.Select(client.CreateChannel).ToList(); foreach (var i in channels) { i.MonitorChanged += new EpicsDelegate(Channel_MonitorChangedObject); i.StatusChanged += new EpicsStatusDelegate(i_StatusChanged); }*/ List<EpicsChannel<PSI.EpicsClient2.ExtControl<string>>> channelExt = channelNames .Where(row=>!row.Contains("WAVE") && !row.Contains("PICTURE")) .Select(client.CreateChannel<PSI.EpicsClient2.ExtControl<string>>).ToList(); foreach (var i in channelExt) i.MonitorChanged += new EpicsDelegate<PSI.EpicsClient2.ExtControl<string>>(Channel_MonitorChangedExtObject); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); while (true) { //var res=client.MultiGet<string>(channels.Where(row => row.Status == ChannelStatus.CONNECTED)); /*foreach (var i in channels.Where(row => row.Status == ChannelStatus.CONNECTED)) { var s = i.Get<string>(); }*/ Thread.Sleep(1000); //int nbConnected = channels.Where(row => row.Status == ChannelStatus.CONNECTED).Count() + channelExt.Where(row => row.Status == ChannelStatus.CONNECTED).Count(); //int nbConnected = channels.Count(row => row.Status == ChannelStatus.CONNECTED); int nbConnected = channelExt.Count(row => row.Status == ChannelStatus.CONNECTED); Console.Write("Events per sec: " + nbEvents + " / Connected: " + nbConnected + " (" + channelExt .Count+ ") \r"); nbEvents = 0; } }
void CheckGateway() { Thread.Sleep(40000); while (!shouldStop) { bool isOk=false; for (int i = 0; i < 5; i++) { using (EpicsClient client = new EpicsClient()) { //Console.WriteLine("Checking..."); client.Configuration.WaitTimeout = 15000; EpicsChannel<double> cpuInfo = client.CreateChannel<double>(ConfigurationManager.AppSettings["GatewayName"] + ":CPU"); try { double v = cpuInfo.Get(); if (v < 80.0) { isOk = true; break; } /*else Console.WriteLine("All ok");*/ } catch { } } Thread.Sleep(1000); } if (!isOk) { StopGateway(); StartGateway(); } else Thread.Sleep(10000); } }
static void Main(string[] args) { EpicsClient client = new EpicsClient(); client.Configuration.SearchAddress = "129.129.130.87:5432"; channel = client.CreateChannel<string>("ADG1:IST1:2"); channel.StatusChanged += new EpicsStatusDelegate(channel_StatusChanged); channel.MonitorChanged += new EpicsDelegate<string>(channel_MonitorChanged); while (true) { switch (Console.ReadKey().KeyChar) { case (char)27: return; case (char)13: if (channel == null) { channel = client.CreateChannel<string>("ADG1:IST1:2"); channel.StatusChanged += new EpicsStatusDelegate(channel_StatusChanged); channel.MonitorChanged += new EpicsDelegate<string>(channel_MonitorChanged); } else { channel.Dispose(); channel = null; } break; case ' ': monitored = !monitored; if (monitored) channel.MonitorChanged += new EpicsDelegate<string>(channel_MonitorChanged); else channel.MonitorChanged -= new EpicsDelegate<string>(channel_MonitorChanged); break; default: break; } } }
public static void Main() { /*Application.EnableVisualStyles(); * Application.SetCompatibleTextRenderingDefault(false); * Application.Run(new TestApp());*/ var client = new EpicsClient(); var monitor = client.CreateChannel("TestChannel01:Counter"); monitor.MonitorChanged += (sender, value) => Console.WriteLine(value); Task.Factory.StartNew(() => { var server = new EpicsServer(); var record = server.GetEpicsRecord <string>("TestChannel01:Counter"); for (int i = 0; i < 500; i++) { record.VAL = i.ToString(); Thread.Sleep(1000); } }); /*var server = new EpicsServer(); * var record = server.GetEpicsRecord<double>("TestChannel01:Counter"); * record.HIGH = 50; * record.HIHI = 75; * record.VAL = 19; * * for (int i = 0; i < 10; i++) * { * record.VAL = i; * Thread.Sleep(1000); * }*/ Console.ReadKey(); }
public void ClientServer() { using (var server = new EpicsServer()) using (var client = new EpicsClient()) { server.Config.BeaconPort = 95; server.Config.TCPPort = 115; server.Config.UDPPort = 115; server.Config.UDPDestPort = 115; var record = server.GetEpicsRecord<double>("OMA:Counter"); record.HIGH = 50; record.HIHI = 75; record.VAL = 19; client.Config.UDPBeaconPort = 95; client.Config.UDPIocPort = 115; var monitor = client.CreateChannel("OMA:Counter"); Assert.Equal(19, monitor.Get()); } }
public void ClientServer() { using (var server = new EpicsServer()) using (var client = new EpicsClient()) { server.Config.BeaconPort = 95; server.Config.TCPPort = 115; server.Config.UDPPort = 115; server.Config.UDPDestPort = 115; var record = server.GetEpicsRecord <double>("OMA:Counter"); record.HIGH = 50; record.HIHI = 75; record.VAL = 19; client.Config.UDPBeaconPort = 95; client.Config.UDPIocPort = 115; var monitor = client.CreateChannel("OMA:Counter"); Assert.Equal(19, monitor.Get()); } }
public static void Main() { /*Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new TestApp());*/ var client = new EpicsClient(); var monitor = client.CreateChannel("TestChannel01:Counter"); monitor.MonitorChanged += (sender, value) => Console.WriteLine(value); Task.Factory.StartNew(() => { var server = new EpicsServer(); var record = server.GetEpicsRecord<string>("TestChannel01:Counter"); for (int i = 0; i < 500; i++) { record.VAL = i.ToString(); Thread.Sleep(1000); } }); /*var server = new EpicsServer(); var record = server.GetEpicsRecord<double>("TestChannel01:Counter"); record.HIGH = 50; record.HIHI = 75; record.VAL = 19; for (int i = 0; i < 10; i++) { record.VAL = i; Thread.Sleep(1000); }*/ Console.ReadKey(); }
static void ProscanWave() { PBCaGw.Services.Log.Enabled = false; gateway = new Gateway(); gateway.Configuration.GatewayName = "TESTGW"; gateway.Configuration.LocalAddressSideA = ip + ":5555"; //gateway.Configuration.LocalAddressSideA = "129.129.130.87:5555"; gateway.Configuration.RemoteAddressSideA = remoteIp + ":5552"; gateway.Configuration.LocalAddressSideB = ip + ":5888"; //gateway.Configuration.RemoteAddressSideB = remoteIp + ":5777"; gateway.Configuration.RemoteAddressSideB = "172.25.60.67:5062"; gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.UNIDIRECTIONAL; gateway.SaveConfig(); gateway.Start(); Console.WriteLine("Gateway up"); //gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.BIDIRECTIONAL; client = new EpicsClient(); client.Configuration.WaitTimeout = 2000; client.Configuration.SearchAddress = ip + ":5555"; List<EpicsChannel<ExtGraphic<string>>> channels = new List<EpicsChannel<ExtGraphic<string>>>(); foreach (string i in channelsToConnect) { EpicsChannel<ExtGraphic<string>> ch = client.CreateChannel<ExtGraphic<string>>(i); ch.MonitorChanged += new EpicsDelegate<ExtGraphic<string>>(ch_MonitorChanged); channels.Add(ch); } Thread.Sleep(2000); gateway.Dispose(); PBCaGw.Services.Log.Enabled = true; //Thread.Sleep(5000); gateway = new Gateway(); gateway.Configuration.LocalAddressSideA = ip + ":5555"; //gateway.Configuration.LocalAddressSideA = "129.129.130.87:5555"; gateway.Configuration.RemoteAddressSideA = remoteIp + ":5552"; gateway.Configuration.LocalAddressSideB = ip + ":5888"; //gateway.Configuration.RemoteAddressSideB = remoteIp + ":5777"; gateway.Configuration.RemoteAddressSideB = "172.25.60.67:5062"; gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.UNIDIRECTIONAL; gateway.Start(); Thread.Sleep(5000); foreach (var i in channels) { if (i.Status != ChannelStatus.CONNECTED) { Console.WriteLine(i.ChannelName + " not connected."); } } //client.Dispose(); Console.ReadKey(); //Console.WriteLine(ch.Get<string>()); }
private static void MultipleCreate() { Console.WindowWidth = 120; Console.BufferWidth = 120; Console.WindowHeight = 60; Console.BufferHeight = 3000; server = new CAServer(IPAddress.Parse(ip), 5777, 5777); CAStringRecord record = server.CreateRecord<CAStringRecord>("PCTEST:STR"); record.Value = "Hello there!"; gateway = new Gateway(); gateway.Configuration.GatewayName = "TESTGW"; gateway.Configuration.LocalAddressSideA = ip + ":5555"; //gateway.Configuration.LocalAddressSideA = "129.129.130.87:5555"; gateway.Configuration.RemoteAddressSideA = ip + ":5552"; gateway.Configuration.LocalAddressSideB = ip + ":5888"; //gateway.Configuration.RemoteAddressSideB = remoteIp + ":5777"; gateway.Configuration.RemoteAddressSideB = ip + ":5777"; gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.UNIDIRECTIONAL; gateway.SaveConfig(); Gateway.AutoCreateChannel = false; Gateway.RestoreCache = false; gateway.Start(); Thread.Sleep(2000); EpicsClient c1 = new EpicsClient(); c1.Configuration.SearchAddress = ip + ":5555"; EpicsClient c2 = new EpicsClient(); c2.Configuration.SearchAddress = ip + ":5555"; EpicsChannel ca1 = c1.CreateChannel("PCTEST:STR"); EpicsChannel ca2 = c2.CreateChannel("PCTEST:STR"); Console.WriteLine("Reading..."); ca1.MonitorChanged += new EpicsDelegate(ca1_MonitorChanged); ca2.MonitorChanged += new EpicsDelegate(ca2_MonitorChanged); Console.ReadKey(); }
static void MultiConnect() { EpicsChannel[] channels = new EpicsChannel[intRecords.Length]; for (int i = 0; i < channels.Length; i++) channels[i] = client.CreateChannel("PCT:INT-" + i); client.MultiConnect(channels); client.Dispose(); client = new EpicsClient(); client.Configuration.SearchAddress = "127.0.0.1:5555"; for (int i = 0; i < channels.Length; i++) channels[i] = client.CreateChannel("PCT:INT-" + i); client.MultiConnect(channels); Console.WriteLine("Done..."); Dictionary<uint, string> sids = new Dictionary<uint, string>(); foreach (EpicsChannel c in channels) { if (sids.ContainsKey(c.SID) && sids[c.SID] != c.ChannelName) { Console.WriteLine("Reuse: " + c.SID); } else if (!sids.ContainsKey(c.SID)) sids.Add(c.SID, c.ChannelName); } client.Dispose(); }
static void MonAll() { //PBCaGw.Services.Log.Enabled = false; Stopwatch sw = new Stopwatch(); for (int loop = 0; loop < 10; loop++) { gateway = new Gateway(); gateway.Configuration.GatewayName = "TESTGW"; gateway.Configuration.LocalAddressSideA = ip + ":5555"; //gateway.Configuration.LocalAddressSideA = "129.129.130.87:5555"; gateway.Configuration.RemoteAddressSideA = remoteIp + ":5552"; gateway.Configuration.LocalAddressSideB = ip + ":5888"; //gateway.Configuration.RemoteAddressSideB = remoteIp + ":5777"; gateway.Configuration.RemoteAddressSideB = "172.25.60.67:5062"; gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.UNIDIRECTIONAL; gateway.SaveConfig(); gateway.Start(); Console.WriteLine("Gateway up"); //gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.BIDIRECTIONAL; Gateway.BufferedSockets = false; Thread.Sleep(1000); multiActionCountDown = new CountdownEvent(channelsToConnect.Count(row => !row.Contains("TRACE"))); hadValue = new Dictionary<string, bool>(); sw.Start(); client = new EpicsClient(); client.Configuration.WaitTimeout = 2000; client.Configuration.SearchAddress = ip + ":5555"; List<EpicsChannel<ExtGraphic<string>>> channels = new List<EpicsChannel<ExtGraphic<string>>>(); foreach (string i in channelsToConnect.Where(row => !row.Contains("TRACE"))) { EpicsChannel<ExtGraphic<string>> ch = client.CreateChannel<ExtGraphic<string>>(i); ch.MonitorChanged += new EpicsDelegate<ExtGraphic<string>>(ch_MonitorChangedGotValue); channels.Add(ch); } if (multiActionCountDown.Wait(5000) == false) Console.WriteLine("Didn't got it..."); client.Dispose(); sw.Stop(); gateway.Dispose(); } Console.WriteLine("Time: " + sw.Elapsed.ToString()); Console.ReadKey(); }
public EpicsSharp() { _client = new EpicsClient(); _client.Configuration.WaitTimeout = 2000; _channels = new Dictionary<string, EpicsChannel>(); }
static void ReconnectProscan() { gateway = new Gateway(); gateway.Configuration.GatewayName = "TESTGW"; gateway.Configuration.LocalAddressSideA = ip + ":5555"; //gateway.Configuration.LocalAddressSideA = "129.129.130.87:5555"; gateway.Configuration.RemoteAddressSideA = remoteIp + ":5552"; gateway.Configuration.LocalAddressSideB = ip + ":5888"; //gateway.Configuration.RemoteAddressSideB = remoteIp + ":5777"; gateway.Configuration.RemoteAddressSideB = "172.25.60.67:5062"; gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.UNIDIRECTIONAL; gateway.SaveConfig(); gateway.Start(); client = new EpicsClient(); client.Configuration.WaitTimeout = 2000; client.Configuration.SearchAddress = ip + ":5555"; EpicsChannel<ExtGraphic<string>> ch = client.CreateChannel<ExtGraphic<string>>("MMAP10Y:CMODE:1"); ch.StatusChanged += new EpicsStatusDelegate(ch_StatusChanged); ch.MonitorChanged += new EpicsDelegate<ExtGraphic<string>>(ch_MonitorChangedView); EpicsChannel<ExtGraphic<string>> ch2 = client.CreateChannel<ExtGraphic<string>>("MMAP12Y:CNSAMPLES:1"); ch2.StatusChanged += new EpicsStatusDelegate(ch_StatusChanged); ch2.MonitorChanged += new EpicsDelegate<ExtGraphic<string>>(ch_MonitorChangedView); Thread.Sleep(1000); Console.WriteLine("------------------------------------------------------------------------"); gateway.Dispose(); //Thread.Sleep(5000); gateway = new Gateway(); gateway.Configuration.LocalAddressSideA = ip + ":5555"; //gateway.Configuration.LocalAddressSideA = "129.129.130.87:5555"; gateway.Configuration.RemoteAddressSideA = remoteIp + ":5552"; gateway.Configuration.LocalAddressSideB = ip + ":5888"; //gateway.Configuration.RemoteAddressSideB = remoteIp + ":5777"; gateway.Configuration.RemoteAddressSideB = "172.25.60.67:5062"; gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.UNIDIRECTIONAL; gateway.Start(); /*EpicsChannel restart = client.CreateChannel("TESTGW:RESTART"); try { restart.Put<int>(2); } catch { }*/ Thread.Sleep(5000); Console.ReadKey(); }
internal static DataPipe CreateTcp(EpicsClient client, System.Net.IPEndPoint iPEndPoint) { DataPipe res = PopulatePipe(TcpChainList, client); ((TcpReceiver)res[0]).Start(iPEndPoint); return res; }
static void Main(string[] args) { int nbRepeat = 1; if (args.Any(row => row == "-r")) { for (int i = 0; i < args.Length; i++) { if (args[i] == "-r") { i++; nbRepeat = int.Parse(args[i]); } } } for (int r = 0; r < nbRepeat || nbRepeat == 0;) { if (nbRepeat > 0) { r++; } if (r != 0 || nbRepeat == 0) { Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Thread.Sleep(100); } using (EpicsClient client = new EpicsClient()) { client.Configuration.WaitTimeout = 10000; string channelName = ""; bool usingMonitor = false; for (int i = 0; i < args.Length; i++) { if (args[i] == "-e") { i++; client.Configuration.SearchAddress = args[i]; } else if (args[i] == "-m") { usingMonitor = true; } else { channelName = args[i]; } } client.Configuration.DebugTiming = true; Console.WriteLine("EPICS Configuration: " + client.Configuration.SearchAddress); Console.WriteLine("Trying to read " + channelName); EpicsChannel <string> channel = client.CreateChannel <string>(channelName); bool hasError = false; if (usingMonitor) { Console.WriteLine("Monitor and wait for the first value back."); channel.MonitorChanged += new EpicsDelegate <string>(channel_MonitorChanged); try { gotMonitorValue.WaitOne(5000); } catch { hasError = true; } } else { Console.WriteLine("Get and waits the value back."); try { Console.WriteLine(channel.Get()); } catch (Exception ex) { hasError = true; Console.WriteLine(ex); } } Console.WriteLine(channel.Status.ToString()); TimeSpan?prevTime = null; foreach (var i in channel.ElapsedTimings) { if (!prevTime.HasValue) { Console.WriteLine(i.Key + ": " + i.Value.ToString()); } else { Console.WriteLine(i.Key + ": " + (i.Value - prevTime).ToString()); } prevTime = i.Value; } Console.WriteLine("Total: " + prevTime.ToString()); Console.WriteLine("Search answered by " + channel.SearchAnswerFrom); Console.WriteLine("IOC: " + channel.IOC); Console.WriteLine("EPICS Type: " + channel.ChannelDefinedType); if (channel.Status != ChannelStatus.CONNECTED || hasError) { Console.Beep(); } } } }
internal static DataPipe CreateUdp(EpicsClient client) { DataPipe res = PopulatePipe(UdpChainList, client); return(res); }
public Client() { this.epicsClient = new EpicsClient(); this.Channels = new Dictionary <string, Channel>(); }
private static void QuickMonitor() { gateway = new Gateway(); gateway.Configuration.GatewayName = "TESTGW"; gateway.Configuration.LocalAddressSideA = "127.0.0.1:5432"; //gateway.Configuration.LocalAddressSideA = "129.129.130.87:5555"; gateway.Configuration.RemoteAddressSideA = "127.0.0.1:5552"; gateway.Configuration.LocalAddressSideB = "129.129.130.87:5064"; //gateway.Configuration.LocalAddressSideB = "172.22.200.116:5432"; //gateway.Configuration.RemoteAddressSideB = remoteIp + ":5777"; //gateway.Configuration.RemoteAddressSideB = "172.22.255.255:5064"; gateway.Configuration.RemoteAddressSideB = "172.22.200.117:5062"; gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.UNIDIRECTIONAL; gateway.SaveConfig(); gateway.Start(); Thread.Sleep(1000); EpicsClient client = new EpicsClient(); string clientConfig = "127.0.0.1:5432"; //string clientConfig="172.22.100.101:5064"; client.Configuration.SearchAddress = clientConfig; //string[] channelNames = { "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL", "ZPSAF101-VME:CALNCONN.EGU", "ZPSAF101-VME:CALDCONN.EGU", "ZPSAF101-VME:LOAD", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:HBT" }; //string[] channelNames = { "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CALNCONN.EGU", "ZPSAF101-VME:CALDCONN.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU" }; string[] channelNames = { "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CALNCONN.EGU", "ZPSAF101-VME:CALDCONN.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:CAL.EGU", "ZPSAF101-VME:HBT.EGU", "ZPSAF101-VME:HBT.EGU", "ZPSAF101-VME:LOAD.EGU" }; //string[] channelNames = { "ZPSAF101-VME:CAL.EGU" }; while (true) { for (int l = 0; l < 10; l++) { List<EpicsChannel<ExtGraphic<string>>> channels = new List<EpicsChannel<ExtGraphic<string>>>(); foreach (var i in channelNames) { EpicsChannel<ExtGraphic<string>> c = client.CreateChannel<ExtGraphic<string>>(i); c.MonitorChanged += new EpicsDelegate<ExtGraphic<string>>(QuickMonitor); channels.Add(c); } foreach (var i in channels) i.Dispose(); client.Dispose(); client = new EpicsClient(); client.Configuration.SearchAddress = clientConfig; } if (true) { bool gotError = false; List<EpicsChannel<ExtGraphic<string>>> channels = new List<EpicsChannel<ExtGraphic<string>>>(); foreach (var i in channelNames) { EpicsChannel<ExtGraphic<string>> c = client.CreateChannel<ExtGraphic<string>>(i); channels.Add(c); } CountdownEvent multiActionCountDown = new CountdownEvent(channelNames.Count()); Dictionary<uint, bool> gotMonitor = new Dictionary<uint, bool>(); foreach (EpicsChannel<ExtGraphic<string>> c in channels) { c.MonitorChanged += delegate(EpicsChannel<ExtGraphic<string>> sender, ExtGraphic<string> newValue) { if ((newValue.Value != "#" && sender.ChannelName.Contains(":CAL")) || (newValue.Value != "%" && sender.ChannelName.Contains(":LOAD")) || (newValue.Value != "ticks" && sender.ChannelName.Contains(":HBT"))) { Console.WriteLine("Wrong data on CID (" + sender.ChannelName + "): " + sender.CID + ", " + newValue.Value); gotError = true; } lock (gotMonitor) { if (!gotMonitor.ContainsKey(sender.CID)) { gotMonitor.Add(sender.CID, true); multiActionCountDown.Signal(); } } }; c.MonitorChanged += new EpicsDelegate<ExtGraphic<string>>(QuickMonitor); } multiActionCountDown.Wait(2500); bool allConnected = true; foreach (var i in channels) { if (i.Status != ChannelStatus.CONNECTED) { allConnected = false; Console.WriteLine(i.ChannelName + " not connected."); //gotError = true; } } if (!allConnected) { needToShow = false; //gotError = true; Console.WriteLine("Not all connected!!!!!"); } foreach (var i in channels) i.Dispose(); client.Dispose(); client = new EpicsClient(); client.Configuration.SearchAddress = clientConfig; multiActionCountDown.Dispose(); if (gotError) { Console.Beep(); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); needToShow = true; } } } }
static void ReconnectIoc() { InitServer(); gateway = new Gateway(); gateway.Configuration.GatewayName = "TESTGW"; gateway.Configuration.LocalAddressSideA = ip + ":5555"; //gateway.Configuration.LocalAddressSideA = "129.129.130.87:5555"; gateway.Configuration.RemoteAddressSideA = ip + ":5552"; gateway.Configuration.LocalAddressSideB = ip + ":5888"; //gateway.Configuration.RemoteAddressSideB = remoteIp + ":5777"; gateway.Configuration.RemoteAddressSideB = ip + ":5777"; gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.UNIDIRECTIONAL; gateway.SaveConfig(); Gateway.AutoCreateChannel = false; Gateway.RestoreCache = false; gateway.Start(); client = new EpicsClient(); client.Configuration.SearchAddress = ip + ":5555"; client.Configuration.WaitTimeout = 200; chans = new List<EpicsChannel>(); for (int i = 0; i < 1; i++) { EpicsChannel<int> intChan = client.CreateChannel<int>("PCT:INT-" + i); chans.Add(intChan); intChan.MonitorChanged += new EpicsDelegate<int>(intChan_MonitorChanged); } Thread t = new Thread(ChanToGet); t.IsBackground = true; t.Start(); //Thread.Sleep(2000); //chans[0].Get<int>(); //for (int i = 0; i < 100; i++) while(true) { Thread.Sleep(5000); server.Dispose(); Thread.Sleep(2000); InitServer(); } Console.ReadKey(); }
internal static DataPipe CreateUdp(EpicsClient client) { DataPipe res = PopulatePipe(UdpChainList, client); return res; }
private static void ZTest() { string[] channelNames = File.ReadAllLines(@"channels.txt"); List<EpicsChannel> channels = new List<EpicsChannel>(); client = new EpicsClient(); //client.Configuration.SearchAddress = "172.22.200.117:5062"; //client.Configuration.SearchAddress = "172.22.200.103:5062"; client.Configuration.WaitTimeout = 2000; channelNames = channelNames.OrderBy(a => Guid.NewGuid()).ToArray(); gotDisconnect = new AutoResetEvent(false); foreach (var i in channelNames) { if (needToStop) break; Console.WriteLine("Checking " + i); EpicsChannel<ExtControl<string>> c = client.CreateChannel<ExtControl<string>>(i.Trim()); //EpicsChannel c = client.CreateChannel(i.Trim()); gotValue = new AutoResetEvent(false); c.MonitorChanged += gotValueNotified; channels.Add(c); /*if (channels.Count > 295) break;*/ c.StatusChanged += new EpicsStatusDelegate(c_StatusChanged); Thread.Sleep(100); /*try { if (!gotValue.WaitOne(2000)) { Console.WriteLine("Never got back."); } } catch { Console.WriteLine("Didn't get value for "+i); } c.Dispose(); client.Dispose();*/ } //Console.ReadKey(); gotDisconnect.WaitOne(); Console.WriteLine("Nb ok: " + channels.Count); Console.WriteLine("Disconnected!"); client.Dispose(); Console.ReadKey(); }
static void InternTest() { InitServer(); gateway = new Gateway(); gateway.Configuration.LocalAddressSideA = ip + ":5555"; //gateway.Configuration.LocalAddressSideA = "129.129.130.87:5555"; gateway.Configuration.RemoteAddressSideA = remoteIp + ":5552"; gateway.Configuration.LocalAddressSideB = ip + ":5888"; gateway.Configuration.RemoteAddressSideB = remoteIp + ":5777"; gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.UNIDIRECTIONAL; //gateway.Configuration.ConfigurationType = PBCaGw.Configurations.ConfigurationType.BIDIRECTIONAL; gateway.Start(); client = new EpicsClient(); client.Configuration.SearchAddress = ip + ":5555"; //client.Configuration.SearchAddress = "129.129.130.255:5555"; //client.Configuration.SearchAddress = "127.0.0.1:5777"; //MultiConnect(); //Checks2(); EpicsChannel ca = client.CreateChannel("PCT:INT-1"); Console.WriteLine(ca.Get<string>()); //GetDisconnect(); Console.WriteLine("Press a key to continue..."); Console.ReadKey(); }
static void Main(string[] args) { using (EpicsClient client = new EpicsClient()) { client.Configuration.SearchAddress="129.129.130.87:6789"; if (args.Length > 0 && args[0] == "-m") { //Console.WriteLine("Running monitor mode"); EpicsChannel<string>[] channels = new EpicsChannel<string>[100]; for (int j = 0; j < channels.Length; j++) { channels[j] = client.CreateChannel<string>("STRESS:INT:" + j / 2); channels[j].MonitorChanged += new EpicsDelegate<string>(Program_MonitorChanged); } Thread.Sleep(5000); int nbNotConnected = 0; for (int j = 0; j < channels.Length; j++) { if (channels[j].Status != ChannelStatus.CONNECTED) nbNotConnected++; } if (nbNotConnected > 0) { Console.WriteLine("Channels not connected: " + nbNotConnected); Console.Beep(); Thread.Sleep(10000); } for (int j = 0; j < channels.Length; j++) { channels[j].Dispose(); } } else { for (int i = 0; i < 10; i++) { //Console.WriteLine("Create channel"); EpicsChannel<string> channel = client.CreateChannel<string>("STRESS:INT"); channel.StatusChanged += new EpicsStatusDelegate(channel_StatusChanged); try { //Console.WriteLine("Get"); for (int j = 0; j < 10; j++) { string val = channel.Get(); if (val != "1234") Console.WriteLine("Wrong value!"); //Console.WriteLine("Got " + val); } } catch { Console.WriteLine("Didn't got back!"); //Console.Beep(); } channel.Dispose(); Thread.Sleep(10); } //Console.WriteLine("Disposed"); } } }
void ContextNewName(DebugContext ctx, string name) { this.Dispatcher.BeginInvoke((Action)delegate { if (epicsClient != null) { foreach (var i in channels) { i.Dispose(); } channels.Clear(); epicsClient.Dispose(); } txtGatewayName.Text = name; epicsClient = new EpicsClient(); epicsClient.Configuration.SearchAddress = (string)Properties.Settings.Default["StoredGateway"]; foreach (var i in channelNames) { EpicsChannel<string> channel = epicsClient.CreateChannel<string>(name + i); channels.Add(channel); channel.MonitorChanged += new EpicsDelegate<string>(ChannelMonitorChanged); } }); }