Exemple #1
0
 void OnMouseDown()
 {
     communications = comPort.GetComponent<UnitySerialPort>() as UnitySerialPort;
     Debug.Log("Mouse Down");
     if (!Occupied)
     {
         Occupied = !Occupied;
         arrow.SetActive(true);
         xSign.SetActive(false);
         if (communications.isActiveAndEnabled)
         {
             communications.setState(0x01, 0x23, Occupied);
         }
     }
     else
     {
         Occupied = !Occupied;
         arrow.SetActive(false);
         xSign.SetActive(true);
         if (communications.isActiveAndEnabled)
         {
             communications.setState(0x1, 0x23, Occupied);
         }
     }
 }
Exemple #2
0
    /// <summary>
    /// The awake call is used to populate refs to the gui elements used in this
    /// example. These can be removed or replaced if needed with bespoke elements.
    /// This will not affect the functionality of the system. If we are using awake
    /// then the script is being run non staticaly ie. its initiated and run by
    /// being dropped onto a gameObject, thus enabling the game loop events to be
    /// called e.g. start, update etc.
    /// </summary>
    void Awake()
    {
        DataKey = new object();
        // Define the script Instance
        if (Instance == null)
        {
            //DontDestroyOnLoad(this.gameObject);
            Instance = this;
        }
        else
        {
            Debug.LogWarning("Instance of Serial Port Already exist");
            return;
        }
        try
        {
            ComPort = SerialPort.GetPortNames()[0];
        }
        catch
        {
        }
        // If we have used the editor inspector to populate any included gui
        // elements then lets initiate them and set some default values.

        // Details if the port is open or closed
        //if (ComStatusText != null)
        //{ ComStatusText.guiText.text = "ComStatus: Closed"; }
        this.ChunkData = new string[0];
    }
    // Use this for initialization
    void Start()
    {
        curValues = new int[16];  // numbers is a 16-element array

        sp = UnitySerialPort.Instance;
        sp.OpenSerialPort();
    }
    /// <summary>
    /// Use this for initialization
    /// </summary>
    void Start()
    {
        // Register reference to the UnitySerialPort. This
        // was defined in the scripts Awake function so we
        // know it is instantiated before this call.

        unitySerialPort = UnitySerialPort.Instance;

        // Register the script for all of the available event
        // notifications.

        UnitySerialPort.SerialDataParseEvent +=
            new UnitySerialPort.SerialDataParseEventHandler(UnitySerialPort_SerialDataParseEvent);

        // Port status events

        UnitySerialPort.SerialPortOpenEvent +=
            new UnitySerialPort.SerialPortOpenEventHandler(UnitySerialPort_SerialPortOpenEvent);

        UnitySerialPort.SerialPortCloseEvent +=
            new UnitySerialPort.SerialPortCloseEventHandler(UnitySerialPort_SerialPortCloseEvent);

        // Sent data events

        UnitySerialPort.SerialPortSentDataEvent +=
            new UnitySerialPort.SerialPortSentDataEventHandler(UnitySerialPort_SerialPortSentDataEvent);

        UnitySerialPort.SerialPortSentLineDataEvent +=
            new UnitySerialPort.SerialPortSentLineDataEventHandler(UnitySerialPort_SerialPortSentLineDataEvent);
    }
Exemple #5
0
    // Refs populated by the editor inspector for default gui
    // functionality if script is to be used in a non-static
    // context.
    //public GameObject ComStatusText;

    //public GameObject RawDataText;



    #endregion Properties

    #region Unity Frame Events

    /// <summary>
    /// The awake call is used to populate refs to the gui elements used in this
    /// example. These can be removed or replaced if needed with bespoke elements.
    /// This will not affect the functionality of the system. If we are using awake
    /// then the script is being run non staticaly ie. its initiated and run by
    /// being dropped onto a gameObject, thus enabling the game loop events to be
    /// called e.g. start, update etc.
    /// </summary>
    void Awake()
    {
        // Define the script Instance
        Instance = this;

        // If we have used the editor inspector to populate any included gui
        // elements then lets initiate them and set some default values.
        spaceGPSestado   = false;
        biometricsEstado = true;
        // Details if the port is open or closed
    }
