Ejemplo n.º 1
0
        static public Customers[] GetCustomerFromPhotoNumberOfDate(int PhotoNumber, ref int Total)
        {
            FileStream DummyFileStream = null;
            Customers  CustomersDummy  = null;

            Customers[] TotalCustomersDummy = new Customers[1000];
            Total = 0;
            //int Dimension = -1;
            try
            {
                PhotoMemmorry t = new PhotoMemmorry();
                DummyFileStream = new FileStream(STakeImage, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read);
                BinaryFormatter Formatters = new BinaryFormatter();
                DummyFileStream.Seek(0, SeekOrigin.Begin);
                TakeImage DummyOutput = null;
                while (DummyFileStream.Position < DummyFileStream.Length)
                {
                    DummyOutput = (TakeImage)Formatters.Deserialize(DummyFileStream);
                    if (DummyOutput.PhotoNumberAccess == PhotoNumber)
                    {
                        CustomersDummy             = DummyOutput.CustomersAcess;
                        TotalCustomersDummy[Total] = CustomersDummy;
                        Total++;
                    }
                }
            }
            catch (SerializationException t)
            {
                Console.WriteLine(t.Message.ToString());
            }
            DummyFileStream.Flush(); DummyFileStream.Close();
            return(TotalCustomersDummy);
        }
Ejemplo n.º 2
0
        static public void PTakeImage()
        {
            Console.WriteLine("TakeIamge:");

            TakeImage       DummyOutput = new TakeImage(0, null);
            FileStream      TakeImage   = new FileStream(STakeImage, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read);
            BinaryFormatter formatters  = new BinaryFormatter();

            TakeImage.Seek(0, SeekOrigin.Begin);
            while (TakeImage.Position < TakeImage.Length)
            {
                DummyOutput = (TakeImage)formatters.Deserialize(TakeImage);
                string   DummyString = DummyOutput.PhotoNumberAccess.ToString();
                string[] Dummy       = new string[] {
                    DummyOutput.CustomersAcess.CustomersCustomerID.ToString(),
                         DummyOutput.CustomersAcess.CustomersName.ToString(),
                         DummyOutput.CustomersAcess.CustomersFamilyName.ToString(),
                         DummyOutput.CustomersAcess.CustomersAddress.ToString(),
                         DummyOutput.CustomersAcess.CustomersTellefon.ToString()
                };
                Console.WriteLine("Customer:");
                Operator.PrintCustomers(Dummy);
                Console.WriteLine("PhotoNumber:");
                Operator.PrintTakeImage(DummyString);
                Console.Write("The Date is:");
                Console.WriteLine(DummyOutput.YearAccess.ToString() + ":" + DummyOutput.MonthAccess.ToString() + ":" + DummyOutput.DayAccess.ToString());
                for (int i = 0; i < 50; i++)
                {
                    Console.Write("=");
                }
                Console.WriteLine("");
            }
            TakeImage.Flush();
            TakeImage.Close();
        }
Ejemplo n.º 3
0
        static public TakeImage GetTakeImage(int No)
        {
            FileStream DummyFileStream = null;

            DummyFileStream = new FileStream(STakeImage, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read);
            int             p          = 0;
            TakeImage       Dummy      = null;
            BinaryFormatter Formatters = new BinaryFormatter();

            DummyFileStream.Seek(0, SeekOrigin.Begin);
            try
            {
                while (p <= No)
                {
                    if (DummyFileStream.Length >= DummyFileStream.Position)
                    {
                        Dummy = (TakeImage)Formatters.Deserialize(DummyFileStream);
                    }
                    else
                    {
                        Dummy = null;
                    }
                    p++;
                }
                DummyFileStream.Flush(); DummyFileStream.Close();
            }
            catch (SerializationException t)
            {
                Console.WriteLine(t.Message.ToString());
            }
            return(Dummy);
        }
