Пример #1
0
        private void Button_PPMS_Serial_Connect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                myparts.myDialog dlg = new myparts.myDialog("シリアルポートに接続します");
                if (dlg.ShowDialog() != true)
                {
                    return;
                }

                this.serialport          = new System.IO.Ports.SerialPort("COM" + this.TextBox_PPMS_COMPORT.Text, int.Parse(this.TextBox_PPMS_BaudRate.Text), System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
                this.serialport.Encoding = Encoding.ASCII;

                byte[] endsign = { 170, 255 };
                this.serialport.NewLine = Encoding.ASCII.GetString(endsign, 0, 1);
                this.serialport.Open();

                this.fps = new FPSAdjuster.FPSAdjuster();
                fps.Fps  = int.Parse(this.TextBox_PPMS_FPS.Text);
                fps.Start();

                this.CTS      = new CancellationTokenSource();
                this.maintask = new Task(new Action(this.MainTask_PPMS), this.CTS.Token);
                this.maintask.Start();
            }
            catch (Exception ex)
            {
                myparts.myDialog dlg = new myparts.myDialog(ex.Message);
                dlg.ShowDialog();
            }
        }
Пример #2
0
        /// <summary>
        /// オーバーロードコンストラクタ
        /// 各種設定を追加
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="name"></param>
        public StreamWindow(MainWindow parent, StreamClient SC)
        {
            InitializeComponent();
            this.MouseLeftButtonDown += (sender, e) => this.DragMove();
            this.Closing             += StreamWindow_Closing;

            this.SC             = SC;
            this.TitleText.Text = this.SC.name;
            this.textblock_settingdata.Text
                = "MyPort : " + this.SC.myport.ToString() + "\n"
                  + "ServerIP : " + this.SC.serverIP + "\n"
                  + "ServerPort : " + this.SC.serverport.ToString() + "\n"
                  + "Mode : " + this.SC.mode.ToString() + "\n"
                  + "FPS : " + this.SC.fps.ToString() + "\n"
                  + "filepath : " + this.SC.filename + "\n";


            #region set button and file open.
            switch (this.SC.mode)
            {
            case MODE.Sender:
                this.Button_Start.IsEnabled    = true;
                this.Button_RecStart.IsEnabled = false;
                this.reader = new BinaryReader(File.OpenRead(this.SC.filename));
                this.progressbar_datastream.Maximum = this.reader.BaseStream.Length;
                break;

            case MODE.Receiver:
                this.Button_Start.IsEnabled    = false;
                this.Button_RecStart.IsEnabled = true;
                this.writer = new BinaryWriter(File.OpenWrite(this.SC.filename));
                break;

            default:
                break;
            }

            #endregion



            this.cipc = new CIPC_CS.CLIENT.CLIENT(this.SC.myport, this.SC.serverIP, this.SC.serverport, this.SC.name, this.SC.fps);
            this.CTS  = new System.Threading.CancellationTokenSource();

            this.Fps_cipc     = new FPSAdjuster.FPSAdjuster();
            this.Fps_cipc.Fps = this.SC.fps;

            this.task = new Task(() => maintask(), this.CTS.Token);
            this.task.Start();

            this.parent        = parent;
            this.IsRecStarted  = false;
            this.IsSendStarted = false;
            this.IsClosed      = false;
        }
