예제 #1
0
파일: K4RtdServer.cs 프로젝트: plusxp/kx-1
        public void DisconnectData(int topic)
        {
            Trace.WriteLineIf(traceSwitch.TraceInfo, "Disconnecting topic: " + topic);

            lock (this)
            {
                foreach (DictionaryEntry de in cache)
                {
                    RTDData data = (RTDData)de.Value;

                    if (data.containsTopic(topic))
                    {
                        data.removeTopic(topic);
                    }

                    if (data.getTopics().Length == 0)
                    {
                        cache.Remove(de.Key);
                    }
                }
            }

            timer.Stop();
            timer.Start();
        }
예제 #2
0
파일: K4RtdServer.cs 프로젝트: plusxp/kx-1
        public Array RefreshData(ref int TopicCount)
        {
            Trace.WriteLineIf(traceSwitch.TraceInfo, "RefreshData");

            lock (this)
            {
                int numItems = 0;

                foreach (DictionaryEntry de in cache)
                {
                    RTDData item = (RTDData)de.Value;

                    if (item.Updated)
                    {
                        numItems += item.getTopics().Length;
                    }
                }

                object[,] ret = new object[2, numItems];

                int i = 0;

                try
                {
                    foreach (DictionaryEntry de in cache)
                    {
                        RTDData item = (RTDData)de.Value;

                        if (item.Updated)
                        {
                            int [] topics = item.getTopics();

                            for (int j = 0; j < topics.Length; j++)
                            {
                                ret[0, i] = topics[j];
                                ret[1, i] = item.getVal(topics[j]);
                                i++;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.ToString());
                }

                TopicCount = i;

                Trace.Flush();

                return(ret);
            }
        }