Ejemplo n.º 4
0
        private void SetupImageButton()
        {
            using (
                var image =
                    UIImage.FromBundle("Icons/add_image.png")
                    .ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal))
            {
                PickImage.SetBackgroundImage(image, UIControlState.Normal);
            }

            using (
                var image2 =
                    UIImage.FromBundle("Icons/icon_camera.png")
                    .ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal))
            {
                TakeImage.SetBackgroundImage(image2, UIControlState.Normal);
            }

            using (
                var image3 =
                    UIImage.FromBundle("Icons/icon_mention.png")
                    .ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal))
            {
                MentionUser.SetBackgroundImage(image3, UIControlState.Normal);
            }
        }
Ejemplo n.º 5
0
        static public Customers[] GetCustomersFromDate(string[] Date, ref int Total)
        {
            TakeImage       DummyOutput = new TakeImage(0, null);
            FileStream      TakeImage   = new FileStream(STakeImage, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read);
            BinaryFormatter formatters  = new BinaryFormatter();

            Customers[] Dummy      = null;
            Customers[] DummyPhoto = new Customers[1000];
            TakeImage.Seek(0, SeekOrigin.Begin);
            Total = 0;
            int Dimention = -1;

            try
            {
                while (TakeImage.Position < TakeImage.Length)
                {
                    DummyOutput = (TakeImage)formatters.Deserialize(TakeImage);

                    if (DummyOutput.YearAccess.ToString() == Date[0])
                    {
                        if (DummyOutput.MonthAccess.ToString() == Date[1])
                        {
                            if (DummyOutput.DayAccess.ToString() == Date[2])
                            {
                                Dummy = Operator.GetCustomerFromPhotoNumberOfDate(DummyOutput.PhotoNumberAccess, ref Dimention);
                            }
                        }
                    }
                    if (Dimention > -1)
                    {
                        for (int i = Total; i < Total + Dimention; i++)
                        {
                            DummyPhoto[i] = Dummy[i - Total];
                        }
                        Total = Total + Dimention;
                    }
                    Dimention = -1;
                }
            }
            catch (SerializationException t)
            {
                Console.WriteLine(t.Message.ToString());
            }
            TakeImage.Flush();
            TakeImage.Close();
            return(DummyPhoto);
        }
Ejemplo n.º 6
0
        static public Photo[] GetPhotoFromPhotoNumberOfDate(int PhotoNumber, ref int Total)
        {
            FileStream DummyFileStream = null;

            Photo[] PhotoDummy      = null;
            Photo[] TotalPhotoDummy = new Photo[1000];
            Total = 0;
            int Dimension = -1;

            try
            {
                PhotoMemmorry t = new PhotoMemmorry();
                DummyFileStream = new FileStream(STakeImage, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read);
                BinaryFormatter Formatters = new BinaryFormatter();
                DummyFileStream.Seek(0, SeekOrigin.Begin);
                TakeImage DummyOutput = null;
                while (DummyFileStream.Position < DummyFileStream.Length)
                {
                    DummyOutput = (TakeImage)Formatters.Deserialize(DummyFileStream);
                    if (DummyOutput.PhotoNumberAccess == PhotoNumber)
                    {
                        PhotoDummy = Operator.GetPhotoFromPhotoFile(DummyOutput.PhotoNumberAccess, ref Dimension);
                        if (Dimension > -1)
                        {
                            for (int i = Total; i <= Total + Dimension; i++)
                            {
                                TotalPhotoDummy[i] = new Photo();
                                TotalPhotoDummy[i] = PhotoDummy[i - Total];
                            }
                            Total     = Total + Dimension + 1;
                            Dimension = -1;
                        }
                    }
                }
            }
            catch (SerializationException t)
            {
                Console.WriteLine(t.Message.ToString());
            }
            DummyFileStream.Flush(); DummyFileStream.Close();
            return(TotalPhotoDummy);
        }