Пример #3
0
 private void MainTask()
 {
     try
     {
         FPSAdjuster.FPSAdjuster fps = new FPSAdjuster.FPSAdjuster();
         fps.Fps = 30;
         fps.Start();
         int DT = DateTime.Now.Millisecond;
         while (!this.CTS.IsCancellationRequested)
         {
             fps.Adjust();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Пример #4
0
 private void MainTask()
 {
     try
     {
         FPSAdjuster.FPSAdjuster fps = new FPSAdjuster.FPSAdjuster();
         fps.Fps = 30;
         fps.Start();
         int DT = DateTime.Now.Millisecond;
         while (!this.CTS.IsCancellationRequested)
         {
             fps.Adjust();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Пример #5
0
        private void Button_SC_Serial_Connect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                myparts.myDialog dlg = new myparts.myDialog("シリアルポートに接続します");
                if (dlg.ShowDialog() != true)
                {
                    return;
                }

                this.serialport          = new System.IO.Ports.SerialPort("COM" + this.TextBox_SC_COMPORT.Text, int.Parse(this.TextBox_SC_BaudRate.Text), System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
                this.serialport.Encoding = Encoding.ASCII;
                this.serialport.Open();

                this.fps = new FPSAdjuster.FPSAdjuster();
                fps.Fps  = 30;
                fps.Start();
            }
            catch (Exception ex)
            {
                myparts.myDialog dlg = new myparts.myDialog(ex.Message);
                dlg.ShowDialog();
            }
        }
        /// <summary>
        /// オーバーロードコンストラクタ
        /// 各種設定を追加
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="name"></param>
        public StreamWindow(MainWindow parent, StreamClient SC)
        {
            try
            {
                InitializeComponent();
                this.MouseLeftButtonDown += (sender, e) => this.DragMove();
                this.Closing += StreamWindow_Closing;

                this.SC = SC;
                this.TitleText.Text = this.SC.name;
                this.textblock_settingdata.Text
                    = "MyPort : " + this.SC.myport.ToString() + "\n"
                    + "ServerIP : " + this.SC.serverIP + "\n"
                    + "ServerPort : " + this.SC.serverport.ToString() + "\n"
                    + "Mode : " + this.SC.mode.ToString() + "\n"
                    + "FPS : " + this.SC.fps.ToString() + "\n"
                    + "filepath : " + this.SC.filename;

                #region set button and file open.
                switch (this.SC.mode)
                {
                    case MODE.Sender:
                        this.Button_Start.IsEnabled = true;
                        this.Button_RecStart.IsEnabled = false;
                        this.reader = new BinaryReader(File.OpenRead(this.SC.filename));
                        this.progressbar_datastream.Maximum = this.reader.BaseStream.Length;
                        break;
                    case MODE.Receiver:
                        this.Button_Start.IsEnabled = false;
                        this.Button_RecStart.IsEnabled = true;
                        this.writer = new BinaryWriter(File.OpenWrite(this.SC.filename));
                        break;
                    default:
                        break;
                }

                #endregion

                this.cipc = new CIPC_CS.CLIENT.CLIENT(this.SC.myport, this.SC.serverIP, this.SC.serverport, this.SC.name, this.SC.fps);
                this.CTS = new System.Threading.CancellationTokenSource();

                this.Fps_cipc = new FPSAdjuster.FPSAdjuster();
                this.Fps_cipc.Fps = this.SC.fps;

                this.task = new Task(() => maintask(), this.CTS.Token);
                this.task.Start();

                this.parent = parent;
                this.IsRecStarted = false;
                this.IsSendStarted = false;
                this.IsClosed = false;

                this.textblock_settingdata.ToolTip = this.textblock_settingdata.Text;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }
        }
Пример #7
0
        private void Button_SC_Serial_Connect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                myparts.myDialog dlg = new myparts.myDialog("シリアルポートに接続します");
                if (dlg.ShowDialog() != true)
                {
                    return;
                }

                this.serialport = new System.IO.Ports.SerialPort("COM" + this.TextBox_SC_COMPORT.Text, int.Parse(this.TextBox_SC_BaudRate.Text), System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
                this.serialport.Encoding = Encoding.ASCII;
                this.serialport.Open();

                this.fps = new FPSAdjuster.FPSAdjuster();
                fps.Fps = 30;
                fps.Start();
            }
            catch (Exception ex)
            {
                myparts.myDialog dlg = new myparts.myDialog(ex.Message);
                dlg.ShowDialog();
            }
        }
Пример #8
0
        private void Button_PPMS_Serial_Connect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                myparts.myDialog dlg = new myparts.myDialog("シリアルポートに接続します");
                if (dlg.ShowDialog() != true)
                {
                    return;
                }

                this.serialport = new System.IO.Ports.SerialPort("COM" + this.TextBox_PPMS_COMPORT.Text, int.Parse(this.TextBox_PPMS_BaudRate.Text), System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
                this.serialport.Encoding = Encoding.ASCII;

                this.serialport.Open();

                this.fps = new FPSAdjuster.FPSAdjuster();
                fps.Fps = int.Parse( this.TextBox_PPMS_FPS.Text);
                fps.Start();

                this.CTS = new CancellationTokenSource();
                this.maintask = new Task(new Action(this.MainTask_PPMS), this.CTS.Token);
                this.maintask.Start();
            }
            catch (Exception ex)
            {
                myparts.myDialog dlg = new myparts.myDialog(ex.Message);
                dlg.ShowDialog();
            }
        }