Ejemplo n.º 1
0
    void Awake()
    {
        if (mSerial == null)
        {
            mSerial = GetComponent <NemoSerial>();
        }

        //mTouchScreenByteLs = new List<byte>();
        mTouchScreenBytes = new byte[4096];
        mTouchScreenIdx   = 0;
        //mRecivedBytes = new List<byte>();
        mTouchDatas = new List <Vector2>();
    }
Ejemplo n.º 2
0
    public bool Open()
    {
        if (mSerial == null)
            mSerial = GetComponent<NemoSerial>();

        //mSerial.BaudRate = 38400;
        mSerial.HandleRecivePackage += OnRecivePackage;
        //
        //         mSerial.BytesPerPackage = 7;
        //         mSerial.BaudRate = 38400;
        //         mSerial.PortName = "COM8";
        bool sucess = mSerial.Open();

        return sucess;
    }
Ejemplo n.º 3
0
    public bool Open()
    {
        if (mSerial == null)
        {
            mSerial = GetComponent <NemoSerial>();
        }

        //mSerial.BaudRate = 38400;
        mSerial.HandleRecivePackage += OnRecivePackage;
//
//         mSerial.BytesPerPackage = 7;
//         mSerial.BaudRate = 38400;
//         mSerial.PortName = "COM8";
        bool sucess = mSerial.Open();

        return(sucess);
    }
Ejemplo n.º 4
0
    //IEnumerator _Coro_DebugLog()
    //{
    //    int i = 0;
    //    while (true)
    //    {
    //        DebugLog("TestLog" + (i++));
    //        yield return new WaitForSeconds(0.1F);
    //    }
    //}
    void Handle_ResultReadWrite(bool isWrite, uint adress, byte datalen, byte resultCode, byte[] data)
    {
        //return;
        if (!mViewReadWrite)
        {
            return;
        }

        DebugLog(string.Format("[读写请求返回] 类型:{0}  地址:{1:d} 数据长度:{2:d} 结果码:{3:d} 内容:{4}"
                               , isWrite ? "写" : "读"
                               , adress
                               , datalen
                               , resultCode
                               , data == null?"无":NemoSerial.ByteArrayToString(data)));
        //Debug.Log(string.Format("[读写请求返回] 类型:{0}  地址:{1:d} 数据长度:{2:d} 结果码:{3:d} 内容:{4}"
        //    , isWrite ? "写" : "读"
        //    , adress
        //    , datalen
        //    , resultCode
        //    , data == null ? "无" : NemoSerial.ByteArrayToString(data)));
    }
Ejemplo n.º 5
0
    public void Handle_MCU_Connect()
    {
        //从FRAM获得guid
        byte[] guidFRAMByte = null;
        if (mMCU.Read_Block(0, 16, out guidFRAMByte))//从FRAM读取guid成功
        {
            Debug.Log("open guid:" + NemoSerial.ByteArrayToString(StaticValueContainerDBFRAM.GetDBID().ToByteArray()));
            System.Guid FRAMEGUID = new System.Guid(guidFRAMByte);
            if (StaticValueContainerDBFRAM.GetDBID() != System.Guid.Empty &&
                FRAMEGUID != StaticValueContainerDBFRAM.GetDBID())   //FRAM和db的guid不一致
            {
                Debug.Log("open guid不一致:" + NemoSerial.ByteArrayToString(StaticValueContainerDBFRAM.GetDBID().ToByteArray()));
                mMCU.RequestReadWrite(true, 0, 16, StaticValueContainerDBFRAM.GetDBID().ToByteArray());//将dbid写入FRAM
                //更新所有IUpdatable
                foreach (IUpdatable i in Updatables)
                {
                    i.UpdateToFRAM();
                }
            }
        }

        //if(StaticValueContainerDBFRAM.GetDBID()
    }