Exemple #6
0
    // Use this for initialization
    void Start()
    {
        //init arrays
        curValues = new int[16];  // numbers is a 16-element array
        oldValues = curValues;

        //init port
        sp = UnitySerialPort.Instance;
        sp.OpenSerialPort();

        lt = GetComponent <Light>();
    }
Exemple #7
0
    /// <summary>
    /// The awake call is used to populate refs to the gui elements used in this
    /// example. These can be removed or replaced if needed with bespoke elements.
    /// This will not affect the functionality of the system. If we are using awake
    /// then the script is being run non staticaly ie. its initiated and run by
    /// being dropped onto a gameObject, thus enabling the game loop events to be
    /// called e.g. start, update etc.
    /// </summary>
    void Awake()
    {
        // Define the script Instance
        Instance = this;

        // If we have used the editor inspector to populate any included gui
        // elements then lets initiate them and set some default values.

        // Details if the port is open or closed
        if (ComStatusText != null)
        {
            ComStatusText.GetComponent <GUIText>().text = "ComStatus: Closed";
        }
    }
    /// <summary>
    /// The awake call is used to populate refs to the gui elements used in this 
    /// example. These can be removed or replaced if needed with bespoke elements.
    /// This will not affect the functionality of the system. If we are using awake
    /// then the script is being run non staticaly ie. its initiated and run by 
    /// being dropped onto a gameObject, thus enabling the game loop events to be 
    /// called e.g. start, update etc.
    /// </summary>
    void Awake()
    {
        // Define the script Instance
        Instance = this;

        // If we have used the editor inspector to populate any included gui
        // elements then lets initiate them and set some default values.

        // Details if the port is open or closed
        if (ComStatusText != null)
        { ComStatusText.GetComponent<GUIText>().text = "ComStatus: Closed"; }
    }
Exemple #9
0
 void Start()
 {
     unitySerialPort = new UnitySerialPort(Instance);
     unitySerialPort = UnitySerialPort.Instance;
 }
 public UnitySerialPort(XBeeManager manager)
 {
     Instance = this;
     PopulateComPorts();
     if (OpenPortOnStart) { OpenSerialPort(); }
 }
 void setRed()
 {
     communications = comPort.GetComponent<UnitySerialPort>() as UnitySerialPort;
     if (communications.isActiveAndEnabled)
     {
         communications.setState((byte)(m_Grana + 1), (byte)(m_Adresa + 1), true);
     }
 }
 void setAuto()
 {
     isManualyRed = !isManualyRed;
     communications = comPort.GetComponent<UnitySerialPort>() as UnitySerialPort;
     if (communications.isActiveAndEnabled)
     {
         communications.setState((byte)(m_Grana + 1), (byte)(m_Adresa + 1), false);
     }
 }
    void OnMouseDown()
    {
        communications = comPort.GetComponent<UnitySerialPort>() as UnitySerialPort;
        if (communications.isActiveAndEnabled)
        {
            if (!Occupied)
            {
                //Occupied = !Occupied;
                setRed();
                isManualyRed = true;

            }
        }
        else
        {

            Occupied = !Occupied;
        }
    }
    /// <summary>
    /// Use this for initialization
    /// </summary>
    void Start()
    {
        // Register reference to the UnitySerialPort. This
        // was defined in the scripts Awake function so we
        // know it is instantiated before this call.

        unitySerialPort = UnitySerialPort.Instance;

        // Register the script for all of the available event
        // notifications.

        UnitySerialPort.SerialDataParseEvent +=
            new UnitySerialPort.SerialDataParseEventHandler(UnitySerialPort_SerialDataParseEvent);

        // Port status events

        UnitySerialPort.SerialPortOpenEvent +=
            new UnitySerialPort.SerialPortOpenEventHandler(UnitySerialPort_SerialPortOpenEvent);

        UnitySerialPort.SerialPortCloseEvent +=
            new UnitySerialPort.SerialPortCloseEventHandler(UnitySerialPort_SerialPortCloseEvent);

        // Sent data events

        UnitySerialPort.SerialPortSentDataEvent +=
            new UnitySerialPort.SerialPortSentDataEventHandler(UnitySerialPort_SerialPortSentDataEvent);

        UnitySerialPort.SerialPortSentLineDataEvent +=
            new UnitySerialPort.SerialPortSentLineDataEventHandler(UnitySerialPort_SerialPortSentLineDataEvent);
    }
