void Awake()
    {
        current = this;

        //Create the other vehicles which we attach to the moise
        GameObject deadCarMouseObj             = Instantiate(car_marker.gameObject) as GameObject;
        GameObject deadSemiMouseObj            = Instantiate(semi_marker.gameObject) as GameObject;
        GameObject deadSemiWithTrailerMouseObj = Instantiate(semiWithTrailer_marker.gameObject) as GameObject;

        car_mouse             = deadCarMouseObj.transform;
        semi_mouse            = deadSemiMouseObj.transform;
        semiWithTrailer_mouse = deadSemiWithTrailerMouseObj.transform;

        startPos = car_selfDriving.position;
        startRot = car_selfDriving.rotation;
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        sim      = SimController.INSTANCE;
        distance = .9f * sim.radius;

        sun = sim.skyModel.GetSun();

        float size = 20.0f;        //transform.localScale.magnitude;

        transform.localScale = new Vector3(size, size, size);

        dirLight = GetComponent <Light> ();

        SetPosition();

        //Debug.Log("light pos -> "+ dirLight.transform.position.ToString ());
    }
示例#3
0
        private static void CreateSimFiles(string[] args)
        {
            string setInfoXmlPath, setName;

            try
            {
                setInfoXmlPath = args[1];
                setName        = args[2];
            }
            catch
            {
                Console.WriteLine("-s <setInfoXmlPath> <name>");
                return;
            }

            SimController.CreateSimFiles(setInfoXmlPath, setName);
        }
示例#4
0
        private static void CalculateEntropy(string[] args)
        {
            string setInfoXmlPath, ipdFilePath;

            try
            {
                setInfoXmlPath = args[1];
                ipdFilePath    = args[2];
            }
            catch
            {
                Console.WriteLine("-en <setInfoXmlPath> <ipdFilePath>");
                return;
            }

            SimController.CalculateEntropy(setInfoXmlPath, ipdFilePath);
        }
示例#5
0
        private static void ParseBinFrequencyFile(string[] args)
        {
            string resultsDir, rawBinFreqFile;

            try
            {
                resultsDir     = args[1];
                rawBinFreqFile = args[2];
            }
            catch (Exception)
            {
                Console.WriteLine("-pb <resultsDir> <rawBinFreqFile>");
                return;
            }

            SimController.ParseBinFrequencyFile(resultsDir, rawBinFreqFile);
        }
示例#6
0
        private static void CreateTestScript(string[] args)
        {
            string processDir, setInfoXmlPath;

            try
            {
                setInfoXmlPath = args[1];
                processDir     = args[2];
            }
            catch (Exception)
            {
                Console.WriteLine("-ct <setInfoXmlPath> <processDir>");
                return;
            }

            SimController.CreateTestScript(setInfoXmlPath, processDir);
        }
示例#7
0
        private static void TestResults(string[] args)
        {
            string resultsDir, captureIpdFileIdent, setInfoXmlPath;

            try
            {
                setInfoXmlPath      = args[1];
                resultsDir          = args[2];
                captureIpdFileIdent = args[3];
            }
            catch (Exception)
            {
                Console.WriteLine("-tr <setInfoXmlPath> <resultsDirectory> <captureIpdFileIdentifier>");
                return;
            }

            SimController.TestResults(resultsDir, captureIpdFileIdent, setInfoXmlPath);
        }
示例#8
0
        private static void ParseIPDS_TraceFile(string[] args)
        {
            string processDir, traceFileIdent, outputFileIdent, sourceIpIdent, setInfoXmlPath;

            try
            {
                processDir      = args[1];
                traceFileIdent  = args[2];
                outputFileIdent = args[3];
                sourceIpIdent   = args[4];
                setInfoXmlPath  = args[5];
            }
            catch (Exception)
            {
                Console.WriteLine("-pt <processDir> <traceFileIdentifier> <outputFileIdentifier> <sourceIpIdent> <setInfoXmlPath>");
                return;
            }

            SimController.ParseIPDS_TraceFile(processDir, traceFileIdent, outputFileIdent, sourceIpIdent, setInfoXmlPath);
        }
    void setTargetNode()
    {
        if (currentNode.ways.Count != 0)
        {
            // have to randomize them later.
            Vector3 targetPosition = currentNode.ways[Random.Range(0, currentNode.ways.Count)];

            // if there are multiple path connect give less weightage to where car came from..
            if (currentNode.ways.Count > 1)
            {
                bool accept = false;
                while (!accept)
                {
                    if (targetPosition == previousLocation)
                    {
                        int chance = Random.Range(0, 5);
                        if (chance == 3)
                        {
                            accept = true;
                        }
                        else
                        {
                            targetPosition = currentNode.ways[Random.Range(0, currentNode.ways.Count)];
                        }
                    }
                    else
                    {
                        accept = true;
                    }
                }
            }
            List <Node> nodeList = SimController.nodeList;
            targetNode = nodeList.Find(node => (node.location == targetPosition));
        }
        else
        {
            targetNode = currentNode;
        }

        speedReductionFactor = SimController.getRoadTraffic(targetNode.location, currentNode.location);
    }
