示例#1
0
        public bool Init(HANDTYPE type)
        {
            byte[] buf = new byte[300];
            for (int i = 0; i < 6; i++)
            {
                valid[i] = true;
            }
            for (int i = 0; i < 16; i++)
            {
                data[i] = Quaternion.identity;
            }

            if (type == HANDTYPE.RIGHT_HAND)
            {
                if (get_RH_port(buf))
                {
                    Console.WriteLine("Try to opening RH Port: " + System.Text.Encoding.ASCII.GetString(buf));
                    if (open_port(this.sp, buf, baud_rate, type))
                    {
                        Console.WriteLine("COM_PORT Opened: " + System.Text.Encoding.ASCII.GetString(buf));
                        port_opened = true;
                        stat        = VRTRIXGloveStatus.NORMAL;
                    }
                    else
                    {
                        Console.WriteLine("COM_PORT Open Failed");
                    }
                }
            }
            else if (type == HANDTYPE.LEFT_HAND)
            {
                if (get_LH_port(buf))
                {
                    Console.WriteLine("Try to opening LH Port: " + System.Text.Encoding.ASCII.GetString(buf));
                    if (open_port(this.sp, buf, baud_rate, type))
                    {
                        Console.WriteLine("COM_PORT Opened: " + System.Text.Encoding.ASCII.GetString(buf));
                        port_opened = true;
                        stat        = VRTRIXGloveStatus.NORMAL;
                    }
                    else
                    {
                        Console.WriteLine("COM_PORT Open Failed");
                    }
                }
            }

            return(port_opened);
        }
示例#2
0
        public bool Init(HANDTYPE type)
        {
            for (int i = 0; i < 16; i++)
            {
                data[i] = Quaternion.identity;
            }

            if (sp != null)
            {
                try
                {
                    if (type == HANDTYPE.RIGHT_HAND)
                    {
                        Debug.Log("Try to connect RH index: " + index);
                    }
                    else if (type == HANDTYPE.LEFT_HAND)
                    {
                        Debug.Log("Try to connect LH index: " + index);
                    }

                    if (OpenPort(this.sp, index, type))
                    {
                        port_opened = true;
                        stat        = VRTRIXGloveStatus.NORMAL;
                    }
                    else
                    {
                        Debug.Log("PORT Open Failed");
                    }
                    return(port_opened);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            return(port_opened);
        }
 public void SetReceivedStatus(VRTRIXGloveStatus stat)
 {
     this.stat = stat;
 }
 public bool ClosePort()
 {
     stat = VRTRIXGloveStatus.CLOSED;
     return(close_port(this.sp));
 }