Ejemplo n.º 1
0
 public MeasureUpdater(DisplayControl displayControl, RTPMEConnector rtPMEConnector, PMEServiceClient rTPMEclient)
 {
     this.rTPMEclient = rTPMEclient;
     this.rtPMEConnector = rtPMEConnector;
     this.displayControl = displayControl;
     mTimer.Elapsed += TimerEvent;
 }
Ejemplo n.º 2
0
        public bool ConnectToServer(DisplayControl displayControl)
        {
            foreach (string measureInstID in rtPMEMeasureFileIDs)
            {
                try
                {
                    StringBuilder measureInstXmlString = measureInstXmlStringMap[measureInstID];
                    XmlWriter measureInstXml = measureInstXmlMap[measureInstID];

                    // Complete Measurement Instances Data
                    measureInstXml.WriteEndElement();
                    measureInstXml.WriteEndElement();
                    measureInstXml.WriteEndDocument();
                    measureInstXml.Close();

                    string test = measureInstXmlString.ToString();

                    // Output list of undefined measures to debug stream
                    OutputUndefinedMeasureList(test);
                }
                catch (Exception)
                {
                }
            }

            // Write the string to a file.
            /*
            {
                System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\AptimaProjects\\Cove\\out.xml");
                foreach (string xmlFileID in rtPMEMeasureFileIDs)
                {
                    StringBuilder measureInstXmlString = measureInstXmlStringMap[xmlFileID];
                    file.WriteLine(measureInstXmlString);
                    file.WriteLine("");
                }
                file.Close();
            }
            */

            // Start the RT PME Service
            StartServices();

            while (!rtPMERunning)
            {
                Thread.Sleep(2000);
            }

            rtpmeClient = new PMEServiceClient("net.tcp_IRTPMEService");

            rtpmeClient.InitializeSession();
            //client.InitializeRTI();

            // Load measurement definitions
            foreach (string resourceName in rtPMEMeasureFileNames)
            {
                try
                {
                    Uri uri = new Uri(resourceName, UriKind.Relative);
                    StreamResourceInfo info = Application.GetResourceStream(uri);
                    StreamReader reader = new StreamReader(info.Stream);
                    string measureStr = reader.ReadToEnd();
                    rtpmeClient.LoadMeasurementFile(measureStr);
                }
                catch (Exception)
                {
                }
            }

            // Load measurement instances
            foreach (string measureInstID in rtPMEMeasureFileIDs)
            {
                try
                {
                    StringBuilder measureInstXmlString = measureInstXmlStringMap[measureInstID];

                    rtpmeClient.LoadMeasureInstance(measureInstXmlString.ToString());

                }
                catch (Exception)
                {
                }
            }

            measureUpdater = new MeasureUpdater(displayControl, this, rtpmeClient);

            // Start Updating thread
            ThreadStart threadStart = new ThreadStart(measureUpdater.Update);
            workerThread = new Thread(threadStart);
            workerThread.Start();

            return true;
        }