示例#10
0
    void addCarToRoadAndNodeList()
    {
        MPACColonyRoadList = new List <Road> ();
        MPACColonyNodeList = new List <Node> ();
        foreach (Road road in SimController.roadList)
        {
            MPACColonyRoadList.Add(road);
        }

        //// NODE LIST
        foreach (Node node in SimController.nodeList)
        {
            Node      n    = new Node(node.location);
            Vector3[] ways = (Vector3[])node.ways.ToArray().Clone();
            n.ways.AddRange(ways);
            MPACColonyNodeList.Add(n);
        }

        // add all the cars on the map as seperate roads...
        foreach (GameObject car in CarGenerator.carList)
        {
            Vector3 carTarget  = car.transform.GetComponent <carController_new> ().targetNode.location;
            Vector3 carCurrent = car.transform.GetComponent <carController_new> ().currentNode.location;
            // add the road from car to target node....
            Road  r           = new Road(car.transform.position, carTarget);
            float trafficLoad = SimController.getRoadTraffic(carTarget, carCurrent);
            r.TrafficLoad = trafficLoad;
            MPACColonyRoadList.Add(r);

            // add a new node for car and set only one way to the target location.
            Node carNode = new Node(car.transform.position);
            carNode.ways.Add(carTarget);
            MPACColonyNodeList.Add(carNode);
            // add a new way to car in the target node...
            int carTargetIndex = MPACColonyNodeList.FindIndex(node => node.location == carTarget);
            MPACColonyNodeList [carTargetIndex].ways.Add(car.transform.position);
        }
    }
示例#11
0
    // Use this for initialization
    void Start()
    {
        sim      = SimController.INSTANCE;
        skyModel = sim.skyModel;


        LocationSettings location = sim.GetLocation();
        double           angle    = 90.0d - location.Latitude;

        earthAxis = new Vector3(0.0f, (float)Math.Sin(angle * M.DEG2RAD), (float)Math.Cos(angle * M.DEG2RAD));

        Quaternion q = Quaternion.Euler((float)angle, 0, 0);

        gameObject.transform.localRotation = q;


        //correction for hour angle
        //TODO



        Debug.Log(string.Format("Angle {0}", angle));
        Debug.Log(string.Format("Quaternion {0}", q));
    }
 // Use this for initialization
 void Start()
 {
     sim      = SimController.INSTANCE;
     skyModel = sim.skyModel;
     go       = new GameObject();
 }
