public void Start()
        {
            //gs5154 = InitRequestSocket("224.0.1.1", 5154);
            //gs5156 = InitRequestSocket("224.0.1.1", 5156);
            //gs5158 = InitRequestSocket("224.0.1.1", 5158);

            DDEClient = new TcpClient();
            //DDEClient.Connect("smkbof1", 1419);

            mainGate1 = new ConnectionProvider.Client("Converter1");
            mainGate2 = new ConnectionProvider.Client("Converter2");
            mainGate3 = new ConnectionProvider.Client("Converter3");

            gl5153 = new GasListener("224.0.1.1", 5153);
            gl5153.OnOffGas += new OnOffGasEventHandler(onConverter1);
            gl5153.OnOffGas += new OnOffGasEventHandler(onConverter1DDE);

            gl5155 = new GasListener("224.0.1.1", 5155);
            gl5155.OnOffGas += new OnOffGasEventHandler(onConverter2);
            gl5155.OnOffGas += new OnOffGasEventHandler(onConverter2DDE);

            gl5157 = new GasListener("224.0.1.1", 5157);
            gl5157.OnOffGas += new OnOffGasEventHandler(onConverter3);
            gl5157.OnOffGas += new OnOffGasEventHandler(onConverter3DDE);

            //var GroupAddress = IPAddress.Parse("224.168.100.2");
            //var GroupPort = 11000;

            //Thread thread = new System.Threading.Thread(RequestsThread);
            //thread.Start();
        }
        private static void Main(string[] argv)
        {
            using (var l = new Logger("PipeCatcher"))
            {
                try
                {
                    var o = new FlexEvent("dummy"); /// нужно чтобы сборка загрузилась
                    CoreGate = new ConnectionProvider.Client();
                    var conf = ConfigurationManager.OpenExeConfiguration("");
                    var settings = conf.AppSettings.Settings;
                    var dbrlist = new List<DBReader>();
                    foreach (KeyValueConfigurationElement pipe in settings)
                    {
                        if (!pipe.Key.StartsWith("pipe")) continue;
                        foreach (KeyValueConfigurationElement kvel in settings)
                        {
                            if (kvel.Key.StartsWith("connectionString"))
                            {
                                dbrlist.Add(new DBReader(kvel.Value, pipe.Value));
                            }
                        }
                    }
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    Application.Run(new Catcher(dbrlist, Application.ExecutablePath));
                }
                catch (Exception e)
                {
                    l.err("PipeCatcher.Main exception {0}", e);
                }
            }
        }
 static void Main(string[] args)
 {
     ConnectionProvider.Client mainGate;
     var o = new HeatChangeEvent();
     mainGate = new ConnectionProvider.Client(new Listener());
     mainGate.Subscribe();
     Console.WriteLine("Breake Listenere Started");
     Console.ReadLine();
 }
 public void Start(string unit)
 {
     var thread = new Thread(() =>
     {
         var events = new EventsListener(unit);
         var mainGate = new ConnectionProvider.Client(unit, events);
         mainGate.Subscribe();
     }) { IsBackground = true };
     thread.Start();
 }
 private static void Main()
 {
     using (var l = new Logger("TransferModelOutput"))
     {
         try
         {
             var pointStyle = new NumberFormatInfo();
             pointStyle.NumberDecimalSeparator = ".";
             CoreGate = new ConnectionProvider.Client();
             var conf = ConfigurationManager.OpenExeConfiguration("");
             var settings = conf.AppSettings.Settings;
             var fex = new ConnectionProvider.FlexHelper(Convert.ToString(settings["?"].Value));
             do
             {
                 foreach (KeyValueConfigurationElement kvel in settings)
                 {
                     if (!kvel.Key.StartsWith("?"))
                     {
                         if (kvel.Value.StartsWith("i", true, null))
                         {
                             string[] imarg = kvel.Value.Substring(1).Split(':');
                             fex.AddInt(kvel.Key, rnd.Next(Convert.ToInt32(imarg[0]),
                                 Convert.ToInt32(imarg[1])));
                         }
                         else if (kvel.Value.StartsWith("#"))
                         {
                             fex.AddStr(kvel.Key, kvel.Value.Substring(1));
                         }
                         else
                         {
                             string[] marg = kvel.Value.Split(':');
                             fex.AddDbl(kvel.Key,
                                        randomFromTo(Convert.ToDouble(marg[0], pointStyle),
                                                     Convert.ToDouble(marg[1], pointStyle)));
                         }
                     }
                 }
                 fex.Fire(CoreGate);
                 l.msg("Event fired>\n{0}", fex.evt);
                 for (int i = 0; i < 3; i++)
                 {
                     Console.Write(".");
                     System.Threading.Thread.Sleep(300);
                 }
                 fex.ClearArgs();
                 Console.Write(">");
             } while ("q" != Console.ReadLine());
             Console.WriteLine("Done");
         }
         catch (Exception e)
         {
             l.err("TransferModelOutput.Main exception {0}", e);
         }
     }
 }
 static void Main(string[] args)
 {
     var o = new TestEvent();
     m_listenGate = new ConnectionProvider.Client(new Listener());
     m_listenGate.Subscribe();
     var conf = ConfigurationManager.OpenExeConfiguration("");
     var settings = conf.AppSettings.Settings;
     m_startsWith = Convert.ToString(settings["?"].Value);
     Console.WriteLine("FlexEventSaver started");
     Console.ReadLine();
 }
 public static void Main(string[] args)
 {
     using (Logger l = new Logger("Bazooka"))
     {
         try
         {
             for (int i = 0; i < args.Count(); i++)
             {
                 l.msg("Command line argument {0} is <{1}>", i, args[i]);
                 if (i > 0)
                 {
                     string[] res = args[i].Split(new[] {'='}, 2);
                     ArgList.Add(res[0], res[1]);
                     l.msg("\tRecognized as <{0}>=<{1}> key-value pair", res[0], res[1]);
                 }
             }
             var o = new HeatChangeEvent(); /// нужно чтобы сборка загрузилась
             EventsList = BaseEvent.GetEvents();
             bool found = false;
             for (int index = 0; index < EventsList.Length; index++)
             {
                 if (EventsList[index].Name == args[0])
                 {
                     l.msg("Event {0} found -- preparing parameters:", args[0]);
                     EventToPush = (CommonTypes.BaseEvent) Activator.CreateInstance(EventsList[index]);
                     // Enum all the properties
                     foreach (var prop in EventsList[index].GetProperties())
                     {
                         l.msg("\tProperty {0} {1} == {2}", prop.PropertyType.ToString(), prop.Name,
                               prop.GetValue(EventToPush, null));
                     }
                     // real processing
                     found = true;
                     break;
                 }
             }
             if (found)
             {
                 m_pushGate = new ConnectionProvider.Client();
                 m_pushGate.PushEvent(EventToPush);
                 System.Threading.Thread.Sleep(1000);
                 l.msg("Event fired>\n{0}", EventToPush.ToString());
             }
             else
             {
                 l.err("Unknown event {0}", args[0]);
             }
         }
         catch (Exception e)
         {
             l.err("Exception caught:\n{0}", e.ToString());
         }
     }
 }
        public void Play()
        {
            try
            {
                EventsListener el = new EventsListener(this);
                mainGate = new ConnectionProvider.Client(el);
                DateTime? lastTime = null;
                this.Invoke((Action)delegate { pbProgress.Step = 1; });
                this.Invoke((Action)delegate { tbMessages.Clear(); });

                int ProgressBarUpdatePeriod = (int)(allEvents.Last().Time - allEvents.First().Time).TotalSeconds / 100;
                DateTime LastProgressbarUpdate = allEvents.First().Time;

                foreach (BaseEvent _event in allEvents)
                {
                    while (PauseThread)
                    {
                        System.Threading.Thread.Sleep(1);
                    }

                    if (lastTime != null)
                    {
                        try
                        {
                            Thread.Sleep((int)((_event.Time - lastTime.Value).TotalMilliseconds) / speed);
                        }
                        catch (Exception e)
                        {
                            Thread.Sleep(0);
                        }
                    }

                    //this.Invoke((Action)delegate { tbMessages.AppendText(string.Format("{0}\n\n", allEvents[time].ToString())); });
                    lastTime = _event.Time;

                    mainGate.PushEvent(_event);
                    if ((_event.Time - LastProgressbarUpdate).TotalSeconds > ProgressBarUpdatePeriod)
                    {
                        this.Invoke((Action)delegate { pbProgress.PerformStep(); });
                        LastProgressbarUpdate = _event.Time;
                    }
                    //this.Invoke((InvokeDelegate)((String s) => { tbMessages.AppendText(s + "\n"); }), allEvents[time].ToString());
                }
                this.Invoke((Action)delegate { pbProgress.Value = 0; });
                Status = StatusEnum.Stopped;
                this.Invoke((Action)delegate { UpdateControls(""); });

            }
            catch (Exception e)
            {
                e.ToString();
            }
        }
        public Graph()
        {
            InitializeComponent();
            bpIsCreated = false;
            Init();
            m_onLoad = new System.Threading.Timer(new TimerCallback(TimerOnload));
            m_onLoad.Change(500, 0);
            PaintGraphs = new SimpleGrp(pbGraph.Font);

            var o = new HeatChangeEvent();
            m_listenGate = new ConnectionProvider.Client(new Listener());
            m_listenGate.Subscribe();
        }
        public void Start()
        {
            if (m_Events == null)
            {
                m_Events = new EventsListener();
            }

            if (m_MainGate == null)
            {
                m_MainGate = new ConnectionProvider.Client(_channelName + m_UnitNumber.ToString(),m_Events);
                m_MainGate.Subscribe();
            }

            m_WorkingFlag = true;
            System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(ProccesAssync));
            thread.Start();
        }
 static void Main(string[] args)
 {
     var o = new HeatChangeEvent();
     var mainConf = System.Configuration.ConfigurationManager.OpenExeConfiguration("");
     m_listenGate = new ConnectionProvider.Client(new Listener());
     m_listenGate.Subscribe();
     m_pushGate = new ConnectionProvider.Client();
     Thread.Sleep(1000);
     // запрашиваем привязку бункеров к материалам
     m_pushGate.PushEvent(new OPCDirectReadEvent() { EventName = typeof(BoundNameMaterialsEvent).Name });
     // навески
     m_pushGate.PushEvent(new OPCDirectReadEvent() { EventName = typeof(visAdditionTotalEvent).Name });
     Thread.Sleep(1000);
     // текущий номер плавки
     m_pushGate.PushEvent(new OPCDirectReadEvent() { EventName = typeof(HeatChangeEvent).Name });
     Console.WriteLine("TransferModelBunkers is running, press enter to exit");
     Console.ReadLine();
     Console.WriteLine("Bye!");
 }
        static void Main(string[] args)
        {
            var mainConf = System.Configuration.ConfigurationManager.OpenExeConfiguration("");
            var conf = new System.ServiceModel.Configuration.ClientSection();

            //((System.ServiceModel.Configuration.ClientSection)mainConf.SectionGroups["system.serviceModel"].Sections["client"]).Endpoints[0]

            mainGate = new ConnectionProvider.Client();
            mainGate.Subscribe();
            Console.WriteLine("Press Enter");
            Console.ReadLine();
            mainGate.PushEvent(new HeatChangeEvent() { HeatNumber = 1001 });
            Console.WriteLine("Press Enter");
            Console.ReadLine();
            mainGate.PushEvent(new HeatChangeEvent() { HeatNumber = 100 });
            Console.WriteLine("Press Enter");
            Console.ReadLine();
            mainGate.PushEvent(new HeatChangeEvent() { HeatNumber = 101 });
            Console.WriteLine("Press Enter");
            Console.ReadLine();
            CultureInfo culture = CultureInfo.InvariantCulture;
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            // load spim-generated data from embedded resource file
            //const string spimDataName = ;
            for (int i = 0; i < 1000; i++)
            {
                Console.WriteLine("Press Enter");
                Console.ReadLine();
               // mainGate.PushEvent(new Esms.FingersStateEvent { FingersOpened = true, Time = DateTime.Now });
            }
                 //mainGate.PushEvent(new HeatChangeEvent() { HeatNumber = 1001, iCnvNr = DateTime.Now.Second % 2 + 1, Time = DateTime.Now });
                 //Console.ReadLine();
                 mainGate.PushEvent(new LanceEvent() { O2TotalVol = 20 });
                 Console.ReadLine();
                 for (int i = 0; i < 1000; i++)
                 {
                     Thread.Sleep(100);
                     mainGate.PushEvent(new LanceEvent() { O2TotalVol = i * 20 });

                 }
                 Console.ReadLine();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            coreClient = new ConnectionProvider.Client();

            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 2; j++)
                {

                }
            }
        }
 private void Record()
 {
     switch (Status)
     {
         case StatusEnum.Recorded:
             if (mainGate != null)
             {
                 mainGate.Unsubscribe();
                 Status = StatusEnum.Stopped;
                 UpdateControls("Запись приостановлена");
             }
             break;
         default:
             try
             {
                 Status = StatusEnum.Recorded;
                 var o = new HeatChangeEvent();
                 mainGate = new ConnectionProvider.Client(new EventsListener(this));
                 //mainGate = new ConnectionProvider.Client();
                 mainGate.Subscribe();
                 UpdateControls("Идёт запись");
             }
             catch
             {
                 Status = StatusEnum.Stopped;
                 UpdateControls("Не могу подключиться для записи.");
                 return;
             }
             break;
     }
 }
        private bool CreateGroups()
        {
            m_ClientGroups = Group.LoadGroupsFromXmlFile(m_ConfigPath).Where(p => IsInConfig(p.Destination) && m_AviableEvents.Contains(p.Type.Name)).ToList();
            InstantLogger.log(string.Format("OPC Groups count {0}", m_ClientGroups.Count), "OPC");

            foreach (Group group in m_ClientGroups)
            {
                if (!MainGates.ContainsKey(group.Destination))
                {
                    EventsListener eventListener = new EventsListener();
                    ConnectionProvider.Client mainGateClient = new ConnectionProvider.Client(group.Destination, eventListener);
                    MainGates.Add(group.Destination, mainGateClient);
                    EventsToWrite.Add(group.Destination, eventListener);
                    mainGateClient.Subscribe();

                }
                InstantLogger.log(string.Format("==== GroupName {0} GroupeType={1} GroupLocation={2}", group.Name, group.Type.ToString(), group.Location), "OPC");
                foreach (Point point in group.Points)
                {
                    InstantLogger.log(string.Format("FieldName={0} Location={1} Type={2} OPCLocation={3}", point.FieldName, point.Location, point.Type.ToString(), point.OPCLocation), "OPC");
                }

            }

            return true;
        }
 public Sendor(ConnectionProvider.Client mainGate)
 {
     this.mainGate = mainGate;
 }
        private static void Receiver(object state)
        {
            var o = new HeatChangeEvent();
            m_listenGate = new ConnectionProvider.Client(new Listener());
            m_listenGate.Subscribe();

            InstantLogger.log("receiver", "Started", InstantLogger.TypeMessage.important);
        }
 public WeigherReleaseSender()
 {
     m_pushGate = new ConnectionProvider.Client();
     InitializeComponent();
 }