Example #1
0
        public UnsureNetworkForm()
        {
            InitializeComponent();

            NodeSavingReading reader = new NodeSavingReading();

            net = new NeuralNet(7, 7, ANNfilename, KFoldFilename);
            inputTrainingData  = reader.GetStoredDataFromFile(Globals.inputDataStorage);
            outputTrainingData = reader.GetStoredDataFromFile(Globals.outputDataStorage);

            //inputTrainingData = new List<double[]>();
            //outputTrainingData = new List<double[]>();

            controls = new PatsControlScheme();
            controls.Initialize();
            controls.timeNeededForChange = 7000;

            serial = new SerialReader();
            serial.Read();

            UnityCommunicationHub.InitializeUnityCommunication();
            UnityCommunicationHub.TwoWayTransmission();


            indexList        = Globals.GetBasicValues();
            reverseIndexList = Globals.GetBasicValuesReversed();
            setPointList     = Globals.GetBasicPositions();

            foreach (KeyValuePair <string, int> position in indexList)
            {
                DefaultPositionsBox.Items.Add(position.Key);
            }
        }
Example #2
0
        public NeuralNetForm()
        {
            InitializeComponent();

            NodeSavingReading reader = new NodeSavingReading();

            net = new NeuralNet(8, 7, ANNfilename, KFoldFilename);
            inputTrainingData  = reader.GetStoredDataFromFile(Globals.inputDataStorage);
            outputTrainingData = reader.GetStoredDataFromFile(Globals.outputDataStorage);

            //inputTrainingData = new List<double[]>();
            //outputTrainingData = new List<double[]>();



            serial = new SerialReader();
            serial.Read();

            UnityCommunicationHub.InitializeUnityCommunication();
            UnityCommunicationHub.TwoWayTransmission();


            indexList    = Globals.GetBasicValues();
            setPointList = Globals.GetBasicPositions();

            foreach (KeyValuePair <string, int> position in indexList)
            {
                DefaultPositionsBox.Items.Add(position.Key);
            }
        }
Example #3
0
        public ContinuousNeuralNetForm()
        {
            InitializeComponent();

            net = new NeuralNet(8, 7, ANNfilename, KFoldFilename);
            inputTrainingData  = new List <double[]>();
            outputTrainingData = new List <double[]>();

            if (inputTrainingData.Count > expirationTimer)
            {
                inputTrainingData.RemoveAt(0);
                outputTrainingData.RemoveAt(0);
            }

            serial = new SerialReader();
            serial.Read();

            UnityCommunicationHub.InitializeUnityCommunication();
            UnityCommunicationHub.TwoWayTransmission();

            Random rand = new Random(23);

            setPointList = Globals.GetBasicPositions();

            var firstPoint = setPointList[3];

            Globals.A1DesiredPosition = firstPoint.A1Position;
            Globals.A2DesiredPosition = firstPoint.A2Position;
            Globals.A3DesiredPosition = firstPoint.A3Position;
            Globals.B1DesiredPosition = firstPoint.B1Position;
            Globals.B2DesiredPosition = firstPoint.B2Position;
            Globals.B3DesiredPosition = firstPoint.B3Position;
            Globals.C1DesiredPosition = firstPoint.C1Position;
            Globals.C2DesiredPosition = firstPoint.C2Position;
            Globals.C3DesiredPosition = firstPoint.C3Position;
            Globals.D1DesiredPosition = firstPoint.D1Position;
            Globals.D2DesiredPosition = firstPoint.D2Position;
            Globals.D3DesiredPosition = firstPoint.D3Position;
            Globals.T1DesiredPosition = firstPoint.T1Position;
            Globals.T2DesiredPosition = firstPoint.T2Position;
            //Globals.T1DesiredPosition = (float)rand.Next(0, 90);
            //Globals.T2DesiredPosition = (float)rand.Next(0, 90);
            //Globals.A1DesiredPosition = (float)rand.Next(0, 90);
            //Globals.A2DesiredPosition = (float)rand.Next(0, 90);
            //Globals.A3DesiredPosition = (float)rand.Next(0, 90);
            //Globals.B1DesiredPosition = (float)rand.Next(0, 90);
            //Globals.B2DesiredPosition = (float)rand.Next(0, 90);
            //Globals.B3DesiredPosition = (float)rand.Next(0, 90);
            //Globals.C1DesiredPosition = (float)rand.Next(0, 90);
            //Globals.C2DesiredPosition = (float)rand.Next(0, 90);
            //Globals.C3DesiredPosition = (float)rand.Next(0, 90);
            //Globals.D1DesiredPosition = (float)rand.Next(0, 90);
            //Globals.D2DesiredPosition = (float)rand.Next(0, 90);
            //Globals.D3DesiredPosition = (float)rand.Next(0, 90);


            lastSetPoint = firstPoint;
            UnityCommunicationHub.WriteData(true);
        }
