/// <summary>
        /// オープン
        /// </summary>
        /// <param name="portname"></param>
        /// <returns></returns>
        public ErrorCode Open(string portname)
        {
            ERROR     er   = ERROR.READER_UNKNOWN;
            ErrorCode code = new ErrorCode();

            code.Clear();

            _FixBarcodePort.PortName = portname;

            _FixBarcodePort.BaudRate = 115200;
            _FixBarcodePort.DataBits = 8;
            _FixBarcodePort.Parity   = System.IO.Ports.Parity.None;
            _FixBarcodePort.StopBits = System.IO.Ports.StopBits.One;
            try { _FixBarcodePort.Open(); }
            catch
            {
                er            = ERROR.READER_OPEN;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                return(code);
            }

            er                        = ERROR.READER_NONE;
            code.ErrorNo              = (int)er;
            code.ErrorStr             = er.ToString();
            _FixBarcodePort.RtsEnable = true;


            return(code);
        }
Example #2
0
        public ErrorCode ChangeGain(int gain_right, int gain_left)
        {
            ERROR     er   = ERROR.CAMERA_UNKNOWN;
            ErrorCode code = new ErrorCode();

            code.Clear();

            lock (_SyncObj)
            {
                if (_RightCameraObj.SetGlobalGain(gain_right) != 1)
                {
                    er            = ERROR.CAMERA_SETGAIN;
                    code.ErrorNo  = (int)er;
                    code.ErrorStr = er.ToString();
                    code.DetailNo = _RightCameraObj.GetLastError();
                    return(code);
                }

                if (_LeftCameraObj.SetGlobalGain(gain_left) != 1)
                {
                    er            = ERROR.CAMERA_SETGAIN;
                    code.ErrorNo  = (int)er;
                    code.ErrorStr = er.ToString();
                    code.DetailNo = _LeftCameraObj.GetLastError();
                    return(code);
                }
            }
            er            = ERROR.CAMERA_NONE;
            code.ErrorNo  = (int)er;
            code.ErrorStr = er.ToString();
            return(code);
        }
    private void MakeMyPlayer(ResponseData res, ERROR error)
    {
        if (error != ERROR.NONE)
        {
            PrintSystemLog(error.ToString());
            return;
        }

        var data = (PlayerData)res;

        myPlayer = CreatePlayer(data);

        players.Add(myPlayer);

        myPlayer.IsMyPlayer = true;

        Camera.main.transform.parent = myPlayer.transform;

        Camera.main.transform.localPosition = new Vector3(1.5f, 12f, 1.5f);

        mapCollider.transform.parent = myPlayer.transform;

        mapCollider.transform.position = Vector3.zero;

        mapCollider.SetActive(true);
    }
Example #4
0
        public ErrorCode Capture(out byte[] lpic, out byte[] rpic)
        {
            ERROR     er   = ERROR.CAMERA_UNKNOWN;
            ErrorCode code = new ErrorCode();

            code.Clear();

            lpic = new byte[PIC_WIDTH * PIC_HEIGHT * 3];
            rpic = new byte[PIC_WIDTH * PIC_HEIGHT * 3];

            lock (_SyncObj)
            {
                if (_LeftCameraObj.SnapShot(lpic, PIC_WIDTH * PIC_HEIGHT * 3, 0) != 1)
                {
                    er            = ERROR.CAMERA_CAPTURE;
                    code.ErrorNo  = (int)er;
                    code.ErrorStr = er.ToString();
                    code.DetailNo = _LeftCameraObj.GetLastError();
                    return(code);
                }
                if (_RightCameraObj.SnapShot(rpic, PIC_WIDTH * PIC_HEIGHT * 3, 0) != 1)
                {
                    er            = ERROR.CAMERA_CAPTURE;
                    code.ErrorNo  = (int)er;
                    code.ErrorStr = er.ToString();
                    code.DetailNo = _RightCameraObj.GetLastError();
                    return(code);
                }
            }

            //System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\Users\\masudako\\Documents\\test.csv");

            //int length = lpic.Length - 1000000;
            //for (int i = 0; i < length; i++)
            //{
            //    sw.WriteLine(lpic[i+1000000]);
            //}

            //sw.Close();
            //sw.Dispose();

            er            = ERROR.CAMERA_NONE;
            code.ErrorNo  = (int)er;
            code.ErrorStr = er.ToString();
            return(code);
        }
        /// <summary>
        /// 読取
        /// </summary>
        /// <param name="portname"></param>
        /// <returns></returns>
        public ErrorCode Read(out string serial)
        {
            ERROR     er   = ERROR.READER_UNKNOWN;
            ErrorCode code = new ErrorCode();

            code.Clear();

            serial = "";
            //try
            //{
            //    _BarcodePort.DiscardInBuffer();
            //    _BarcodePort.WriteLine(System.Text.Encoding.ASCII.GetString(new byte[] { 0x1B }) + "A0.02\r");
            //}

            //catch
            //{
            //    er = ERROR.READER_WRITE;
            //    code.ErrorNo = (int)er;
            //    code.ErrorStr = er.ToString();
            //    return code;
            //}

            try
            {
                serial = _FixBarcodePort.ReadLine();

                // フッタ切り取り // xoa byte dau va byte cuoi
            }
            catch
            {
                er            = ERROR.READER_READ;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                return(code);
            }

            er            = ERROR.READER_NONE;
            code.ErrorNo  = (int)er;
            code.ErrorStr = er.ToString();
            return(code);
        }
    private void DisconnectedPlayer(ResponseData res, ERROR error)
    {
        if (error != ERROR.NONE)
        {
            PrintSystemLog(error.ToString());
            return;
        }

        var data = (PlayerData)res;

        DestroyPlayer(data, ERROR.NONE);

        PrintSystemLog($"{data.userId}님이 서버를 종료했습니다.");
    }
    private void MakePlayer(ResponseData res, ERROR error)
    {
        if (error != ERROR.NONE)
        {
            PrintSystemLog(error.ToString());
            return;
        }

        var data = (PlayerData)res;

        var player = CreatePlayer(data);

        players.Add(player);
    }
    private void ResponseMovePlayer(ResponseData res, ERROR error)
    {
        if (error != ERROR.NONE)
        {
            PrintSystemLog(error.ToString());
            return;
        }

        var data = (PlayerData)res;

        var player = players.Find(p => p.PlayerData.userId == data.userId);

        player.MovePlayerNextPosition(data);
    }
    private void DestroyPlayer(ResponseData res, ERROR error)
    {
        if (error != ERROR.NONE)
        {
            PrintSystemLog(error.ToString());
            return;
        }

        var data = (PlayerData)res;

        var player = players.Find(p => p.PlayerData.userId == data.userId);

        Destroy(player.gameObject);

        var index = players.FindIndex(p => p.PlayerData.userId == data.userId);

        players.RemoveAt(index);
    }
