private static void SimpleServer() { Console.WindowWidth = 120; Console.BufferWidth = 120; Console.WindowHeight = 60; Console.BufferHeight = 3000; server = new CAServer(IPAddress.Parse(ip), 5777, 5777); CAIntRecord record = server.CreateRecord<CAIntRecord>("MXI1:ILOG:2"); record.Value = 5; gateway = new Gateway(); gateway.Configuration.GatewayName = "TESTGW"; gateway.Configuration.LocalAddressSideA = ip + ":5432"; //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(); Console.ReadKey(); gateway.Dispose(); }
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(); }
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(); }
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>()); }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Console.WriteLine("PBCaGW " + Gateway.Version); Console.WriteLine("Build on " + DiagnosticServer.BuildTime.ToString(CultureInfo.InvariantCulture)); Console.WriteLine("(c) Paul Scherrer Institute - GFA IT - 2012"); // Setup the console look try { Console.Title = "PBCaGW - " + System.Configuration.ConfigurationManager.AppSettings["gatewayName"]; Console.WindowWidth = 120; Console.BufferWidth = 120; Console.WindowHeight = 60; Console.BufferHeight = 3000; } catch { } if (System.Diagnostics.Debugger.IsAttached) { Console.WriteLine("Press return to stop the gateway..."); } else { Console.WriteLine("Press Ctrl+C to stop the gateway..."); Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress); } Console.WriteLine(""); /*Gateway.AutoCreateChannel = false; Gateway.RestoreCache = false;*/ /*Gateway.AutoCreateChannel = false; Gateway.RestoreCache = false;*/ //Gateway.AutoCreateChannel = false; //Gateway.BufferedSockets = false; gateway = new Gateway(); gateway.LoadConfig(); gateway.Start(); while (true) { ConsoleKeyInfo k = Console.ReadKey(); switch (k.Key) { case ConsoleKey.Spacebar: DataPacket.ShowPools(); break; case ConsoleKey.L: Log.ShowAll = !Log.ShowAll; break; default: if (System.Diagnostics.Debugger.IsAttached) { gateway.Dispose(); return; } break; } } /*if (System.Diagnostics.Debugger.IsAttached) { while (true) { ConsoleKeyInfo k = Console.ReadKey(); switch (k.Key) { case ConsoleKey.Spacebar: DataPacket.ShowPools(); break; default: gateway.Dispose(); return; } } } else { while (true) Console.ReadKey(); }*/ }