Example #4
0
        private void DecreaseAngleButton_Click(object sender, EventArgs e)
        {
            float desiredAngle = (float)System.Convert.ToDouble(DesiredAngleInput.Text) - 1.0f;

            DesiredAngleInput.Text = desiredAngle.ToString();
            setDesiredAngle();
            UnityCommunicationHub.TwoWayTransmission();
        }
Example #5
0
 private void DesiredAngleInput_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         setDesiredAngle();
         UnityCommunicationHub.TwoWayTransmission();
         e.Handled = e.SuppressKeyPress = true;
     }
 }
Example #6
0
        private void TestButton_Click(object sender, EventArgs e)
        {
            //Random rand = new Random(23);

            //setPointList = Globals.GetBasicPositions();

            //var firstPoint = setPointList[rand.Next(0, 5)];
            //Globals.A1DesiredPosition = firstPoint.A1Position;
            //Globals.A2DesiredPosition = firstPoint.A2Position;
            //Globals.A3DesiredPosition = firstPoint.A3Position;
            //Globals.B1DesiredPosition = firstPoint.B1Position;
            //Globals.B2DesiredPosition = firstPoint.B2Position;
            //Globals.B3DesiredPosition = firstPoint.B3Position;
            //Globals.C1DesiredPosition = firstPoint.C1Position;
            //Globals.C2DesiredPosition = firstPoint.C2Position;
            //Globals.C3DesiredPosition = firstPoint.C3Position;
            //Globals.D1DesiredPosition = firstPoint.D1Position;
            //Globals.D2DesiredPosition = firstPoint.D2Position;
            //Globals.D3DesiredPosition = firstPoint.D3Position;
            //Globals.T1DesiredPosition = firstPoint.T1Position;
            //Globals.T2DesiredPosition = firstPoint.T2Position;
            //Globals.T1DesiredPosition = (float)rand.Next(0, 90);
            //Globals.T2DesiredPosition = (float)rand.Next(0, 90);
            //Globals.A1DesiredPosition = (float)rand.Next(0, 90);
            //Globals.A2DesiredPosition = (float)rand.Next(0, 90);
            //Globals.A3DesiredPosition = (float)rand.Next(0, 90);
            //Globals.B1DesiredPosition = (float)rand.Next(0, 90);
            //Globals.B2DesiredPosition = (float)rand.Next(0, 90);
            //Globals.B3DesiredPosition = (float)rand.Next(0, 90);
            //Globals.C1DesiredPosition = (float)rand.Next(0, 90);
            //Globals.C2DesiredPosition = (float)rand.Next(0, 90);
            //Globals.C3DesiredPosition = (float)rand.Next(0, 90);
            //Globals.D1DesiredPosition = (float)rand.Next(0, 90);
            //Globals.D2DesiredPosition = (float)rand.Next(0, 90);
            //Globals.D3DesiredPosition = (float)rand.Next(0, 90);



            UnityCommunicationHub.WriteData(true);
            for (int i = 0; i < 7; i++)
            {
                positionsToVisit.Add(i);
            }
            for (int i = 0; i < 22; i++)
            {
                Thread testThread = new Thread(Test);
                testThread.Start();
                Thread trainingThread = new Thread(Train);
                trainingThread.Start();
                Thread.Sleep(1000);
            }
        }