Ejemplo n.º 6
0
    void OnGUI()
    {
        if (Skin != null)
        {
            GUI.skin = Skin;
        }


        GUILayout.BeginHorizontal();


        GUILayout.BeginVertical();//左边控制台
        {
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("串口(1-n):");

            GUILayout_IntArea(ref SerialPort);
            GUILayout_IntArea(ref boudarate);
            if (GUILayout.Button("打开"))
            {
                NemoSerial ns = GetComponent <NemoSerial>();
                if (ns != null)
                {
                    ns.PortName = "COM" + SerialPort;
                    ns.BaudRate = boudarate;
                }
                else
                {
                    DebugLog("找不到NemoSerial组件,打开串口失败.");
                }

                //int

                if (ArcIO.Open())
                {
                    DebugLog("打开串口成功");
                }
                else
                {
                    DebugLog("打开串口失败");
                }
            }


            if (GUILayout.Button("关闭"))
            {
                ArcIO.Close();
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(20.0f);

            GUILayout.BeginVertical("box");
            {
                GUILayout.BeginHorizontal("box");
                {
                    GUILayout.Label("机台号(0-5):");
                    if (GUILayout_IntArea(ref PlayerIdx))//player改变
                    {
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout_IntArea(ref mOutCoinNum);
                if (GUILayout.Button("出币"))
                {
                    ArcIO.OutCoin((uint)mOutCoinNum, PlayerIdx);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout_IntArea(ref mOutTicketNum);
                if (GUILayout.Button("出票"))
                {
                    ArcIO.OutTicket((uint)mOutTicketNum, PlayerIdx);
                }
                GUILayout.EndHorizontal();

                bool oldRTOBToggle = mRealTimeOutBounty;
                mRealTimeOutBounty = GUILayout.Toggle(mRealTimeOutBounty, "实时退币(票)");
                if (oldRTOBToggle != mRealTimeOutBounty)
                {
                    ArcIO.SetRealTimeOutBounty(mRealTimeOutBounty);
                }


                if (GUILayout.Button("补币"))
                {
                    ArcIO.ResponCoin(PlayerIdx);
                }

                if (GUILayout.Button("补票"))
                {
                    ArcIO.ResponTicket(PlayerIdx);
                }

                GUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("闪灯"))
                    {
                        ArcIO.FlashButtomLight(mButtomLightIdx);
                    }
                    GUILayout.Label("玩家ID(0-5):");
                    GUILayout_IntArea(ref mButtomLightIdx);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button(mSendingFlashLightMsg ? "发送大量闪灯数据[停]" : "发送大量闪灯数据[开]"))
                    {
                        if (mSendingFlashLightMsg)
                        {
                            StopCoroutine("_Coro_FlashLights");
                            mSendingFlashLightMsg = false;
                        }
                        else
                        {
                            StartCoroutine("_Coro_FlashLights");
                            mSendingFlashLightMsg = true;
                        }
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    if (!mDataBackOnOff)
                    {
                        if (GUILayout.Button("返回大量数据[开始]"))
                        {
                            ArcIO.RequestDataBack((byte)mDataBackLen, (byte)mDataBackInterval, true);
                            mDataBackOnOff = true;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("返回大量数据[停止]"))
                        {
                            ArcIO.RequestDataBack((byte)mDataBackLen, (byte)mDataBackInterval, false);
                            mDataBackOnOff = false;
                        }
                    }

                    GUILayout.Label("长度(byte)");
                    GUILayout_IntArea(ref mDataBackLen);
                    GUILayout.Label("间隔(ms)");
                    GUILayout_IntArea(ref mDataBackInterval);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            GUILayout.Space(20.0f);
            GUILayout.BeginVertical("box");
            {
                //if (GUILayout.Button("版本号" + mHardwareVersion))
                //{
                //    ArcIO.RequestHardwareVersion();
                //}


                GUILayout.BeginHorizontal();
                GUILayout.Label("外围跑灯模式(0-4):");
                int scenicLightMode = (int)mScenicLightMode;
                if (GUILayout_IntArea(ref scenicLightMode))
                {
                    mScenicLightMode = (ArcadeIO_Feng.ScenicLightMode)scenicLightMode;
                }

                if (GUILayout.Button("设置"))
                {
                    ArcIO.SetScenicLight(mScenicLightMode);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();


            mSendVisibleMsg = GUILayout.TextArea(mSendVisibleMsg, GUILayout.MinWidth(TextAreaMinWidth));
            if (GUILayout.Button("验证明文"))
            {
                byte[] ba = System.Text.Encoding.Default.GetBytes(mSendVisibleMsg);
                string viewPlainTextBytes = "";
                foreach (byte b in ba)
                {
                    viewPlainTextBytes += string.Format("  {0:x}", b);
                }
                DebugLog("发出明文(hex):" + viewPlainTextBytes);
                ArcIO.SendCheckPlainText(System.Text.Encoding.Default.GetBytes(mSendVisibleMsg));
            }

            if (GUILayout.Button("清空LOG"))
            {
                mDebugInfos.Clear();
                mScrollVal = 0F;
            }
        }
        GUILayout.EndVertical();//左边控制台结束

        //GUILayout.BeginVertical("box");
        GUILayout.TextArea(""

                           , new GUILayoutOption[] { GUILayout.MinWidth(750), GUILayout.MinHeight(390) });
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();//右边combobox的显示
        {
            string viewStr = "";
            int    i       = 0;
            int    j       = 0;
            foreach (string info in mDebugInfos)
            {
                if (i >= (int)mScrollVal)
                {
                    viewStr = viewStr + info + "\n";
                    ++j;
                    if (j >= mConsoloViewMaxLine)
                    {
                        break;
                    }
                }
                ++i;
            }
            GUILayout.TextArea(viewStr
                               , new GUILayoutOption[] { GUILayout.MinWidth(500), GUILayout.MinHeight(330) });


            if (mDebugInfos.Count > mConsoloViewMaxLine)
            {
                mScrollVal = GUILayout.VerticalScrollbar(mScrollVal, 1f, 0F, (1 + mDebugInfos.Count - mConsoloViewMaxLine)
                                                         , GUILayout.MinHeight(330));
            }
        }
        GUILayout.EndHorizontal();

        //GUILayout.TextField(mDebugInfos.Count.ToString());
        //GUILayout.TextField(mScrollVal.ToString());
        //GUILayout.EndHorizontal();
    }
Ejemplo n.º 7
0
    void OnRecivePackage(NemoSerial.Package p)
    {
        //Debug.Log("mTouchScreenIdx =" + mTouchScreenIdx + "   p.data.Length = " + ((p.data == null) ? 0:p.data.Length));
        int writtedIdx = mTouchScreenIdx;
        mTouchScreenBytes[mTouchScreenIdx] = p.data[0];
        ++mTouchScreenIdx;

        if (writtedIdx == 1 && mTouchScreenBytes[writtedIdx] == 0xf5)//֮ǰһ�ֽ���������
        {

            --mTouchScreenIdx;//��������������
        }

        if (writtedIdx == 6)
        {
            mTouchScreenIdx = 0;
            ProcessDataPackage(mTouchScreenBytes);
        }
    }
Ejemplo n.º 8
0
    void Awake()
    {
        if (mSerial == null)
            mSerial = GetComponent<NemoSerial>();

        //mTouchScreenByteLs = new List<byte>();
        mTouchScreenBytes = new byte[4096];
        mTouchScreenIdx = 0;
        //mRecivedBytes = new List<byte>();
        mTouchDatas = new List<Vector2>();
    }