예제 #1
0
파일: MainForm.cs 프로젝트: sec-d04/RTMWeb
        /// <summary>
        /// コンポーネントからデータを受信する処理
        /// </summary>
        private void ReceiveData(TimedLong data)
        {
            // コンポーネントとFormで実行スレッドが異なるので、UI Threadから実行させる
            if (InvokeRequired)
            {
                Invoke(new Action<TimedLong>(ReceiveData), new object[] { data });
                return;
            }

               // textBoxReceive.Text = data.Data.ToString();
        }
예제 #2
0
파일: MainForm.cs 프로젝트: sec-d04/RTMWeb
        /// <summary>
        /// 送信ボタンが押されたときの処理
        /// </summary>
        private void buttonSend_Click(object sender, EventArgs e)
        {
            // int input = int.Parse(textBoxSend.Text);

            var data = new TimedLong();
            data.Time.SetDateTime(DateTime.Now);
              //  data.Data = input;
            data.Data = 1;

            // コンポーネントからデータを出力
            component.SendData(data);
        }
예제 #3
0
        public void シリアライズのテスト()
        {
            var factory = new CdrSerializerFactory();

            var serializer = factory.GetSerializer<TimedLong>(true);

            TimedLong data = new TimedLong(new Time(0x12, 0x34), 0x5678);

            var stream = new MemoryStream();
            serializer.Serialize(data, stream);

            stream.Length.Is(12);
            stream.ToArray().Is(new List<byte> {
                0x12, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x78, 0x56, 0x00, 0x00 });
        }
예제 #4
0
        public void データを書き込んでみる()
        {
            var recorder = new Recorder("127.0.0.1:2809/SampleOut0.rtc", "SampleOut0.out");

            recorder.IsAlive.Is(true);

            recorder.Play();

            recorder.IsAlive.Is(true);

            var comp = NamingServiceManager.Default.GetComponent("127.0.0.1:2809/SampleOut0.rtc");
            var port = comp.GetPort("SampleOut0.out") as OutPortServiceMock;

            port.IsNotNull();

            var inportcdr = port.GetInPortCdr();

            inportcdr.IsNotNull();

            var factory    = new CdrSerializerFactory();
            var serializer = factory.GetSerializer <TimedLong>();

            for (int i = 0; i < 100; i++)
            {
                var stream = new MemoryStream();
                var data   = new TimedLong(new Time(0x12, 0x34), i);
                serializer.Serialize(data, stream);

                inportcdr.put(stream.ToArray());
            }

            recorder.IsAlive.Is(true);

            recorder.Stop();

            recorder.IsAlive.Is(true);

            recorder.RecordDescription.Count.Is(100);
            recorder.RecordDescription.SumSize.Is(1200);

            Directory.EnumerateFiles(TestDataDirectory).Count().Is(2);
        }
예제 #5
0
        private void ListenerThread()
        {
            while (true)
            {
                HttpListenerContext context = listener.GetContext();
                HttpListenerRequest req = context.Request;
                HttpListenerResponse res = context.Response;

                logger.DebugFormat("HttpMethod {0}", req.HttpMethod);
                logger.DebugFormat(req.RawUrl);

                // リクエストされたURLからファイルのパスを求める
                string path = root + req.RawUrl.Replace("/", "\\");

                // ファイルが存在すればレスポンス・ストリームに書き出す
                if (File.Exists(path))
                {
                    byte[] content = File.ReadAllBytes(path);
                    res.OutputStream.Write(content, 0, content.Length);
                }
                if (req.HttpMethod == "POST")
                {
                    if (req.HasEntityBody)
                    {
                        System.IO.Stream body = req.InputStream;
                        System.Text.Encoding encoding = req.ContentEncoding;
                        System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
                        if (req.ContentType != null)
                        {
                            logger.DebugFormat("Client data content type {0}", req.ContentType);
                        }
                        logger.DebugFormat("Client data content length {0}", req.ContentLength64);

                        logger.DebugFormat("Start of client data:");

                        string s = reader.ReadToEnd();

                        logger.DebugFormat(s);
                        logger.DebugFormat("End of client data:");
                        body.Close();
                        reader.Close();

                        logger.DebugFormat("s={0}", s);

                        //スクロール指定
                        if (s.IndexOf("scroll=") > 0)
                        {
                            s = s.Replace("scroll=", "");
                            logger.DebugFormat("Replaceed s={0}", s);

                            var data = new TimedLong();
                            data.Time.SetDateTime(DateTime.Now);
                            //  data.Data = input;
                            data.Data = int.Parse(s);

                            // コンポーネントからデータを出力
                            component.SendData(data);
                        }
                        else if (s.IndexOf("locate=") > 0)
                        {
                            s = s.Replace("locate=", "");
                            logger.DebugFormat("Replaceed s={0}", s);

                            var data = new TimedLong();
                            data.Time.SetDateTime(DateTime.Now);
                            //  data.Data = input;
                            data.Data = int.Parse(s);
                            MessageBox.Show(null,"s = {0}",s);

                            // コンポーネントからデータを出力
                           // component.SendData(data);
                        }
                    }
                }
                res.Close();
            }
        }
예제 #6
0
 ///<exclude/>
 public bool Equals(TimedLong other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other._Tm.Equals(_Tm) && other._Data.Equals(_Data);
 }
예제 #7
0
        public void データを書き込んでみる()
        {
            var recorder = new Recorder("127.0.0.1:2809/SampleOut0.rtc", "SampleOut0.out");

            recorder.IsAlive.Is(true);

            recorder.Play();

            recorder.IsAlive.Is(true);

            var comp = NamingServiceManager.Default.GetComponent("127.0.0.1:2809/SampleOut0.rtc");
            var port = comp.GetPort("SampleOut0.out") as OutPortServiceMock;

            port.IsNotNull();

            var inportcdr = port.GetInPortCdr();

            inportcdr.IsNotNull();

            var factory = new CdrSerializerFactory();
            var serializer = factory.GetSerializer<TimedLong>();

            for (int i = 0; i < 100; i++)
            {
                var stream = new MemoryStream();
                var data = new TimedLong(new Time(0x12, 0x34), i);
                serializer.Serialize(data, stream);

                inportcdr.put(stream.ToArray());
            }

            recorder.IsAlive.Is(true);

            recorder.Stop();

            recorder.IsAlive.Is(true);

            recorder.RecordDescription.Count.Is(100);
            recorder.RecordDescription.SumSize.Is(1200);

            Directory.EnumerateFiles(TestDataDirectory).Count().Is(2);
        }
예제 #8
0
파일: WebToRTM.cs 프로젝트: sec-d04/RTMWeb
 //        protected override ReturnCode_t OnRateChanged(int exec_handle)
 //        {
 //            return ReturnCode_t.RTC_OK;
 //        }
 //        protected override ReturnCode_t OnReset(int exec_handle)
 //        {
 //            return ReturnCode_t.RTC_OK;
 //        }
 //        protected override ReturnCode_t OnShutdown(int exec_handle)
 //        {
 //            return ReturnCode_t.RTC_OK;
 //        }
 //        protected override ReturnCode_t OnStartup(int exec_handle)
 //        {
 //            return ReturnCode_t.RTC_OK;
 //        }
 //        protected override ReturnCode_t OnStateUpdate(int exec_handle)
 //        {
 //            return ReturnCode_t.RTC_OK;
 //        }
 /// <summary>
 /// outportからデータを出力する
 /// </summary>
 public void SendData(TimedLong data)
 {
     outport.Write(data);
 }