Example #7
0
        private void Run()
        {
            //while (true)
            {
                lock (dataLock)
                {
                    var      input     = serial.GetData();
                    double[] inputData = new double[8];
                    for (int j = 0; j < 8; j++)
                    {
                        inputData[j] = input[j];
                    }
                    var percievedPositionArray = net.Think(inputData);

                    double   bestVal      = 0;
                    SetPoint bestSetPoint = new SetPoint();


                    for (int i = 0; i < percievedPositionArray.Length; i++)
                    {
                        if (percievedPositionArray[i] > bestVal)
                        {
                            bestVal      = percievedPositionArray[i];
                            bestSetPoint = setPointList[i];
                        }
                    }


                    var percievedPosition = bestSetPoint;

                    Globals.T1DesiredPosition = percievedPosition.T1Position;
                    Globals.T2DesiredPosition = percievedPosition.T2Position;
                    Globals.A1DesiredPosition = percievedPosition.A1Position;
                    Globals.A2DesiredPosition = percievedPosition.A2Position;
                    Globals.A3DesiredPosition = percievedPosition.A3Position;
                    Globals.B1DesiredPosition = percievedPosition.B1Position;
                    Globals.B2DesiredPosition = percievedPosition.B2Position;
                    Globals.B3DesiredPosition = percievedPosition.B3Position;
                    Globals.C1DesiredPosition = percievedPosition.C1Position;
                    Globals.C2DesiredPosition = percievedPosition.C2Position;
                    Globals.C3DesiredPosition = percievedPosition.C3Position;
                    Globals.D1DesiredPosition = percievedPosition.D1Position;
                    Globals.D2DesiredPosition = percievedPosition.D2Position;
                    Globals.D3DesiredPosition = percievedPosition.D3Position;

                    UnityCommunicationHub.WriteData(true);
                }
            }
        }
Example #8
0
 private void loadPositions(Node thisNode)
 {
     Globals.A1DesiredPosition = thisNode.A1Position;
     Globals.A2DesiredPosition = thisNode.A2Position;
     Globals.A3DesiredPosition = thisNode.A3Position;
     Globals.B1DesiredPosition = thisNode.B1Position;
     Globals.B2DesiredPosition = thisNode.B2Position;
     Globals.B3DesiredPosition = thisNode.B3Position;
     Globals.C1DesiredPosition = thisNode.C1Position;
     Globals.C2DesiredPosition = thisNode.C2Position;
     Globals.C3DesiredPosition = thisNode.C3Position;
     Globals.D1DesiredPosition = thisNode.D1Position;
     Globals.D2DesiredPosition = thisNode.D2Position;
     Globals.D3DesiredPosition = thisNode.D3Position;
     Globals.T1DesiredPosition = thisNode.T1Position;
     Globals.T2DesiredPosition = thisNode.T2Position;
     UnityCommunicationHub.TwoWayTransmission();
 }
Example #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (UnityCommunicationHub.connected)
            {
                try
                {
                    Globals.T1DesiredPosition = float.Parse(toSend);
                }
                catch (Exception error)
                {
                    Console.WriteLine("ERROR WHEN PARSING FLOAT: " + error.ToString());
                    Globals.T1DesiredPosition = 0;
                }

                UnityCommunicationHub.TwoWayTransmission();
            }
            else
            {
                Console.WriteLine("ERROR: CONNECT TO UNITY FIRST");
                textBox1.Text = "ERROR: CONNECT TO UNITY FIRST";
            }
        }
Example #10
0
        private void setHandPositionButton_Click(object sender, EventArgs e)
        {
            UnityCommunicationHub.ReadData(true);
            SetPoint newPoint = new SetPoint
            {
                A1Position = Globals.A1DesiredPosition,
                A2Position = Globals.A2DesiredPosition,
                A3Position = Globals.A3DesiredPosition,
                B1Position = Globals.B1DesiredPosition,
                B2Position = Globals.B2DesiredPosition,
                B3Position = Globals.B3DesiredPosition,
                C1Position = Globals.C1DesiredPosition,
                C2Position = Globals.C2DesiredPosition,
                C3Position = Globals.C3DesiredPosition,
                D1Position = Globals.D1DesiredPosition,
                D2Position = Globals.D2DesiredPosition,
                D3Position = Globals.D3DesiredPosition,
                T1Position = Globals.T1DesiredPosition,
                T2Position = Globals.T2DesiredPosition
            };

            controls.allNodes[(int)activeNode.Tag].setHandPosition(newPoint);
        }