Example #10
0
    private void ReceiveChatData(ResponseData res, ERROR error)
    {
        if (error != ERROR.NONE)
        {
            GameManager.Inst.PrintSystemLog(error.ToString());
            return;
        }

        var data = (ChatData)res;

        if (GameManager.Inst.UserId == data.userId)
        {
            PrintChatText($"\n<color=#0DFF00>{data.userId} : {data.message}</color>");
        }
        else
        {
            PrintChatText($"\n{data.userId} : {data.message}");
        }
    }
Example #11
0
        public ErrorCode Close()
        {
            ERROR     er   = ERROR.CAMERA_UNKNOWN;
            ErrorCode code = new ErrorCode();

            code.Clear();

            if (IsOpen)
            {
                _RightCameraObj.Close();
                _LeftCameraObj.Close();

                _RightCameraObj.Release();
                _LeftCameraObj.Release();
            }

            er            = ERROR.CAMERA_NONE;
            code.ErrorNo  = (int)er;
            code.ErrorStr = er.ToString();
            return(code);
        }
Example #12
0
        /// <summary>
        /// OPEN
        /// </summary>
        /// <param name="handle"></param>
        /// <returns></returns>
        public ErrorCode Open(IntPtr handle, int gain_right, int gain_left)
        {
            ERROR     er   = ERROR.CAMERA_UNKNOWN;
            ErrorCode code = new ErrorCode();

            code.Clear();

            IsOpen = false;

            if (!_RightCameraObj.LoadLibrary("ArtCamSdk_036MI2_WOM.dll"))
            {
                _RightCameraObj.GetLastError();


                er            = ERROR.CAMERA_LOADLIBRARY;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (!_LeftCameraObj.LoadLibrary("ArtCamSdk_036MI2_WOM.dll"))
            {
                er            = ERROR.CAMERA_LOADLIBRARY;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }

            if (!_RightCameraObj.Initialize(handle))
            {
                er            = ERROR.CAMERA_INITIALIZE;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (!_LeftCameraObj.Initialize(handle))
            {
                er            = ERROR.CAMERA_INITIALIZE;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }

            if (_RightCameraObj.SetDeviceNumber(0) != 1)
            {
                er            = ERROR.CAMERA_SETDEVICENUMBER;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (_LeftCameraObj.SetDeviceNumber(1) != 1)
            {
                er            = ERROR.CAMERA_SETDEVICENUMBER;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }


            if (_RightCameraObj.SetHalfClock(1) != 1)
            {
                er            = ERROR.CAMERA_SETHALFCLOCK;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (_LeftCameraObj.SetHalfClock(1) != 1)
            {
                er            = ERROR.CAMERA_SETHALFCLOCK;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }

            // IDチェック
            int leftidNo  = 1;
            int rightidNo = 2;

            int left_id_now  = _LeftCameraObj.ReadSromID(0);
            int right_id_now = _LeftCameraObj.ReadSromID(0);

            if (left_id_now == leftidNo && right_id_now == rightidNo)
            {
                // スルー
            }

            else if (left_id_now == rightidNo && right_id_now == leftidNo)
            {
                CArtCam tempobj = _RightCameraObj;
                _RightCameraObj = _LeftCameraObj;
                _LeftCameraObj  = tempobj;
            }
            else
            {
                _RightCameraObj.WriteSromID(0, rightidNo);
                _LeftCameraObj.WriteSromID(0, rightidNo);
            }


            if (_RightCameraObj.SetGlobalGain(gain_right) != 1)
            {
                er            = ERROR.CAMERA_SETGAIN;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (_LeftCameraObj.SetGlobalGain(gain_left) != 1)
            {
                er            = ERROR.CAMERA_SETGAIN;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }

            if (_RightCameraObj.SetMirrorH(true) != 1)
            {
                er            = ERROR.CAMERA_SETMIRROR;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (_LeftCameraObj.SetMirrorH(true) != 1)
            {
                er            = ERROR.CAMERA_SETMIRROR;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }

            if (_RightCameraObj.Capture() != 1)
            {
                er            = ERROR.CAMERA_CAPTURE;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (_LeftCameraObj.Capture() != 1)
            {
                er            = ERROR.CAMERA_CAPTURE;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }



            IsOpen = true;


            er            = ERROR.CAMERA_NONE;
            code.ErrorNo  = (int)er;
            code.ErrorStr = er.ToString();
            return(code);
        }
 public static String error(String message)
 {
     return($"{ERROR.ToString()} {message}");
 }