Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        // find script
        mySerialScript = GetComponent <SerialConnect>();

        // find all comm ports
        if (mySerialScript != null)
        {
            // list all comm ports
            mySerialScript.PopulateComPorts();

            for (int i = 0; i < SerialConnect.comPorts.Count; i++)
            {
                // create a button for each comm port
                //GameObject button = (GameObject)Instantiate(buttonPrefab);
                //button.GetComponentInChildren<Text>().text = SerialConnect.comPorts[i];
                string arg = SerialConnect.comPorts[i]; // pass this string to the lambda function
                MyOpenFunction(arg);                    // connects to the first comport
                //button.GetComponent<Button>().onClick.AddListener((
                //   ) => { MyOpenFunction(arg); }
                //   );
                //button.transform.parent = menuPanel;
            }
        }
    }
Beispiel #2
0
 void Start()
 {
     btnBack.onClick.AddListener(OnClick);
     serial = SerialConnect.GetInstance();
     serial.AddListener(new BackwardListener());
     if (!serial.IsListening())
     {
         serial.StartListening();
     }
 }
Beispiel #3
0
 // Use this for initialization
 void Start()
 {
     timeDef = timeButton;
     Blocks  = GameObject.FindGameObjectsWithTag("Player");
     cycle   = true;
     if (GameObject.FindGameObjectsWithTag("Played").Length >= 1)
     {
         Debug.LogWarning("More than one player detected, all blocks need the 'player' tag in the editor, this script will take care of the rest");
     }
     myScript = objectWithSerialConnect.GetComponent <SerialConnect>();
 }
Beispiel #4
0
 // Start is called before the first frame update
 void Start()
 {
     BtnStop.onClick.AddListener(OnClick);
     _serial = SerialConnect.GetInstance();
     _serial.StartListening();
 }
Beispiel #5
0
 // Use this for initialization
 void Start()
 {
     //
     myScript = objectWithSerialConnect.GetComponent <SerialConnect>();
     command  = myScript.commandToSend;
 }
Beispiel #6
0
 // Use this for initialization
 void Start()
 {
     myScript = objectWithSerialConnect.GetComponent <SerialConnect>();
     origRot  = transform.rotation;
 }
Beispiel #7
0
 // Start is called before the first frame update
 void Start()
 {
     slider.onValueChanged.AddListener(OnValue);
     serial = SerialConnect.GetInstance();
     serial.StartListening();
 }
Beispiel #8
0
        public static MyCanvas LoadProject(string filename, TextBox a, TextBox b, TextBox c)
        {
            MyCanvas    FirstElement = null;
            MyCanvas    Curent       = null;
            MyCanvas    PREVIOUS     = null;
            XmlDocument xDoc         = new XmlDocument();

            xDoc.Load(filename);
            // получим корневой элемент
            XmlElement xRoot = xDoc.DocumentElement;

            // обход всех узлов в корневом элементе
            if (xRoot.Attributes.Count > 0)
            {
                a.Text = xRoot.Attributes.GetNamedItem("EXP").Value;
                b.Text = xRoot.Attributes.GetNamedItem("TIME").Value;
                c.Text = xRoot.Attributes.GetNamedItem("KOEF").Value;
            }
            foreach (XmlNode xnode in xRoot)
            {
                // получаем атрибут name
                if (xnode.Attributes.Count > 0)
                {
                    XmlNode attr = xnode.Attributes.GetNamedItem("ELTYPE");
                    if (attr.Value == "EMPTY")
                    {
                        Curent = new MyCanvas();
                    }
                    else if (attr.Value == "PLAIN")
                    {
                        Curent = new Plain();
                    }
                    else if (attr.Value == "LOADED")
                    {
                        Curent = new Loaded();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "UNLOADED")
                    {
                        Curent = new Unloaded();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "SLIDINGLOAD")
                    {
                        Curent = new SlidingLoaded();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "SLIDINGUNLOAD")
                    {
                        Curent = new SlidingUnLoaded();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "MAJOR")
                    {
                        Curent = new MajorConnect();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "BRIDGE")
                    {
                        Curent = new BridgeConnect();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "BDCGLR")
                    {
                        Curent = new BackupDeviceControlGroupsLR();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "SERIAL")
                    {
                        Curent = new SerialConnect();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "BACKUP")
                    {
                        Curent = new BackupControlType2();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "RMR")
                    {
                        Curent = new ReservManageReplacing();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "LIST_")
                    {
                        Curent = new List_(null);
                        loadList(xnode, Curent);
                    }
                    Curent.Draw();
                    Canvas.SetLeft(Curent, Convert.ToDouble(xnode.Attributes.GetNamedItem("X").Value));
                    Canvas.SetTop(Curent, Convert.ToDouble(xnode.Attributes.GetNamedItem("Y").Value));
                    Curent.lambda        = Convert.ToDouble(xnode.Attributes.GetNamedItem("LAMBDA").Value);
                    Curent.lambda_1      = Convert.ToDouble(xnode.Attributes.GetNamedItem("LAMBDA_1").Value);
                    Curent.ItemsAmount   = Convert.ToInt32(xnode.Attributes.GetNamedItem("ITEMS").Value);
                    Curent.ItemsAmount_1 = Convert.ToInt32(xnode.Attributes.GetNamedItem("ITEMS_1").Value);
                }
                if (FirstElement == null)
                {
                    FirstElement = Curent;
                }
                Curent.PREVIOUS = PREVIOUS;
                if (PREVIOUS != null)
                {
                    PREVIOUS.NEXT = Curent;
                }
                PREVIOUS = Curent;
                Curent   = Curent.NEXT;
            }
            return(FirstElement);
        }
