Beispiel #1
0
        /// <summary>
        /// Called when a new instance of the RTD function is created.
        /// </summary>
        /// <param name="topicId"></param>
        /// <param name="Strings"></param>
        /// <param name="GetNewValues"></param>
        /// <returns></returns>-
        public object ConnectData(int topicId, ref Array Strings, ref bool GetNewValues)
        {
            try {
                var rtdString = (string)Strings.GetValue(0);
                if (rtdString == "" || rtdString.Trim().Length == 0)
                {
                    return("#Topic error - " + rtdString);
                }

                var details = new TopicDetails {
                    key        = client.BuildPositionLookupKey(rtdString, (string)Strings.GetValue(1)),
                    valueField = ((string)Strings.GetValue(1)),
                    topicID    = topicId
                };

                var jmsTopic = NmsClient.ExtractJmsTopic((string)Strings.GetValue(0));
                client.StartListeningTo(jmsTopic, details.key, details.valueField, details.topicID);

                // ensure we replace the value in the spreadsheet
                GetNewValues = true;

                return(client.LookupValue(details.key, details.valueField));
            } catch (Exception e) {
                log.Error("Unable to ConnectData", e);
                return("#ConnectData");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Called when loaded by Excel.  Connect to the NMS Broker.
        /// </summary>
        /// <param name="callbackObject"></param>
        /// <returns></returns>
        public int ServerStart(Excel.IRTDUpdateEvent callbackObject)
        {
            try
            {
                m_xlRTDUpdate = callbackObject;

                LoadConfiguration();
                log.Info("Starting AIM RTD server");
                if (brokerUrl == null)
                {
                    //brokerUrl = "tcp://localhost:61616";
                    brokerUrl = "tcp://amqpositions:61616";
                }

                client = new NmsClient(callbackObject,
                                       new[]
                {
                    "account", "securityId", "level1TagName", "normOpenPosition"
                }, brokerUrl);
                // The level2-4 tags do not add anything to uniqueness
                // , "level2TagName", "level3TagName", "level4TagName"
                //Thread m_WorkerThread = new Thread(client.NMSReaderLoop);
                //m_WorkerThread.Name = "NMSListener";
                //m_WorkerThread.Start();

                return(1);
            }
            catch (Exception e)
            {
                log.Error("Caught exception during server start", e);
            }
            return(-1);
        }
Beispiel #3
0
        /// <summary>
        /// Called when loaded by Excel.  Connect to the NMS Broker.
        /// </summary>
        /// <param name="CallbackObject"></param>
        /// <returns></returns>
        public int ServerStart(Excel.IRTDUpdateEvent CallbackObject)
        {
            m_xlRTDUpdate = CallbackObject;

            loadConfiguration();

            if (brokerUrl == null)
            {
                //brokerUrl = "tcp://localhost:61616";
                brokerUrl = "tcp://nysrv61:61616";
            }

            try
            {
                client = new NmsClient(CallbackObject,
                                       new String[]
                {
                    "account", "securityId", "level1TagName"
                }, brokerUrl);
                // The level2-4 tags do not add anything to uniqueness
                // , "level2TagName", "level3TagName", "level4TagName"
                Thread m_WorkerThread = new Thread(client.NMSReaderLoop);
                m_WorkerThread.Name = "NMSListener";
                m_WorkerThread.Start();

                return(1);
            }
            catch (Exception e)
            {
                //log.Error("Caught exception during serverstart", e);
            }
            return(-1);
        }
Beispiel #4
0
 public void ServerTerminate()
 {
     try {
         // Nothing to do here
         client.Shutdown();
         client = null;
         log.Info("Stopping AIM RTD server");
     } catch (Exception e) {
         log.Error("ServerTerminate:", e);
     }
 }
Beispiel #5
0
 public void ServerTerminate()
 {
     // Nothing to do here
     client.shutdown();
     client = null;
 }