Exemple #15
0
 void Start()
 {
     Respond = new List<byte>();
     Grana1Data1 = new List<byte>();
     Grana2Data1 = new List<byte>();
     Grana3Data1 = new List<byte>();
     Grana4Data1 = new List<byte>();
     Grana5Data1 = new List<byte>();
     occupied = ToBoolean(0);
     foreach (GameObject go in m_Grana1)
     {
        go.transform.parent = this.gameObject.transform;
     }
     serialPort = GetComponent<UnitySerialPort>() as UnitySerialPort;
     StartCoroutine(Pool());
 }
 // Update is called once per frame
 void FixedUpdate()
 {
     Vector3 pos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
     RaycastHit2D hit = Physics2D.Raycast(pos, Vector2.zero);
     if (hit != null && hit.collider != null) {
         OnMouseDown();
     }
     communications = comPort.GetComponent<UnitySerialPort>() as UnitySerialPort;
     if (!communications.isActiveAndEnabled)
     {
         if (!Occupied)
         {
             GetComponent<SpriteRenderer>().color = green;
         }
         else
         {
             GetComponent<SpriteRenderer>().color = red;
         }
     }
 }
 // Use this for initialization
 void Start()
 {
     MagneticPinchHand = GameObject.Find ("RigidHandRight");
     PortScript = MagneticPinchHand.GetComponent ("UnitySerialPort") as UnitySerialPort;
     //PortScript.middleTip
     //PortScript = (UnitySerialPort) GameObject.FindObjectOfType (typeof(UnitySerialPort));
     //GUIScript = GameObject.FindGameObjectWithTag("PlayerAnimation").GetComponent<MyAnimationScript>();
 }
    /// <summary>
    /// The awake call is used to populate refs to the gui elements used in this 
    /// example. These can be removed or replaced if needed with bespoke elements.
    /// This will not affect the functionality of the system. If we are using awake
    /// then the script is being run non staticaly ie. its initiated and run by 
    /// being dropped onto a gameObject, thus enabling the game loop events to be 
    /// called e.g. start, update etc.
    /// </summary>
    void Awake()
    {
        path = Application.dataPath + "/StreamingAssets/ComPorts.xml";
        xmlDoc = new XmlDocument(); // xmlDoc is the new xml document.
                                                    // Define the script Instance
        Instance = this;
        xmlDoc.Load(path);
        XMLReader();

        for (int i = 0; i < etaze.Count; i++)
        {
            string etazaName = "";
            string baudrate = "";
            string active = "";
            etaze[i].TryGetValue("name", out etazaName);
            Debug.Log(" OVO IMAM " + etazaName);
            Debug.Log(" OVO JE TAG " + this.gameObject.tag);
            if (this.gameObject.tag == etazaName)
            {
                etaze[i].TryGetValue("comPort", out ComPort);
                Debug.Log(" COMPORT " + ComPort);
                etaze[i].TryGetValue("baudrate", out baudrate);
                etaze[i].TryGetValue("active", out active);
                if (active.Equals("true"))
                {
                    OpenPortOnStart = true;
                }
                else
                {
                    OpenPortOnStart = false;
                }
            }
        }
        // ComPort = this.gameObject.tag;

        // If we have used the editor inspector to populate any included gui
        // elements then lets initiate them and set some default values.

        // Details if the port is open or closed
        if (ComStatusText != null)
        { ComStatusText.GetComponent<GUIText>().text = "ComStatus: Closed"; }
    }