Beispiel #9
0
        public static void loadElement(XmlNode node, MyCanvas Element)
        {
            MyCanvas Curent = null;

            foreach (XmlNode xnode in node)
            {
                // получаем атрибут name
                if (xnode.Attributes.Count > 0)
                {
                    XmlNode attr = xnode.Attributes.GetNamedItem("ELTYPE");
                    if (attr.Value == "EMPTY")
                    {
                        Curent = new MyCanvas();
                    }
                    else if (attr.Value == "PLAIN")
                    {
                        Curent = new Plain();
                    }
                    else if (attr.Value == "LOADED")
                    {
                        Curent = new Loaded();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "UNLOADED")
                    {
                        Curent = new Unloaded();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "SLIDINGLOAD")
                    {
                        Curent = new SlidingLoaded();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "SLIDINGUNLOAD")
                    {
                        Curent = new SlidingUnLoaded();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "MAJOR")
                    {
                        Curent = new MajorConnect();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "BRIDGE")
                    {
                        Curent = new BridgeConnect();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "BDCGLR")
                    {
                        Curent = new BackupDeviceControlGroupsLR();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "SERIAL")
                    {
                        Curent = new SerialConnect();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "BACKUP")
                    {
                        Curent = new BackupControlType2();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "RMR")
                    {
                        Curent = new ReservManageReplacing();
                        loadElement(xnode, Curent);
                    }
                    else if (attr.Value == "LIST_")
                    {
                        Curent = new List_(null);
                        loadList(xnode, Curent);
                    }
                    Curent.Draw();
                    Canvas.SetLeft(Curent, Convert.ToDouble(xnode.Attributes.GetNamedItem("X").Value));
                    Canvas.SetTop(Curent, Convert.ToDouble(xnode.Attributes.GetNamedItem("Y").Value));
                    Curent.lambda        = Convert.ToDouble(xnode.Attributes.GetNamedItem("LAMBDA").Value);
                    Curent.lambda_1      = Convert.ToDouble(xnode.Attributes.GetNamedItem("LAMBDA_1").Value);
                    Curent.ItemsAmount   = Convert.ToInt32(xnode.Attributes.GetNamedItem("ITEMS").Value);
                    Curent.ItemsAmount_1 = Convert.ToInt32(xnode.Attributes.GetNamedItem("ITEMS_1").Value);
                }
                if (Element.cont == 0)
                {
                    Element.ContainEl = Curent;
                    Element.cont++;
                }
                else if (Element.cont == 1)
                {
                    Element.ContainEl_1 = Curent;
                    Element.cont++;
                }
                else if (Element.cont == 2)
                {
                    Element.ContainEl_2 = Curent;
                    Element.cont++;
                }
                Curent = Curent.NEXT;
            }
        }