Example #11
0
        private void Test()
        {
            lock (dataLock)
            {
                //var input = serial.GetData();
                //UnityCommunicationHub.ReadData();
                //var percievedPositionArray = net.Think(input);



                //inputTrainingData.Add(input);
                //outputTrainingData.Add(Globals.GetDoubles());

                //for (int i = 0; i < percievedPositionArray.Length; i++)
                //{
                //    percievedPositionArray[i] = percievedPositionArray[i] * 90;
                //}



                //Globals.T1DesiredPosition = (float)percievedPositionArray[0];
                //Globals.T2DesiredPosition = (float)percievedPositionArray[1];
                //Globals.A1DesiredPosition = (float)percievedPositionArray[2];
                //Globals.A2DesiredPosition = (float)percievedPositionArray[3];
                //Globals.A3DesiredPosition = (float)percievedPositionArray[4];
                //Globals.B1DesiredPosition = (float)percievedPositionArray[5];
                //Globals.B2DesiredPosition = (float)percievedPositionArray[6];
                //Globals.B3DesiredPosition = (float)percievedPositionArray[7];
                //Globals.C1DesiredPosition = (float)percievedPositionArray[8];
                //Globals.C2DesiredPosition = (float)percievedPositionArray[9];
                //Globals.C3DesiredPosition = (float)percievedPositionArray[10];
                //Globals.D1DesiredPosition = (float)percievedPositionArray[11];
                //Globals.D2DesiredPosition = (float)percievedPositionArray[12];
                //Globals.D3DesiredPosition = (float)percievedPositionArray[13];
                var percievedPosition = new SetPoint(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                var rand = new Random();
                //UnityCommunicationHub.WriteData(true);

                var percievedPositionArray = new double[7];

                if (inputTrainingData.Count != 0)
                {
                    percievedPositionArray = net.Think(inputTrainingData[inputTrainingData.Count - 1]);

                    double   bestVal      = 0;
                    SetPoint bestSetPoint = new SetPoint();


                    for (int i = 0; i < percievedPositionArray.Length; i++)
                    {
                        if (percievedPositionArray[i] > bestVal)
                        {
                            bestVal      = percievedPositionArray[i];
                            bestSetPoint = setPointList[i];
                        }
                    }

                    if (lastSetPoint.Equals(bestSetPoint))
                    {
                        percievedPosition = setPointList[rand.Next(0, 7)];
                    }
                    else
                    {
                        percievedPosition = bestSetPoint;
                    }
                }
                else
                {
                    percievedPosition = setPointList[rand.Next(0, 7)];
                }

                if (positionsToVisit.Count > 0)
                {
                    percievedPosition = setPointList[positionsToVisit.First()];
                    for (int i = 0; i < 7; i++)
                    {
                        if ((7 - i) == positionsToVisit.Count)
                        {
                            percievedPositionArray[i] = 1;
                        }
                    }
                    positionsToVisit.RemoveAt(0);
                }

                Globals.T1DesiredPosition = percievedPosition.T1Position;
                Globals.T2DesiredPosition = percievedPosition.T2Position;
                Globals.A1DesiredPosition = percievedPosition.A1Position;
                Globals.A2DesiredPosition = percievedPosition.A2Position;
                Globals.A3DesiredPosition = percievedPosition.A3Position;
                Globals.B1DesiredPosition = percievedPosition.B1Position;
                Globals.B2DesiredPosition = percievedPosition.B2Position;
                Globals.B3DesiredPosition = percievedPosition.B3Position;
                Globals.C1DesiredPosition = percievedPosition.C1Position;
                Globals.C2DesiredPosition = percievedPosition.C2Position;
                Globals.C3DesiredPosition = percievedPosition.C3Position;
                Globals.D1DesiredPosition = percievedPosition.D1Position;
                Globals.D2DesiredPosition = percievedPosition.D2Position;
                Globals.D3DesiredPosition = percievedPosition.D3Position;

                UnityCommunicationHub.WriteData(true);
                lastSetPoint = percievedPosition;
                Thread.Sleep(200);
                for (int i = 0; i < 250; i++)
                {
                    var      input     = serial.GetData();
                    double[] inputData = new double[8];
                    for (int j = 0; j < 8; j++)
                    {
                        inputData[j] = input[j];
                    }
                    UnityCommunicationHub.ReadData();


                    inputTrainingData.Add(inputData);
                    outputTrainingData.Add(percievedPositionArray);
                    Thread.Sleep(1);
                }
            }
        }
Example #12
0
        private void Run()
        {
            lock (dataLock)
            {
                //var input = serial.GetData();
                //var percievedPositionArray = net.Think(input);

                //if (input.Contains(double.NaN))
                //{
                //    while (input.Contains(double.NaN))
                //    {
                //        input = serial.GetData();
                //    }
                //}

                //for (int i = 0; i < percievedPositionArray.Length; i++)
                //{
                //    percievedPositionArray[i] = percievedPositionArray[i] * 90;
                //}



                //Globals.T1DesiredPosition = (float)percievedPositionArray[0];
                //Globals.T2DesiredPosition = (float)percievedPositionArray[1];
                //Globals.A1DesiredPosition = (float)percievedPositionArray[2];
                //Globals.A2DesiredPosition = (float)percievedPositionArray[3];
                //Globals.A3DesiredPosition = (float)percievedPositionArray[4];
                //Globals.B1DesiredPosition = (float)percievedPositionArray[5];
                //Globals.B2DesiredPosition = (float)percievedPositionArray[6];
                //Globals.B3DesiredPosition = (float)percievedPositionArray[7];
                //Globals.C1DesiredPosition = (float)percievedPositionArray[8];
                //Globals.C2DesiredPosition = (float)percievedPositionArray[9];
                //Globals.C3DesiredPosition = (float)percievedPositionArray[10];
                //Globals.D1DesiredPosition = (float)percievedPositionArray[11];
                //Globals.D2DesiredPosition = (float)percievedPositionArray[12];
                //Globals.D3DesiredPosition = (float)percievedPositionArray[13];

                //UnityCommunicationHub.WriteData(true);

                var      input     = serial.GetData();
                double[] inputData = new double[8];
                for (int j = 0; j < 8; j++)
                {
                    inputData[j] = input[j];
                }
                var percievedPositionArray = net.Think(inputData);

                double   bestVal      = 0;
                SetPoint bestSetPoint = new SetPoint();


                for (int i = 0; i < percievedPositionArray.Length; i++)
                {
                    if (percievedPositionArray[i] > bestVal)
                    {
                        bestVal      = percievedPositionArray[i];
                        bestSetPoint = setPointList[i];
                    }
                }


                var percievedPosition = bestSetPoint;

                Globals.T1DesiredPosition = percievedPosition.T1Position;
                Globals.T2DesiredPosition = percievedPosition.T2Position;
                Globals.A1DesiredPosition = percievedPosition.A1Position;
                Globals.A2DesiredPosition = percievedPosition.A2Position;
                Globals.A3DesiredPosition = percievedPosition.A3Position;
                Globals.B1DesiredPosition = percievedPosition.B1Position;
                Globals.B2DesiredPosition = percievedPosition.B2Position;
                Globals.B3DesiredPosition = percievedPosition.B3Position;
                Globals.C1DesiredPosition = percievedPosition.C1Position;
                Globals.C2DesiredPosition = percievedPosition.C2Position;
                Globals.C3DesiredPosition = percievedPosition.C3Position;
                Globals.D1DesiredPosition = percievedPosition.D1Position;
                Globals.D2DesiredPosition = percievedPosition.D2Position;
                Globals.D3DesiredPosition = percievedPosition.D3Position;

                UnityCommunicationHub.WriteData(true);
            }
        }
Example #13
0
 //exits the application
 public static void CloseAllForms(object sender, FormClosingEventArgs e)
 {
     UnityCommunicationHub.PurgeFileSystem();
     Application.Exit();
 }
Example #14
0
 private void button3_Click(object sender, EventArgs e)
 {
     UnityCommunicationHub.InitializeUnityCommunication();
 }
Example #15
0
        public NeuralTreeWindow()
        {
            this.Size         = new System.Drawing.Size(1710, 1301);
            this.FormClosing += Globals.CloseAllForms;
            InitializeComponent();

            updateFingerDisplay();

            UnityCommunicationHub.InitializeUnityCommunication();

            //initialize tree structure
            controls = new PatsControlScheme();
            controls.Initialize();

            loadPositions(controls.root);

            List <Node> newList = controls.allNodes.Values.ToList <Node>();

            //order the list from lowest to highest to ensure all nodes are populated in order
            newList.OrderBy(o => o.id);

            //make sure the list of nodes is clear
            NeuronTreeView.Nodes.Clear();

            //sequentially add all the nodes to the tree
            foreach (Node n in newList)
            {
                if (n.id != Globals.CONTROLNODE)
                {
                    //figure out what the parent id is
                    int parentID = n.parent;
                    //if it's the root node, just add it to the tree
                    if (parentID == Globals.NULLPARENT)
                    {
                        TreeNode newNode = new TreeNode(n.name);
                        newNode.Tag = n.id;
                        NeuronTreeView.Nodes.Add(newNode);
                        activeNode = newNode;
                    }
                    //in the case that it's a child node, figure out what display node to add it to
                    else
                    {
                        //iterate through until you find the parent
                        TreeNode parentNode = findNodeInTree(parentID);
                        //once we find the parent, add it to the parent's children
                        TreeNode newNode = new TreeNode(n.name);
                        newNode.Tag = n.id;
                        parentNode.Nodes.Add(newNode);
                    }
                }
            }

            foreach (Node n in newList)
            {
                if (n.id != Globals.CONTROLNODE && n.children.Contains(Globals.CONTROLNODE))
                {
                    TreeNode tn   = findNodeInTree(n.id);
                    bool     done = false;
                    foreach (TreeNode tnn in tn.Nodes)
                    {
                        if (!done && (int)tnn.Tag == Globals.CONTROLNODE)
                        {
                            tnn.Remove();
                            done = true;
                        }
                    }
                    TreeNode newControlNode = new TreeNode("Controls");
                    newControlNode.Tag = Globals.CONTROLNODE;
                    tn.Nodes.Add(newControlNode);
                }
            }
        }
Example #16
0
        private void Run()
        {
            //while (true)
            {
                lock (dataLock)
                {
                    var      input     = serial.GetData();
                    double[] inputData = new double[7];
                    for (int j = 0; j < 8; j++)
                    {
                        if (j < 1)
                        {
                            inputData[j] = input[j];
                        }
                        else if (j > 1)
                        {
                            inputData[j - 1] = input[j];
                        }
                    }
                    var percievedPositionArray = net.Think(inputData);

                    double   bestVal      = 0;
                    SetPoint bestSetPoint = new SetPoint();
                    bool     goodToMove   = false;

                    while (!goodToMove)
                    {
                        var index = 0;
                        for (int i = 0; i < percievedPositionArray.Length; i++)
                        {
                            if (percievedPositionArray[i] > bestVal)
                            {
                                bestVal      = percievedPositionArray[i];
                                index        = i;
                                bestSetPoint = setPointList[i];
                            }
                        }

                        if (bestVal > 0.95)
                        {
                            goodToMove = true;
                        }
                        else
                        {
                            PositionTextBox.Text = reverseIndexList[index];
                            goodToMove           = RunFocus();
                            if (!goodToMove)
                            {
                                percievedPositionArray[index] = 0;
                                bestVal = 0;
                            }
                        }
                    }

                    var percievedPosition = bestSetPoint;

                    Globals.T1DesiredPosition = percievedPosition.T1Position;
                    Globals.T2DesiredPosition = percievedPosition.T2Position;
                    Globals.A1DesiredPosition = percievedPosition.A1Position;
                    Globals.A2DesiredPosition = percievedPosition.A2Position;
                    Globals.A3DesiredPosition = percievedPosition.A3Position;
                    Globals.B1DesiredPosition = percievedPosition.B1Position;
                    Globals.B2DesiredPosition = percievedPosition.B2Position;
                    Globals.B3DesiredPosition = percievedPosition.B3Position;
                    Globals.C1DesiredPosition = percievedPosition.C1Position;
                    Globals.C2DesiredPosition = percievedPosition.C2Position;
                    Globals.C3DesiredPosition = percievedPosition.C3Position;
                    Globals.D1DesiredPosition = percievedPosition.D1Position;
                    Globals.D2DesiredPosition = percievedPosition.D2Position;
                    Globals.D3DesiredPosition = percievedPosition.D3Position;

                    UnityCommunicationHub.WriteData(true);
                }
            }
        }