示例#13
0
        //This event fires when a menu item or toolbar button is clicked.  So if you added a button or menu
        //on the Initialize event, then this is where you would handle it.
        public void ItemClicked(string ItemName, ref bool Handled)
        {
            if (ItemName == this.strBTNRun)
            {
                //显示仿真窗口
                //scConvas.Show();
                this.convas.Show();
                // SimController.Run();
                SimController.StartSimulate();
                Handled             = true;
                TBTN_Config.Enabled = false;
                TBTN_Pause.Enabled  = true;

                TBTN_ChartMeanSpeed.Enabled = false;
                TBTN_ChartSpaceTime.Enabled = false;
                TBTN_ChartSpeedTime.Enabled = false;
                TBTN_ShowData.Enabled       = false;
            }

            if (ItemName == this.strBTNConfig)
            {
                TBTN_Run.Enabled   = true;
                TBTN_Pause.Enabled = true;
                this.convas        = this.mMapWin.UIPanel.CreatePanel("TranSimGIS", MapWindowDockStyle.Right);


                TrafficSim.SimConfig cs = new TrafficSim.SimConfig();
                if (cs.ShowDialog() == DialogResult.OK)
                {
//                    SimController.iMobileCount = cs.iCarCount;

//                    SimController.iSimInterval = cs.iSimSpeed;
//                    ModelSetting.dRate = cs.dRatio;
//                    ModelSetting. = cs.dRatio;
//.i = cs.iCellWidth;
                }
                cs.Dispose();


//                SimController.ConfigSimEnvironment(this.convas);
                TBTN_Config.Enabled = false;
                TBTN_Pause.Enabled  = true;

                Handled = true;
            }

            //暂停
            if (ItemName == this.strBTNPause)
            {
                //SimController.IsPause = true;
                SimController.bIsExit = true;

                TBTN_Run.Enabled = true;

                TBTN_ChartMeanSpeed.Enabled = true;
                TBTN_ChartSpaceTime.Enabled = true;
                TBTN_ChartSpeedTime.Enabled = true;
                TBTN_ShowData.Enabled       = true;

                TBTN_Config.Enabled = false;
                Handled             = true;
            }
            //平均速度
            if (ItemName == this.strBTNMeanSpeed)
            {
                MeanSpeed msc = new MeanSpeed();
                msc.Show();
                Handled = true;
            }
            //时间空间图
            if (ItemName == this.strBTNSpaceTime)
            {
                TimeSpace tsc = new TimeSpace();
                tsc.Show();
                Handled = true;
            }
            //速度时间图
            if (ItemName == this.strBTNSpeedTime)
            {
                SpeedTime st = new SpeedTime();
                st.Show();
                Handled = true;
            }

            //速度时间图
            if (ItemName == this.strBTNShowData)
            {
                DataOutputer dop = new DataOutputer();
                dop.Show();
                Handled = true;
            }
        }
    public void RunDay()
    {
        int      i, j;
        Delivery delivery;

        UnityEngine.Debug.Log("Before RunDay: " + SimController.DayNum);

        // print shifts
        UnityEngine.Debug.Log("Shifts:");
        for (i = 0; i < 3; i++)
        {
            UnityEngine.Debug.Log("Shift" + (i + 1) + " --> " + ((ShiftInfo)Shifts[i]).ToString());
        }
        // print deliveries
        for (i = 0; i < Deliveries.Count; i++)
        {
            Delivery temp = (Delivery)Deliveries[i];
            UnityEngine.Debug.Log("Delivery Item: " + temp.foodItem.Name + " Quantity: " + temp.Quantity + " Exp: " + temp.Expedited + " ArrivalDate: " + temp.ArrivalDate);
        }
        // print BOH stock
        for (i = 0; i < Stock.Count; i++)
        {
            FoodItem food = (FoodItem)Stock[i];
            UnityEngine.Debug.Log("BOH " + food.Name + ": " + food.StockBOH);
        }

        // simulate day
        DailyEmployeePayout = 0.0m;
        DailyDeliveryCost   = 0.0m;
        DailyRevenue        = 0;
        ShiftRevenue        = new decimal[3];
        DailyItemsSold      = 0;
        ShiftItemsSold      = new int[3];
        RegUT          = new double[3];
        StartOfDayCash = Cash;

        for (i = 0; i < 3; i++)
        {
            ShiftRevenue[i]   = 0;
            ShiftItemsSold[i] = 0;
        }
        CheckoutsPerformed = 0;
        CheckoutsPossible  = 0;
        DeliveriesOrdered  = 0;
        // pay for deliveries ordered today
        for (i = 0; i < Deliveries.Count; i++)
        {
            delivery = (Delivery)Deliveries[i];

            // check for expedited is redundant (thus not here)
            if (delivery.OrderDate == SimController.DayNum)
            {
                Cash -= delivery.Cost;
                DailyDeliveryCost += delivery.Cost;
                DeliveriesOrdered++;
            }
        }

        // get standard deliveries
        for (i = 0; i < Deliveries.Count; i++)
        {
            delivery = (Delivery)Deliveries[i];

            // check for expedited is redundant (thus not here)
            if (delivery.ArrivalDate == SimController.DayNum && delivery.Expedited)
            {
                ProcessDelivery(delivery.foodItem, delivery.Quantity);
                Deliveries.RemoveAt(i);
                i--;
            }
        }

        // For each shift
        for (i = 0; i < 3; i++)
        {
            Store.ShiftInfo shift = (Store.ShiftInfo)Shifts[i];

            // pay employees
            DailyEmployeePayout += (decimal)shift.TotalEmployees * HourlyPay;

            // 1. process expedited deliveries --> Expedited deliveries come during shift 2
            if (i == 1)
            {
                for (j = 0; j < Deliveries.Count; j++)
                {
                    delivery = (Delivery)Deliveries[j];

                    // check for expedited is redundant (thus not here)
                    if (delivery.ArrivalDate == SimController.DayNum)
                    {
                        ProcessDelivery(delivery.foodItem, delivery.Quantity);
                        Deliveries.RemoveAt(j);
                        j--;
                    }
                }
            }

            // 2. restock before "shift"
            Restock(i);

            // 3. during shift, people buy goods
            // modeled closely to Real-Time AR tablet logic
            // IMPORTANT: if Simulation.TimeBetweenCheckouts == 10, numCheckoutsPerHour MUST equal 6
            //               for checkouts to be balanced
            for (j = 0; j < NUM_CHECKOUTS_PER_HOUR; j++)
            {
                PullItemsOffShelves(i);
                checkoutFoods(i);
            }

            // items that are not checked out but are brought to registers need to be returned
            ReturnItemsToShelves();

            RegUT[i] = 100.0 * CheckoutsPerformed / CheckoutsPossible;

            UnityEngine.Debug.Log("Register UT for shift " + (i + 1) + " is " + RegUT[i]);

            // 4. restock after "shift"
            Restock(i);
        }

        // expire foods
        ExpireFoods();

        // print BOH stock
        UnityEngine.Debug.Log("After RunDay" + SimController.DayNum);
        for (i = 0; i < Stock.Count; i++)
        {
            FoodItem food = (FoodItem)Stock[i];
            UnityEngine.Debug.Log("BOH " + food.Name + ": " + food.StockBOH);
        }

        // Deduct today's orders (set by SetDeliveries() )
        Cash -= DeliveryCost;

        Cash -= DailyEmployeePayout;
        UnityEngine.Debug.Log("Cash: " + Cash);

        // load PostDayReport
        SimController.LoadResults();
    }
示例#15
0
 void Awake()
 {
     sim  = SimController.INSTANCE;
     moon = sim.skyModel.GetMoon();
 }