Ejemplo n.º 1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="localPort">自分のポート</param>
        public RemoteHost(int localPort, DebugWindow debugwindow, TerminalConnection.TerminalConnection TC)
        {
            try
            {
                this.UP_Cliant  = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(localPort);
                this.UP_Encoder = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.UP_Decoder = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
                this.id         = localPort;

                this.CTS    = new CancellationTokenSource();
                this.mytask = new Task(() => this.Main_Task(), CTS.Token);

                this.mytask.Start();
                this.fpsa = new FPSAdjuster.FPSAdjuster();

                this.debugwindow          = debugwindow;
                this.debugwindow.DebugLog = "[Port:" + localPort.ToString() + "]受信を開始します";

                this.TC = TC;
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void connect(ref int port)
        {
            try
            {
                for (int current_port = Definitions.PORT_START_NUMBER; current_port < Definitions.PORT_START_NUMBER + max_connect_num; current_port++)
                {
                    if (!this.LstPort.Contains(current_port))
                    {
                        port = current_port;
                        this.LstPort.Add(current_port);

                        this.enc  = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                        this.enc += Definitions.CONNECTION_OK;
                        this.enc += current_port;
                        this.client.Send(this.enc.data);

                        this.debugwindow.DebugLog = "[RemoteHostServer]接続要求がきました.解放ポートを通知します.ポート番号:" + port.ToString();
                        break;
                    }
                }
            }catch (Exception ex)
            {
                debugwindow.DebugLog = ex.Message + "コネクトの段階でエラーが発生しました。";
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 接続を切断します。
        /// </summary>
        public void disconnect()
        {
            try
            {
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]切断します.";
                UP_Cliant.Close();
                this.data = null;
                if (this.connect_host != null)
                {
                    this.connect_host.connect_host = null;
                    this.connect_host = null;
                }

                CTS.Cancel();
                isConnected     = false;
                this.UP_Encoder = null;
                this.UP_Decoder = null;

                this.UP_Cliant = null;

                this.DataReceived = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "接続の切断に失敗しました。");
            }
            finally
            {
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="localPort">自分のポート</param>
        public RemoteHost(int localPort, DebugWindow debugwindow/*, TerminalConnection.TerminalConnection TC*/)
        {
            try
            {
                this.UP_Cliant = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(localPort);
                this.UP_Encoder = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.UP_Decoder = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
                this.id = localPort;

                this.CTS = new CancellationTokenSource();
                this.mytask = new Task(() => this.Main_Task(), CTS.Token);

                this.mytask.Start();
                this.fpsa = new FPSAdjuster.FPSAdjuster();

                this.debugwindow = debugwindow;
                this.debugwindow.DebugLog = "[Port:" + localPort.ToString() + "]受信を開始します";

                //this.TC = TC;
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        public void Send(byte[] data)
        {
            if (this.Datalength != data.LongLength) return;

            byte[] buffer = new byte[this.DPP];

            byte[] senddata;

            for (int i = 0; i < data.LongLength / this.DPP; i++)
            {
                try
                {
                    if (i < data.LongLength / this.DPP - 1)
                    {
                        Array.Copy(data, i * this.DPP, buffer, 0, this.DPP);
                    }
                    else
                    {
                        if (this.Datalength % this.DPP == 0) return;
                        Array.Copy(data, i * this.DPP, buffer, 0, this.Datalength % this.DPP);
                    }
                    UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                    enc += i;
                    enc += buffer;
                    senddata = enc.data;
                    this.client.Update(ref senddata);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + this.DPP);
                }
            }
        }
        //座標算出
        void SendLEDPtData(ref UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc)
        {
            CameraSpacePoint LEDPt = this.calib.GetLEDPositinon(this.imageWidth,
                                                                this.imageHeigt,
                                                                this.colors,
                                                                new OpenCvSharp.CPlusPlus.Scalar(30, 93, 93),
                                                                this.depthBuffer);

            this.calib.MakeSaveData(this.calibMode, LEDPt);
            enc += LEDPt.X;
            enc += LEDPt.Y;
            enc += LEDPt.Z;
            Console.WriteLine("X:" + LEDPt.X.ToString());
            Console.WriteLine("Y:" + LEDPt.Y.ToString());
            Console.WriteLine("Z:" + LEDPt.Z.ToString());

            //キャリブレーション画像表示
            OpenCvSharp.CPlusPlus.Mat calibMat = calib.GetCalibrationImage().Clone();
            this.calibrationImage.Source          = OpenCvSharp.Extensions.WriteableBitmapConverter.ToWriteableBitmap(calibMat);
            this.CalibrationImageTable.IsSelected = true;

            //送信データ表示
            this.message.Content = "LEDPosition  " + "X:" + LEDPt.X.ToString() + " Y:" + LEDPt.Y.ToString() + " Z:" + LEDPt.Z.ToString();

            //データ送信モード変更
            this.SendData_LEDPt.IsChecked = false;
            this.SendData_Body.IsChecked  = true;
        }
        //データ送信
        void SendData()
        {
            //CIPCに送信
            #region
            try
            {
                UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();

                if (this.SendData_Body.IsChecked == true)
                {
                    this.SendBodyData(ref enc, this.bodies, this.NumberofPlayer);
                }
                else if (this.SendData_LEDPt.IsChecked == true)
                {
                    this.SendLEDPtData(ref enc);
                }

                if (this.cipcMain != null && enc.data != null)
                {
                    this.cipcMain.send(enc.data);
                    //Console.WriteLine("sendDat");
                }
                if (this.UDPclientWidow != null && enc.data != null)
                {
                    this.UDPclientWidow.Send(enc.data);
                    //Console.WriteLine("sendDat");
                }
            }
            catch
            {
                this.ErrorPoint(System.Reflection.MethodBase.GetCurrentMethod().Name.ToString());
            }
            #endregion
        }
Ejemplo n.º 8
0
 public NoticePort(int Port)
 {
     this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
     //OK
     this.enc += (int)0;
     this.enc += (int)Port;
     this.SendData = this.enc.data;
 }
Ejemplo n.º 9
0
 public NoticePort(int Port)
 {
     this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
     //OK
     this.enc     += (int)0;
     this.enc     += (int)Port;
     this.SendData = this.enc.data;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// リモートホストと接続します。
        /// </summary>
        /// <returns>接続先のIPエンドポイント</returns>
        private IPEndPoint Connect()
        {
            try
            {
                while (true)
                {
                    if (this.UP_Cliant.Received_Data != null)
                    {
                        this.UP_Decoder.Source = this.UP_Cliant.Received_Data;
                        break;
                    }
                }
                if (this.UP_Decoder.get_int() == Definitions.CONNECTION_DEMANDS)
                {
                    this.FPS      = this.UP_Decoder.get_int();
                    this.fpsa.Fps = this.FPS;
                    this.fpsa.Start();

                    switch (this.UP_Decoder.get_int())
                    {
                    case Definitions.CONNECTION_MODE_SEND:
                        this.cstate = ConnectionState.Sender;
                        this.UP_Cliant.DataReceived += UP_Cliant_DataReceived;
                        break;

                    case Definitions.CONNECTION_MODE_RECEIVE:
                        this.cstate = ConnectionState.Receiver;
                        break;

                    default:
                        throw new Exception("CONNECTION_MODE が無効です。senderの設定を確かめてください。");
                    }
                    name = this.UP_Decoder.get_string();

                    Thread.Sleep(100);

                    this.UP_Encoder  = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                    this.UP_Encoder += Definitions.CONNECTION_OK;
                    this.UP_Cliant.Send(this.UP_Encoder.data);

                    this.isConnected = true;
                }
                else
                {
                    throw new Exception("コネクションの際に例外が発生しました。");
                }
                return(UP_Cliant.RemoteEP);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.UP_Cliant.DataReset();
            }
            return(UP_Cliant.RemoteEP);
        }
Ejemplo n.º 11
0
        public RemoteHostServer()
        {
            try
            {
                client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort);
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }

            try
            {
                this.enc     = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.dec     = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
                this.LstPort = new List <int>();

                mytask = new Task(() => this.MAIN_TASK());
                mytask.Start();
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
            try
            {
                #region create remotehost servers list and one remotehost server
                this.List_remotehost = new List <RemoteHost>();
                #endregion
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Ejemplo n.º 12
0
 public DirectConnect_NoticePort(CIPCServer.ClientStatus clientstatus)
 {
     this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
     //OK
     this.enc     += (int)0;
     this.enc     += clientstatus.ReceiverIP;
     this.enc     += clientstatus.ReceiverPort;
     this.enc     += clientstatus.Name;
     this.SendData = this.enc.data;
 }
Ejemplo n.º 13
0
        public static void DisconnectByUserPort(int SenderUserPort, int ReceiverUserPort, string RemoteIP, int RemotePort, int myPort)
        {
            UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort);
            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc    = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            enc += (int)14;
            enc += SenderUserPort;
            enc += ReceiverUserPort;

            client.Send(enc.data);
            client.Close();
        }
Ejemplo n.º 14
0
        public static void Connect(int SenderID, int ReceiverID, string RemoteIP, int RemotePort, int myPort)
        {
            UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort);
            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc    = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            enc += (int)5;
            enc += SenderID;
            enc += ReceiverID;

            client.Send(enc.data);
            client.Close();
        }
Ejemplo n.º 15
0
        public static void Disconnect(int SenderID, int ReceiverID, string RemoteIP, int RemotePort, int myPort)
        {
            UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort);
            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            enc += (int)6;
            enc += SenderID;
            enc += ReceiverID;

            client.Send(enc.data);
            client.Close();
        }
Ejemplo n.º 16
0
        public static void ConnectByUserPort(int SenderUserPort, int ReceiverUserPort, string RemoteIP, int RemotePort, int myPort)
        {
            UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort);
            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            enc += (int)13;
            enc += SenderUserPort;
            enc += ReceiverUserPort;

            client.Send(enc.data);
            client.Close();
        }
Ejemplo n.º 17
0
        void Send(int localport, int newclientport)
        {
            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            enc += true;
            enc += localport;
            enc += newclientport;
            byte[] data = enc.data;

            if (this.server != null)
            {
                this.server.BeginSend(data, data.Length, this.clientIP, this.clientPort, this.sendCallBack, this.server);
            }
        }
Ejemplo n.º 18
0
 public void Access()
 {
     try
     {
         UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
         enc += true;
         byte[] data = enc.data;
         this.client.BeginSend(data, data.Length, this.serverIP, this.serverPort, this.AccesSsendCallBack, this.client);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Ejemplo n.º 19
0
        private void disconnect(int port)
        {
            try
            {
                this.debugwindow.DebugLog = "[RemoteHostServer]切断要求がきました.ポート番号:" + port.ToString();
                destroyport = port;
                this.LstPort.Remove(port);
                this.List_remotehost.RemoveAll(check_remotehosts);

                this.enc  = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.enc += Definitions.CONNECTION_END;
                this.client.Send(this.enc.data);
            }
            catch (Exception ex)
            {
                debugwindow.DebugLog = ex.Message + "接続を終了する段階でエラーが発生しました。";
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        public void Send(byte[] data)
        {
            if (this.Datalength != data.LongLength)
            {
                return;
            }

            byte[] buffer = new byte[this.DPP];

            byte[] senddata;

            for (int i = 0; i < data.LongLength / this.DPP; i++)
            {
                try
                {
                    if (i < data.LongLength / this.DPP - 1)
                    {
                        Array.Copy(data, i * this.DPP, buffer, 0, this.DPP);
                    }
                    else
                    {
                        if (this.Datalength % this.DPP == 0)
                        {
                            return;
                        }
                        Array.Copy(data, i * this.DPP, buffer, 0, this.Datalength % this.DPP);
                    }
                    UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                    enc     += i;
                    enc     += buffer;
                    senddata = enc.data;
                    this.client.Update(ref senddata);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + this.DPP);
                }
            }
        }
Ejemplo n.º 21
0
        private void SendSKST_DivData(byte[][] DivinedData)
        {
            if (DivinedData == null)
            {
                return;
            }
            if (DivinedData.Length == 0)
            {
                return;
            }

            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            string str = "DivStart";
            enc += str;
            enc += DivinedData.Length;//分割数
            enc += DivinedData[0].Length;//一パケットあたりの長さ
            enc += DivinedData[DivinedData.Length - 1].Length;//あまり
            byte[] data = enc.data;
            this.SKST.networkstream.Write(data, 0, data.Length);

            Thread.Sleep(200);
            for (int i = 0; i < DivinedData.Length; i++)
            {
                UDP_PACKETS_CODER.UDP_PACKETS_ENCODER _enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                string _str = "DivData";
                _enc += _str;
                _enc += i;
                _enc += DivinedData[i];
                byte[] _data = _enc.data;
                this.SKST.networkstream.Write(_data, 0, _data.Length);
                Thread.Sleep(200);
            }

            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER __enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            string __str = "DivFinish";
            __enc += __str;
            byte[] __data = __enc.data;
            this.SKST.networkstream.Write(__data, 0, __data.Length);
        }
Ejemplo n.º 22
0
        private void SendSKST_3Dmodel_Pos()
        {
            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            string str = "3DModel1";
            enc += str;
            enc += (int)this.mesh_3dmodel.Positions.Count / this.databit_3Dmodel;

            Console.WriteLine("clear");
            for (int i = 0; i < this.mesh_3dmodel.Positions.Count / this.databit_3Dmodel; i++)
            {
                float x = (float)this.mesh_3dmodel.Positions[i].X;
                float y = (float)this.mesh_3dmodel.Positions[i].Y;
                float z = (float)this.mesh_3dmodel.Positions[i].Z;

                float _x = x;
                float _y = (float)(Math.Cos(-(float)this.CS.rx) * y - Math.Sin(-(float)this.CS.rx) * z);
                float _z = (float)(Math.Sin(-(float)this.CS.rx) * y + Math.Cos(-(float)this.CS.rx) * z);

                x = (float)(Math.Cos((float)this.CS.rz) * _x - Math.Sin((float)this.CS.rz) * _y);
                y = (float)(Math.Sin((float)this.CS.rz) * _x + Math.Cos((float)this.CS.rz) * _y);
                z = _z;

                _x = (float)(Math.Cos((float)this.CS.ry) * x - Math.Sin((float)this.CS.ry) * z);
                _y = y;
                _z = (float)(Math.Sin((float)this.CS.ry) * x + Math.Cos((float)this.CS.ry) * z);

                enc += _x + this.CS.dx;
                enc += _y + this.CS.dy;
                enc += _z + this.CS.dz;
            }
            Console.WriteLine(this.mesh_3dmodel.Positions.Count / this.databit_3Dmodel);
            Console.WriteLine(enc.data.Length);
            byte[] data = enc.data;
            this.SKST.networkstream.Write(data, 0, data.Length);
        }
Ejemplo n.º 23
0
        public void sendToAllEP(string str)
        {
            try
            {
                this.Client.IsRecast = true;
                var tmp = this.Client.RemoteEP;
                foreach (var p in this.m_SetIPEndPoint)
                {
                    this.Client.RemoteEP = p;
                    UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                    enc += str;
                    this.Client.Send(enc.data);
                }
                this.Client.RemoteEP = tmp;

            }
            catch (Exception ex)
            {
                this.debugwindow.DebugLog = "[" + this + "]" + ex.Message;
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// SKSTに送信するデータを作成します。
        /// </summary>
        private void DataCreate_SKST()
        {
            try
            {
                if (this.kinectsensor == null)
                    return;
                if (!this.kinectsensor.IsRunning)
                    return;
                this.TrackingLevel = 0;
                this.enc_shadow = null;
                this.enc_shadow = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.enc_shadow += 2;
                this.enc_shadow += this.FrameSkeletons.Length;
                if (true)//bodydirectionを入れると幸せになる場所
                {
                    for (int i = 0; i < FrameSkeletons.Length; i++)
                    {
                        this.enc_shadow += i;
                        this.make_send_joint(i, JointType.HipCenter);
                        this.make_send_joint(i, JointType.Spine);
                        this.make_send_joint(i, JointType.ShoulderCenter);
                        this.make_send_joint(i, JointType.Head);
                        this.make_send_joint(i, JointType.ShoulderLeft);
                        this.make_send_joint(i, JointType.ElbowLeft);
                        this.make_send_joint(i, JointType.WristLeft);
                        this.make_send_joint(i, JointType.HandLeft);
                        this.make_send_joint(i, JointType.ShoulderRight);
                        this.make_send_joint(i, JointType.ElbowRight);
                        this.make_send_joint(i, JointType.WristRight);
                        this.make_send_joint(i, JointType.HandRight);
                        this.make_send_joint(i, JointType.HipLeft);
                        this.make_send_joint(i, JointType.KneeLeft);
                        this.make_send_joint(i, JointType.AnkleLeft);
                        this.make_send_joint(i, JointType.FootLeft);
                        this.make_send_joint(i, JointType.HipRight);
                        this.make_send_joint(i, JointType.KneeRight);
                        this.make_send_joint(i, JointType.AnkleRight);
                        this.make_send_joint(i, JointType.FootRight);
                    }
                }
                else
                {
                    for (int i = 0; i < FrameSkeletons.Length; i++)
                    {
                        this.enc_shadow += i;
                        this.make_send_joint(i, JointType.HipCenter);
                        this.make_send_joint(i, JointType.Spine);
                        this.make_send_joint(i, JointType.ShoulderCenter);
                        this.make_send_joint(i, JointType.Head);

                        this.make_send_joint(i, JointType.ShoulderRight);
                        this.make_send_joint(i, JointType.ElbowRight);
                        this.make_send_joint(i, JointType.WristRight);
                        this.make_send_joint(i, JointType.HandRight);

                        this.make_send_joint(i, JointType.ShoulderLeft);
                        this.make_send_joint(i, JointType.ElbowLeft);
                        this.make_send_joint(i, JointType.WristLeft);
                        this.make_send_joint(i, JointType.HandLeft);

                        this.make_send_joint(i, JointType.HipRight);
                        this.make_send_joint(i, JointType.KneeRight);
                        this.make_send_joint(i, JointType.AnkleRight);
                        this.make_send_joint(i, JointType.FootRight);

                        this.make_send_joint(i, JointType.HipLeft);
                        this.make_send_joint(i, JointType.KneeLeft);
                        this.make_send_joint(i, JointType.AnkleLeft);
                        this.make_send_joint(i, JointType.FootLeft);

                    }
                }
                this.enc_shadow += (float)kinectsensor.AccelerometerGetCurrentReading().X;
                this.enc_shadow += (float)kinectsensor.AccelerometerGetCurrentReading().Y;
                this.enc_shadow += (float)kinectsensor.AccelerometerGetCurrentReading().Z;
                this.enc_shadow += (int)this.TrackingLevel;
                this.data_shadow = this.enc_shadow.data;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 接続を切断します。
        /// </summary>
        public void disconnect()
        {
            try
            {
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]切断します.";
                UP_Cliant.Close();
                this.data = null;
                if (this.connect_host != null)
                {
                    this.connect_host.connect_host = null;
                    this.connect_host = null;
                }

                CTS.Cancel();
                isConnected = false;
                this.UP_Encoder = null;
                this.UP_Decoder = null;

                this.UP_Cliant = null;

                this.DataReceived = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "接続の切断に失敗しました。");
            }
            finally
            {
            }
        }
Ejemplo n.º 26
0
        public RemoteHostServer()
        {
            try
            {
                this.Eventer = new TerminalConnectionSettings.CommandEventer();
                client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort);
                this.remoteOperator = new RemoteOperater(client);
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }

            try
            {
                this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
                this.LstPort = new List<int>();

            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
            try
            {
                #region create remotehost servers list and one remotehost server
                this.List_remotehost = new List<RemoteHost>();
                #endregion
                client.DataReceived += client_DataReceived;
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Ejemplo n.º 27
0
 private void SendSKST_3Dmodel_Indecsis()
 {
     UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
     string str = "3DModel2";
     enc += str;
     enc += (int)this.mesh_3dmodel.TriangleIndices.Count;
     Console.WriteLine("clear");
     for (int i = 0; i < this.mesh_3dmodel.TriangleIndices.Count; i++)
     {
         enc += (int)this.mesh_3dmodel.TriangleIndices[i];
     }
     Console.WriteLine(this.mesh_3dmodel.TriangleIndices.Count.ToString());
     byte[] data = enc.data;
     this.SKST.networkstream.Write(data, 0, data.Length);
 }
Ejemplo n.º 28
0
 public CloseResponse()
 {
     this.enc  = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
     this.enc += (int)9;
     this.data = this.enc.data;
 }
Ejemplo n.º 29
0
        public void Access()
        {
            try
            {
                UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                enc += true;
                byte[] data = enc.data;
                this.client.BeginSend(data, data.Length, this.serverIP, this.serverPort, this.AccesSsendCallBack, this.client);

            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// opti data send
        /// TODO:人数直す
        /// </summary>
        private void CIPC_SEND_OPTI()
        {
            try
            {


                if (m_FrameQueue.Count != 0)
                {
                    m_FrameOfData = m_FrameQueue.Dequeue();
                    m_FrameQueue.Clear();

                    Vector3D[] buffer = new Vector3D[20];

                    this.enc_shadow = null;
                    this.enc_shadow = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                    this.enc_shadow += 3;
                    this.enc_shadow += 1;

                    foreach (NatNetML.SkeletonData sk in m_FrameOfData.Skeletons)
                    {


                        foreach (NatNetML.RigidBodyData rbd in sk.RigidBodies)
                        {
                            int uniqueId = 1000 * HighWord(rbd.ID) + LowWord(rbd.ID);

                            RigidBodyWithKinectID rigidBodyWithKinectID;

                            if (m_rigidBodyDefinitions.TryGetValue(uniqueId, out rigidBodyWithKinectID))
                            {

                                int kinectId = rigidBodyWithKinectID.KinectID;



                                if (kinectId == 6 || kinectId == 10)
                                {
                                    //rotate offset

                                    float offsetX = rigidBodyWithKinectID.RigidBody.offsetx;
                                    float offsetY = rigidBodyWithKinectID.RigidBody.offsety;
                                    float offsetZ = rigidBodyWithKinectID.RigidBody.offsetz;
                                    Vector3D newVector = RotateFunctions.Rotate(offsetX, offsetY, offsetZ, rbd.qx, rbd.qy, rbd.qz, rbd.qw);


                                    //送信
                                    Vector3D pos = new Vector3D
                                    {
                                        x = rbd.x + newVector.x / 2.0f,
                                        y = rbd.y + newVector.y / 2.0f,
                                        z = rbd.z + newVector.z / 2.0f
                                    };

                                    buffer[kinectId + 1] = pos;
                                }


                                if (kinectId == 3)
                                {
                                    Vector3D pos = new Vector3D
                                    {
                                        x = rbd.x,
                                        y = rbd.y,
                                        z = rbd.z
                                    };

                                    buffer[kinectId - 1] = pos;

                                    //rotate offset
                                    float offsetX = 0.0f;
                                    float offsetY = 20.0f;
                                    float offsetZ = 0.0f;
                                    Vector3D newVector = RotateFunctions.Rotate(offsetX, offsetY, offsetZ, rbd.qx, rbd.qy, rbd.qz, rbd.qw);

                                    //送信

                                    pos = new Vector3D
                                    {
                                        x = rbd.x + newVector.x / 2.0f,
                                        y = rbd.y + newVector.y / 2.0f,
                                        z = rbd.z + newVector.z / 2.0f
                                    };

                                    buffer[kinectId] = pos;
                                }
                                else
                                {
                                    Vector3D pos = new Vector3D
                                    {
                                        x = rbd.x,
                                        y = rbd.y,
                                        z = rbd.z
                                    };

                                    buffer[kinectId] = pos;
                                }

                            }
                        }




                    }
                    this.enc_shadow += 0;
                    for (int i = 0; i < 20; i++)
                    {
                        this.enc_shadow += buffer[i].x;
                        this.enc_shadow += buffer[i].y;
                        this.enc_shadow += buffer[i].z;
                        this.enc_shadow += 2;
                    }

                    //this.enc_shadow += (float)0.0f;
                    //this.enc_shadow += (float)0.0f;
                    //this.enc_shadow += (float)0.0f;
                    //byte[] data = this.enc_shadow.data;
                    //this.cipc_shadow.Update(ref data);
                    //Thread.Sleep(5);
                    this.data_shadow = this.enc_shadow.data;

                }


            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.TargetSite + ex.Source);
            }
        }
Ejemplo n.º 31
0
        private void disconnect(int port)
        {
            try
            {
                this.debugwindow.DebugLog = "[RemoteHostServer]切断要求がきました.ポート番号:" + port.ToString();
                destroyport = port;
                this.LstPort.Remove(port);
                this.List_remotehost.RemoveAll(check_remotehosts);

                this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.enc += Definitions.CONNECTION_END;
                this.client.Send(this.enc.data);
            }
            catch (Exception ex)
            {
                debugwindow.DebugLog = ex.Message + "接続を終了する段階でエラーが発生しました。";
            }
        }
Ejemplo n.º 32
0
        /// <summary>
        /// CIPCから深度情報を送信します.
        /// </summary>
        private void CIPC_SEND_DEPTH()
        {
            try
            {

                this.enc_shadow = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                foreach (var p in this.DepthImagePixelData_short)
                {
                    this.enc_shadow += p;
                }
                byte[] arraydata = this.enc_shadow.data;
                int divnum = this.enc_shadow.data.Length / sendsize;
                for (int t = 0; t < divnum; t++)
                {
                    var senddata = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                    senddata += (int)1;
                    senddata += (int)enc_shadow.data.Length;
                    senddata += (int)this.DepthImageRect.Width;
                    senddata += (int)this.DepthImageRect.Height;
                    senddata += (int)sendsize;
                    senddata += (int)t;
                    for (int k = t * sendsize; k < (t + 1) * sendsize; k++)
                    {
                        byte a = arraydata[k];
                        senddata += a;

                    }
                    this.data_shadow = senddata.data;
                    //this.cipc_shadow.Update(ref this.data_shadow);
                    //Thread.Sleep(5);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.TargetSite + ex.Source);
            }
        }
        void SendBodyData(ref UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc, Body[] bodies, int numberofplayer)
        {
            try
            {
                //UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                List <string> str = new List <string>();

                str.Add(bodies.Length.ToString());
                byte MoP = (byte)bodies.Length;
                enc += MoP; //MaxofPlayer

                str.Add(numberofplayer.ToString());
                byte NoP = (byte)numberofplayer;
                enc += NoP; //NumberOfPlayer

                int NumberofBody  = 0;
                int NumberofJoint = 0;
                foreach (var body in bodies.Where(b => b.IsTracked))
                {
                    NumberofBody++;
                    byte NoB = (byte)body.Joints.ToArray().Length;
                    enc += NoB;

                    foreach (var joint in body.Joints)
                    {
                        //kinect関節名前書き出し
                        str.Add(joint.Value.JointType.ToString());
                        NumberofJoint++;
                        str.Add(NumberofJoint.ToString());
                        enc += this.Dimension;
                        enc += joint.Value.Position.X;
                        enc += joint.Value.Position.Y;
                        enc += joint.Value.Position.Z;
                        //追加
                        enc += body.JointOrientations[joint.Value.JointType].Orientation.X;
                        enc += body.JointOrientations[joint.Value.JointType].Orientation.Y;
                        enc += body.JointOrientations[joint.Value.JointType].Orientation.Z;
                        enc += body.JointOrientations[joint.Value.JointType].Orientation.W;
                        byte TS = (byte)joint.Value.TrackingState;
                        enc += TS;

                        #region
                        str.Add(this.Dimension.ToString());
                        str.Add(joint.Value.Position.X.ToString());
                        str.Add(joint.Value.Position.Y.ToString());
                        str.Add(joint.Value.Position.Z.ToString());
                        str.Add(body.JointOrientations[joint.Value.JointType].Orientation.X.ToString());
                        str.Add(body.JointOrientations[joint.Value.JointType].Orientation.Y.ToString());
                        str.Add(body.JointOrientations[joint.Value.JointType].Orientation.Z.ToString());
                        str.Add(body.JointOrientations[joint.Value.JointType].Orientation.W.ToString());
                        str.Add(joint.Value.TrackingState.ToString());
                        #endregion
                    }
                }



                //byte[] data = enc.data;
                //csvに保存
                #region
                if (this.IsSave)
                {
                    //string s2 = string.Join(",", s1);
                    string strdata = string.Join(",", str.ToArray());
                    this.streamWriter.WriteLine(strdata);
                    //sw.Close();
                }
                #endregion
                //CIPCに送信

                /*
                 #region
                 * if (this.cipcMain != null)
                 * {
                 *  this.cipcMain.send(data);
                 * }
                 #endregion
                 */
            }
            catch
            {
                this.ErrorPoint(System.Reflection.MethodBase.GetCurrentMethod().ToString());
            }
        }
Ejemplo n.º 34
0
        private void SendSKST_3Dmodel_Pos_div()
        {
            //TODO:60kbyte以下
            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            string str = "3DModel1";
            enc += str;
            enc += (int)this.mesh_3dmodel.Positions.Count / this.databit_3Dmodel / this.databit_3Dmodel;

            Console.WriteLine("clear");
            for (int i = 0; i < this.mesh_3dmodel.Positions.Count / this.databit_3Dmodel / this.databit_3Dmodel; i++)
            {
                float x = (float)this.mesh_3dmodel.Positions[i].X;
                float y = (float)this.mesh_3dmodel.Positions[i].Y;
                float z = (float)this.mesh_3dmodel.Positions[i].Z;

                float _x = x;
                float _y = (float)(Math.Cos(-(float)this.CS.rx) * y - Math.Sin(-(float)this.CS.rx) * z);
                float _z = (float)(Math.Sin(-(float)this.CS.rx) * y + Math.Cos(-(float)this.CS.rx) * z);

                x = (float)(Math.Cos((float)this.CS.rz) * _x - Math.Sin((float)this.CS.rz) * _y);
                y = (float)(Math.Sin((float)this.CS.rz) * _x + Math.Cos((float)this.CS.rz) * _y);
                z = _z;

                _x = (float)(Math.Cos((float)this.CS.ry) * x - Math.Sin((float)this.CS.ry) * z);
                _y = y;
                _z = (float)(Math.Sin((float)this.CS.ry) * x + Math.Cos((float)this.CS.ry) * z);

                enc += _x + this.CS.dx;
                enc += _y + this.CS.dy;
                enc += _z + this.CS.dz;
            }
            Console.WriteLine(this.mesh_3dmodel.Positions.Count / this.databit_3Dmodel / this.databit_3Dmodel);
            Console.WriteLine(enc.data.Length);
            byte[] data = enc.data;

            int datasize = data.Length;
            const int OnePacketLength = 614400;
            //分割数
            int div_num = datasize / OnePacketLength;
            //あまり
            int mod_num = datasize % OnePacketLength;
            //あまりがある場合は+1
            div_num = (mod_num == 0 ? div_num : div_num + 1);

            byte[][] DivinedData = new byte[div_num][];
            for (int i = 0; i < div_num; i++)
            {
                DivinedData[i] = (i < div_num -1 ? new byte[OnePacketLength] : new byte[mod_num]);
                for (int j = 0; j < DivinedData[i].Length; j++)
                {
                    DivinedData[i][j] = data[i * OnePacketLength + j];
                }
            }

            this.SendSKST_DivData(DivinedData);
        }
Ejemplo n.º 35
0
 public NormalResponse()
 {
     this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
     this.enc += (int)0;
     this.data = this.enc.data;
 }
Ejemplo n.º 36
0
        private void make_send_joint(int index, JointType jt)
        {
            try
            {
                switch (this.sendto)
                {
                    case SendTo.ShadowKinectSensorTerminal:
                        float x = (float)this.FrameSkeletons[index].Joints[jt].Position.X;
                        float y = (float)this.FrameSkeletons[index].Joints[jt].Position.Y;
                        float z = (float)this.FrameSkeletons[index].Joints[jt].Position.Z;

                        float _x = x;
                        float _y = (float)(Math.Cos(-(float)this.CS.rx) * y - Math.Sin(-(float)this.CS.rx) * z);
                        float _z = (float)(Math.Sin(-(float)this.CS.rx) * y + Math.Cos(-(float)this.CS.rx) * z);

                        x = (float)(Math.Cos((float)this.CS.rz) * _x - Math.Sin((float)this.CS.rz) * _y);
                        y = (float)(Math.Sin((float)this.CS.rz) * _x + Math.Cos((float)this.CS.rz) * _y);
                        z = _z;

                        _x = (float)(Math.Cos((float)this.CS.ry) * x - Math.Sin((float)this.CS.ry) * z);
                        _y = y;
                        _z = (float)(Math.Sin((float)this.CS.ry) * x + Math.Cos((float)this.CS.ry) * z);

                        this.enc_shadow += _x + this.CS.dx;
                        this.enc_shadow += _y + this.CS.dy;
                        this.enc_shadow += _z + this.CS.dz;
                        break;
                    case SendTo.CIPCServer:
                        this.enc_shadow += (float)this.FrameSkeletons[index].Joints[jt].Position.X;
                        this.enc_shadow += (float)this.FrameSkeletons[index].Joints[jt].Position.Y;
                        this.enc_shadow += (float)this.FrameSkeletons[index].Joints[jt].Position.Z;
                        break;
                    default:
                        break;
                }
                switch (this.FrameSkeletons[index].Joints[jt].TrackingState)
                {
                    case JointTrackingState.NotTracked:
                        this.enc_shadow += 0;
                        this.TrackingLevel += 0;
                        break;
                    case JointTrackingState.Inferred:
                        this.enc_shadow += 1;
                        this.TrackingLevel += 1;
                        break;
                    case JointTrackingState.Tracked:
                        this.enc_shadow += 2;
                        this.TrackingLevel += 2;
                        break;
                    default:
                        this.enc_shadow += 9;
                        this.TrackingLevel += 0;
                        break;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 37
0
        private void disconnect(int port)
        {
            try
            {
                this.debugwindow.DebugLog = "[RemoteHostServer]切断要求がきました.ポート番号:" + port.ToString();

                destroyport = port;
                var connections = this.parent.DataConnectionServer.List_dataconnection.FindAll(p => p.SENDER.ID == port || p.RECEIVER.ID == port);
                foreach (var p in connections)
                {
                    this.parent.DataConnectionServer.delete_connection(p.SENDER, p.RECEIVER);
                }
                this.parent.DataConnectionServer.ListBox_update(parent.LISTBOX_DATA_CONNECTION);

                this.LstPort.Remove(port);
                this.List_remotehost.RemoveAll(check_remotehosts);

                this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.enc += Definitions.CONNECTION_END;
                this.client.Send(this.enc.data);
            }
            catch (Exception ex)
            {
                debugwindow.DebugLog = ex.Message + "接続を終了する段階でエラーが発生しました。";
            }
        }
Ejemplo n.º 38
0
 public void Udp_Send(TerminalConnectionSettings.TerminalProtocols.CIPCTerminalCommand terminalcommand)
 {
     try
     {
         if (this.IsConnectionSetupped)
         {
             UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
             enc += (int)20;
             enc += (string)terminalcommand.Data;
             this.client.Send(enc.data);
         }
         else
         {
             throw new Exception("接続設定をしてください");
         }
     }
     catch (Exception ex)
     {
         this.debuglog.DebugLogPrint = this.debuglog.DebugLogPrint = "[" + this.ToString() + "]" + ex.Message;
     }
 }
Ejemplo n.º 39
0
        private void SendSKST_3Dmodel_Skeleton()
        {
            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            string str = "3DModel3";
            enc += str;
            if (this.skeleton_3Dmodel != null)
            {
                enc += (int)this.skeleton_3Dmodel.Joints.Count;
            }
            else
            {
                enc += (int)0;
            }
            Console.WriteLine("clear");
            if (this.skeleton_3Dmodel != null)
            {
                for (int i = 0; i < this.skeleton_3Dmodel.Joints.Count; i++)
                {

                    float x = (float)this.skeleton_3Dmodel.Joints[(JointType)i].Position.X;
                    float y = (float)this.skeleton_3Dmodel.Joints[(JointType)i].Position.Y;
                    float z = (float)this.skeleton_3Dmodel.Joints[(JointType)i].Position.Z;

                    float _x = x;
                    float _y = (float)(Math.Cos(-(float)this.CS.rx) * y - Math.Sin(-(float)this.CS.rx) * z);
                    float _z = (float)(Math.Sin(-(float)this.CS.rx) * y + Math.Cos(-(float)this.CS.rx) * z);


                    x = (float)(Math.Cos((float)this.CS.rz) * _x - Math.Sin((float)this.CS.rz) * _y);
                    y = (float)(Math.Sin((float)this.CS.rz) * _x + Math.Cos((float)this.CS.rz) * _y);
                    z = _z;

                    _x = (float)(Math.Cos((float)this.CS.ry) * x - Math.Sin((float)this.CS.ry) * z);
                    _y = y;
                    _z = (float)(Math.Sin((float)this.CS.ry) * x + Math.Cos((float)this.CS.ry) * z);

                    enc += _x + this.CS.dx;
                    enc += _y + this.CS.dy;
                    enc += _z + this.CS.dz;
                }
            }
            Console.WriteLine("Finish");

            byte[] data = enc.data;
            this.SKST.networkstream.Write(data, 0, data.Length);

        }
        //データ送信
        void SendData()
        {
            //CIPCに送信
            #region
            try
            {
                UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();

                if (this.SendData_Body.IsChecked == true) this.SendBodyData(ref enc, this.bodies, this.NumberofPlayer);
                else if (this.SendData_LEDPt.IsChecked == true) this.SendLEDPtData(ref enc);

                if (this.cipcMain != null && enc.data != null)
                {
                    this.cipcMain.send(enc.data);
                    //Console.WriteLine("sendDat");
                }
                if (this.UDPclientWidow != null && enc.data != null)
                {
                    this.UDPclientWidow.Send(enc.data);
                    //Console.WriteLine("sendDat");
                }
            }
            catch
            {
                this.ErrorPoint(System.Reflection.MethodBase.GetCurrentMethod().Name.ToString());

            }
            #endregion
        }
Ejemplo n.º 41
0
        /// <summary>
        /// リモートホストと接続します。
        /// </summary>
        /// <returns>接続先のIPエンドポイント</returns>
        private IPEndPoint Connect()
        {
            try
            {
                while (true)
                {
                    if (this.UP_Cliant.Received_Data != null)
                    {
                        this.UP_Decoder.Source = this.UP_Cliant.Received_Data;
                        break;
                    }
                }
                if (this.UP_Decoder.get_int() == Definitions.CONNECTION_DEMANDS)
                {

                    this.FPS = this.UP_Decoder.get_int();
                    this.fpsa.Fps = this.FPS;
                    this.fpsa.Start();

                    switch (this.UP_Decoder.get_int())
                    {
                        case Definitions.CONNECTION_MODE_SEND:
                            this.cstate = ConnectionState.Sender;
                            this.UP_Cliant.DataReceived += UP_Cliant_DataReceived;
                            break;
                        case Definitions.CONNECTION_MODE_RECEIVE:
                            this.cstate = ConnectionState.Receiver;
                            break;
                        default:
                            throw new Exception("CONNECTION_MODE が無効です。senderの設定を確かめてください。");
                    }
                    name = this.UP_Decoder.get_string();

                    Thread.Sleep(100);

                    this.UP_Encoder = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                    this.UP_Encoder += Definitions.CONNECTION_OK;
                    this.UP_Cliant.Send(this.UP_Encoder.data);

                    this.isConnected = true;

                }
                else
                {
                    throw new Exception("コネクションの際に例外が発生しました。");
                }
                return UP_Cliant.RemoteEP;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.UP_Cliant.DataReset();
            }
            return UP_Cliant.RemoteEP;
        }
Ejemplo n.º 42
0
 public NormalResponse()
 {
     this.enc  = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
     this.enc += (int)0;
     this.data = this.enc.data;
 }
Ejemplo n.º 43
0
        public static void Udp_Send(UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client, TerminalConnectionSettings.TerminalProtocols.CIPCTerminalCommand terminalcommand)
        {
            try
            {
                UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                enc += (int)20;
                enc += (string)terminalcommand.Data;
                client.Send(enc.data);

            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 44
0
        void Send(int localport, int newclientport)
        {
            UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
            enc += true;
            enc += localport;
            enc += newclientport;
            byte[] data = enc.data;

            if (this.server != null)
                this.server.BeginSend(data, data.Length, this.clientIP, this.clientPort, this.sendCallBack, this.server);
        }
Ejemplo n.º 45
0
        private void connect(ref int port)
        {
            try
            {
                for (int current_port = Definitions.PORT_START_NUMBER; current_port < Definitions.PORT_START_NUMBER + max_connect_num; current_port++)
                {
                    if (!this.LstPort.Contains(current_port))
                    {
                        port = current_port;
                        this.LstPort.Add(current_port);

                        this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                        this.enc += Definitions.CONNECTION_OK;
                        this.enc += current_port;
                        this.client.Send(this.enc.data);

                        this.debugwindow.DebugLog = "[RemoteHostServer]接続要求がきました.解放ポートを通知します.ポート番号:" + port.ToString();
                        break;
                    }
                }
            }catch(Exception ex)
            {
                debugwindow.DebugLog = ex.Message + "コネクトの段階でエラーが発生しました。";
            }
        }
Ejemplo n.º 46
0
 /// <summary>
 /// CIPCからSKELETONDATAを送信します.
 /// </summary>
 private void CIPC_SEND_SKELETON()
 {
     try
     {
         this.TrackingLevel = 0;
         this.enc_shadow = null;
         this.enc_shadow = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
         this.enc_shadow += 2;
         this.enc_shadow += this.FrameSkeletons.Length;
         for (int i = 0; i < FrameSkeletons.Length; i++)
         {
             this.enc_shadow += i;
             this.make_send_joint(i, JointType.HipCenter);
             this.make_send_joint(i, JointType.Spine);
             this.make_send_joint(i, JointType.ShoulderCenter);
             this.make_send_joint(i, JointType.Head);
             this.make_send_joint(i, JointType.ShoulderLeft);
             this.make_send_joint(i, JointType.ElbowLeft);
             this.make_send_joint(i, JointType.WristLeft);
             this.make_send_joint(i, JointType.HandLeft);
             this.make_send_joint(i, JointType.ShoulderRight);
             this.make_send_joint(i, JointType.ElbowRight);
             this.make_send_joint(i, JointType.WristRight);
             this.make_send_joint(i, JointType.HandRight);
             this.make_send_joint(i, JointType.HipLeft);
             this.make_send_joint(i, JointType.KneeLeft);
             this.make_send_joint(i, JointType.AnkleLeft);
             this.make_send_joint(i, JointType.FootLeft);
             this.make_send_joint(i, JointType.HipRight);
             this.make_send_joint(i, JointType.KneeRight);
             this.make_send_joint(i, JointType.AnkleRight);
             this.make_send_joint(i, JointType.FootRight);
         }
         this.enc_shadow += (float)kinectsensor.AccelerometerGetCurrentReading().X;
         this.enc_shadow += (float)kinectsensor.AccelerometerGetCurrentReading().Y;
         this.enc_shadow += (float)kinectsensor.AccelerometerGetCurrentReading().Z;
         this.data_shadow = this.enc_shadow.data;
         //byte[] data = this.enc_shadow.data;
         //this.cipc_shadow.Update(ref data);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.TargetSite + ex.Source);
     }
 }
Ejemplo n.º 47
0
        public RemoteHostServer()
        {
            try
            {
                client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort);
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }

            try
            {
                this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
                this.LstPort = new List<int>();

                mytask = new Task(() => this.MAIN_TASK());
                mytask.Start();
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
            try
            {
                #region create remotehost servers list and one remotehost server
                this.List_remotehost = new List<RemoteHost>();
                #endregion
            }
            catch(Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Ejemplo n.º 48
0
 public CloseResponse()
 {
     this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
     this.enc += (int)9;
     this.data = this.enc.data;
 }