Ejemplo n.º 7
0
    public IEnumerator visualizeSingleAction(Action a /*, System.Action<bool> result*/)
    {
        //displayText.text = "The Simulator is requesting the following Action: " + a.shortToString();
        //print(a.shortToString());

        switch (a.Name)
        {
        case "MOVE":

            NavMeshAgent agent = null;
            GameObject   rover;
            GameObject   destination     = null;
            string       destinationName = null;
            foreach (ActionParameter ap in a.Parameters)
            {
                if (ap.Role == ActionParameterRole.ACTIVE)
                {
                    //rover = GameObject.Find(ap.Name);
                    //agent = rover.GetComponent<NavMeshAgent>();
                    if (ap.Name == "ROVER1")
                    {
                        rover = rover1;
                    }
                    else
                    {
                        rover = rover2;
                    }
                    agent = rover.GetComponent <NavMeshAgent>();
                }

                //destinationName = a.Dest.Destination.Name;
            }
            foreach (IRelation r in a.PostConditions)
            {
                if (r.Predicate.Name == "AT" && r.Value == RelationValue.TRUE)
                {
                    BinaryRelation br = r as BinaryRelation;
                    destinationName = br.Destination.Name;
                }
            }
            foreach (GameObject waypoint in waypoints)
            {
                if (waypoint.name == destinationName)
                {
                    destination = waypoint.transform.gameObject;
                    destination.GetComponent <Renderer>().material = yellow;
                    if (destinationList != null)
                    {
                        destinationList.Add(destination);
                    }
                }
            }
            backUpStatus.name = agent.gameObject.name;
            backUpStatus.transform.position = agent.gameObject.transform.position;
            if (backUpStatusList != null)
            {
                backUpStatusList.Add(a, backUpStatus);
            }

            //print("PARENT NAME: " + rover.transform.parent.gameObject.transform.parent.gameObject);
            agent.SetDestination(destination.transform.position);
            if (agent.pathPending)
            {
                yield return(null);
            }
            float estimatedTime = 2.0f + agent.remainingDistance / agent.speed;
            if (estimatedTime > maximumWaitingTime)
            {
                maximumWaitingTime = estimatedTime;
            }
            estimatedTimeList.Add(estimatedTime);

            bool res = false;
            yield return(StartCoroutine(CheckMoveResult(agent, destination, estimatedTime, value => res = value)));

            actionResultList.Add(res);

            break;

        case "TAKE_SAMPLE":

            estimatedTime = 6f;
            if (estimatedTime > maximumWaitingTime)
            {
                maximumWaitingTime = estimatedTime;
            }
            estimatedTimeList.Add(estimatedTime);

            string     activeRover  = "";
            GameObject takeSample   = null;
            GameObject dropSample   = null;
            GameObject sampleNumber = null;
            foreach (ActionParameter ap in a.Parameters)
            {
                if (ap.Role == ActionParameterRole.ACTIVE)
                {
                    activeRover = ap.Name;
                    if (ap.Name == "ROVER1")
                    {
                        takeSample   = takeSampleRover1;
                        dropSample   = dropSampleRover1;
                        sampleNumber = sampleNumberRover1;
                    }
                    else
                    {
                        takeSample   = takeSampleRover2;
                        dropSample   = dropSampleRover2;
                        sampleNumber = sampleNumberRover2;
                    }
                    sampleNumberText = sampleNumber.GetComponent <TextMeshProUGUI>();
                }
            }
            backUpStatus.name = activeRover + " - take sample";
            backUpStatus.SetActive(takeSample.activeSelf);
            backUpStatusList.Add(a, backUpStatus);

            res = false;
            yield return(StartCoroutine(TakeSampleAnimation(activeRover, value => res = value)));

            if (res == true)
            {
                if (takeSample.activeSelf == false)
                {
                    takeSample.SetActive(true);
                }
                if (dropSample.activeSelf == true)
                {
                    dropSample.SetActive(false);
                }
                foreach (ActionParameter e in a.Parameters)
                {
                    if (e.Name.Substring(0, 6) == "SAMPLE")
                    {
                        sampleNumberText.text = e.Name.Substring(6, 1);
                    }
                }
                actionResultList.Add(true);
            }
            else
            {
                actionResultList.Add(false);
            }

            break;

        case "DROP_SAMPLE":

            estimatedTime = 2f;
            if (estimatedTime > maximumWaitingTime)
            {
                maximumWaitingTime = estimatedTime;
            }
            estimatedTimeList.Add(estimatedTime);

            activeRover  = "";
            takeSample   = null;
            dropSample   = null;
            sampleNumber = null;

            foreach (ActionParameter ap in a.Parameters)
            {
                if (ap.Role == ActionParameterRole.ACTIVE)
                {
                    activeRover = ap.Name;
                    if (ap.Name == "ROVER1")
                    {
                        takeSample   = takeSampleRover1;
                        dropSample   = dropSampleRover1;
                        sampleNumber = sampleNumberRover1;
                    }
                    else
                    {
                        takeSample   = takeSampleRover2;
                        dropSample   = dropSampleRover2;
                        sampleNumber = sampleNumberRover2;
                    }
                    sampleNumberText = sampleNumber.GetComponent <TextMeshProUGUI>();
                }
            }
            backUpStatus.name = activeRover + " - drop sample";
            backUpStatus.SetActive(dropSample.activeSelf);
            backUpStatusList.Add(a, backUpStatus);

            res = false;
            yield return(StartCoroutine(DropSampleAnimation(activeRover, value => res = value)));

            if (res == true)
            {
                if (takeSample.activeSelf == true)
                {
                    takeSample.SetActive(false);
                }
                if (dropSample.activeSelf == false)
                {
                    dropSample.SetActive(true);
                }

                sampleNumberText.text = "";
                actionResultList.Add(true);
            }
            else
            {
                actionResultList.Add(false);
            }

            //int outcome = Random.Range(0, 100);
            //if (outcome <= 70)
            //{
            //    if (dropSample.activeSelf == false)
            //    {
            //        dropSample.SetActive(true);
            //        sampleNumberText.text = null;
            //        actionResultList.Add(true);
            //    }
            //    if (takeSample.activeSelf == true)
            //        takeSample.SetActive(false);
            //}
            //else
            //{
            //    actionResultList.Add(false);
            //}

            break;

        case "TAKE_IMAGE":

            estimatedTime = 2f;
            if (estimatedTime > maximumWaitingTime)
            {
                maximumWaitingTime = estimatedTime;
            }
            estimatedTimeList.Add(estimatedTime);

            TakeImage ti = new TakeImage();
            foreach (ActionParameter ap in a.Parameters)
            {
                if (ap.Role == ActionParameterRole.ACTIVE)
                {
                    if (ap.Name == "ROVER1")
                    {
                        actionResultList.Add(ti.CaptureScreenshot(renderTextureRover1));
                    }
                    else
                    {
                        actionResultList.Add(ti.CaptureScreenshot(renderTextureRover2));
                    }
                }
            }

            break;

        case "IDLE":

            estimatedTime = 2f;
            if (estimatedTime > maximumWaitingTime)
            {
                maximumWaitingTime = estimatedTime;
            }
            estimatedTimeList.Add(estimatedTime);

            actionResultList.Add(true);

            break;

        case "CHARGE_BATTERY":

            estimatedTime = 2f;
            if (estimatedTime > maximumWaitingTime)
            {
                maximumWaitingTime = estimatedTime;
            }
            estimatedTimeList.Add(estimatedTime);

            actionResultList.Add(true);

            break;

        case "DISCHARGE_BATTERY":

            estimatedTime = 2f;
            if (estimatedTime > maximumWaitingTime)
            {
                maximumWaitingTime = estimatedTime;
            }
            estimatedTimeList.Add(estimatedTime);

            actionResultList.Add(true);

            break;

        case "INFLATE_WHEELS":

            estimatedTime = 2f;
            if (estimatedTime > maximumWaitingTime)
            {
                maximumWaitingTime = estimatedTime;
            }
            estimatedTimeList.Add(estimatedTime);

            actionResultList.Add(true);

            break;

        case "DEFLATE_WHEELS":

            estimatedTime = 2f;
            if (estimatedTime > maximumWaitingTime)
            {
                maximumWaitingTime = estimatedTime;
            }
            estimatedTimeList.Add(estimatedTime);

            actionResultList.Add(true);

            break;
        }
    }