Exemplo n.º 1
0
 public Stacker_Port_ForkIn(MissionType missionType, string conveyorName, Direction_ Direction_) : base(conveyorName, Direction_)
 {
     if (missionType.Equals(MissionType.ProdIn) || missionType.Equals(MissionType.BackIn) || missionType.Equals(MissionType.PalletIn) || missionType.Equals(MissionType.AddPallet))
     {
         SetPos(GetBackPos(conveyorName), GetFrontPos(conveyorName));
     }
     else if (missionType.Equals(MissionType.ProdOut) || missionType.Equals(MissionType.PalletOut) || missionType.Equals(MissionType.GetPallet))
     {
         SetPos(GetBackPos(conveyorName), GetFrontPos(conveyorName));
     }
     SetSpeed();
 }
    //Function calculates the distance in meters from current location (lat lon)
    float Haversine(ref float lastLatitude, ref float lastLontitude, ref float bearing, ref float x, ref float y)
    {
        float newLatitude  = 0;
        float newLontitude = 0;

        x = 0; y = 0;

        //Get coordinates from GPS/given route:
        GetCoordinates(ref newLatitude, ref newLontitude, IsSimMode, ref route_index);
        //Check if location has changed:
        CheckLocationChanged(newLatitude, lastLatitude, newLontitude, lastLontitude);

        Location curr_loc = new Location();

        curr_loc.lat = lastLatitude;
        curr_loc.lng = lastLontitude;

        Location next_loc = new Location();

        next_loc.lat = newLatitude;
        next_loc.lng = newLontitude;

        Direction_ Direction = new Direction_();

        //Calculate the direction and distance:
        GetDirection(ref curr_loc, ref next_loc, ref Direction);
        x = Direction.x;
        y = Direction.y;

        if (LocationChanged())
        {
            //If location changed, updated the bearing:
            bearing        = Direction.bearing;
            approx_bearing = bearing;
        }
        else //Assume the same bearing as before:
        {
            bearing = approx_bearing;
        }

        lastLatitude  = newLatitude;
        lastLontitude = newLontitude;

        return(Direction.distance);
    }
    //Get direction from pt. of origin to target :
    //distance[km] and bearing[deg from north] from pt of origin to target location:
    void GetDirection(ref Location Location_source,
                      ref Location Location_target, ref Direction_ DirToTarget)
    {
        float lat2 = (float)Location_target.lat;
        float lat1 = (float)Location_source.lat;
        float lon2 = (float)Location_target.lng;
        float lon1 = (float)Location_source.lng;


        float R  = EARTH_RADIUS; // metres
        float φ1 = lat1 * Mathf.Deg2Rad;
        float φ2 = lat2 * Mathf.Deg2Rad;
        float λ1 = lon1 * Mathf.Deg2Rad;
        float λ2 = lon2 * Mathf.Deg2Rad;

        float Δφ = (lat2 - lat1) * Mathf.Deg2Rad;
        float Δλ = (lon2 - lon1) * Mathf.Deg2Rad;

        float a = Mathf.Sin(Δφ / 2) * Mathf.Sin(Δφ / 2) +
                  Mathf.Cos(φ1) * Mathf.Cos(φ2) *
                  Mathf.Sin(Δλ / 2) * Mathf.Sin(Δλ / 2);
        float c = 2 * Mathf.Atan2(Mathf.Sqrt(a), Mathf.Sqrt(1 - a));
        float d = R * c;

        DirToTarget.distance = d;//distance in km

        //Calculate the bearing:
        //where φ1, λ1 is the start point, φ2,λ2 the end point(Δλ is the difference in longitude)

        float y = Mathf.Sin(λ2 - λ1) * Mathf.Cos(φ2);
        float x = Mathf.Cos(φ1) * Mathf.Sin(φ2) -
                  Mathf.Sin(φ1) * Mathf.Cos(φ2) * Mathf.Cos(λ2 - λ1);
        float brng = Mathf.Atan2(y, x) * Mathf.Rad2Deg;

        DirToTarget.bearing = brng;  //bearing in [deg]
        DirToTarget.x       = x * R; //[x in km]
        DirToTarget.y       = y * R; //[y in km]
    }
Exemplo n.º 4
0
 public Conveyor_V(MissionType missionType, string conveyorName, Direction_ Direction_) : base(conveyorName, Direction_)
 {
     try
     {
         SetSpeed();
         if (missionType.Equals(MissionType.ProdIn) || missionType.Equals(MissionType.BackIn) || missionType.Equals(MissionType.PalletIn) || missionType.Equals(MissionType.AddPallet))
         {
             SetPos(GetBackPos(conveyorName), GetFrontPos(conveyorName));
         }
         else if (missionType.Equals(MissionType.ProdOut) || missionType.Equals(MissionType.PalletOut) || missionType.Equals(MissionType.GetPallet))
         {
             SetPos(GetFrontPos(conveyorName), GetBackPos(conveyorName));
         }
         else
         {
             throw new Exception("Conveyor_V has exception: Undefined MissionType");
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.ToString());
     }
 }
Exemplo n.º 5
0
        public static Conveyor GetConveyor(string conveyorName, MissionType missionType, string startShelfNo, string endShelfNo, Direction_ Direction_, ModelPosition modelPosition)
        {
            Conveyor conveyor = null;

            switch (Direction_)
            {
            case Direction_.Roadway:
                conveyor = new Stacker_RoadWay(missionType, conveyorName, startShelfNo, endShelfNo, modelPosition, Direction_);
                break;
            }
            return(conveyor);
        }
Exemplo n.º 6
0
 public Stacker_ShelfOut(MissionType missionType, string conveyorName, string shelfNo, ModelPosition modelPosition, Direction_ direction) : base(conveyorName, direction)
 {
     SetPos(modelPosition.GetShelfPos(shelfNo), modelPosition.GetShelfLinePos(shelfNo));
     SetSpeed();
 }
Exemplo n.º 7
0
 public Stacker_RoadWay(MissionType missionType, string conveyorName, string startShelfNo, string endShelfNo, ModelPosition modelPosition, Direction_ Direction_) : base(conveyorName, Direction_)
 {
     SetPos(modelPosition.GetShelfLinePos(startShelfNo), modelPosition.GetShelfLinePos(endShelfNo));
     SetSpeed();
 }
Exemplo n.º 8
0
 public Stacker_RoadWay(MissionType missionType, string conveyorName, string shelfNo, ModelPosition modelPosition, Direction_ Direction_) : base(conveyorName, Direction_)
 {
     if (missionType.Equals(MissionType.ProdIn) || missionType.Equals(MissionType.BackIn) || missionType.Equals(MissionType.PalletIn))
     {
         SetPos(GetLeftBottomPos(conveyorName), modelPosition.GetShelfLinePos(shelfNo));
     }
     else if (missionType.Equals(MissionType.ProdOut) || missionType.Equals(MissionType.PalletOut) || missionType.Equals(MissionType.GetPallet))
     {
         SetPos(modelPosition.GetShelfLinePos(shelfNo), GetLeftBottomPos(conveyorName));
     }
     SetSpeed();
 }
Exemplo n.º 9
0
 public Stacker_Port(MissionType missionType, string conveyorName, Direction_ Direction_) : base(conveyorName, Direction_)
 {
     SetPos(GetBackPos(conveyorName), GetFrontPos(conveyorName));
     SetSpeed();
 }
Exemplo n.º 10
0
        public static Conveyor GetConveyor(string conveyorName, MissionType missionType, string shelfNo, Direction_ Direction, ModelPosition modelPosition)
        {
            Conveyor conveyor = null;

            switch (Direction)
            {
            case Direction_.Vertical:
                conveyor = new Conveyor_V(missionType, conveyorName, Direction);
                break;

            case Direction_.Horizontal:
                conveyor = new Conveyor_H(missionType, conveyorName, Direction);
                break;

            case Direction_.Roadway:
                conveyor = new Stacker_RoadWay(missionType, conveyorName, shelfNo, modelPosition, Direction);
                break;

            case Direction_.PortIn:
                conveyor = new Stacker_Port(missionType, conveyorName, Direction);
                break;

            case Direction_.PortOut:
                conveyor = new Stacker_Port(missionType, conveyorName, Direction);
                break;

            case Direction_.ShelfOut:
                conveyor = new Stacker_ShelfOut(missionType, conveyorName, shelfNo, modelPosition, Direction);
                break;

            case Direction_.ShelfIn:
                conveyor = new Stacker_ShelfIn(missionType, conveyorName, shelfNo, modelPosition, Direction);
                break;
            }
            return(conveyor);
        }
Exemplo n.º 11
0
        protected List <IMission> missions = new List <IMission>();//观察者列表  任务观察 输送带

        public Conveyor(string name, Direction_ Direction)
        {
            this.Name      = name;
            this.Direction = Direction;
        }
Exemplo n.º 12
0
    // Initialization of the Player:
    void Start()
    {
        //Location of our home:
        //wpt lat = "32.09834" lon = "34.97702"

        //Location of Safta miriam:
        //< wpt lat = "32.09363" lon = "34.88043" >

        //IsSimMode = false;
        //Start locations services:
        Input.location.Start();

        //Set initial location:
        GetCoordinates(ref latitude, ref longitude, IsSimMode, ref route_index);

        delta_loc_time_changed = 0; // reset the  accumulative delta time
                                    //var result = GetClosestAttraction(latitude, longitude);

        //Initialize the current attraction:
        Closest_attraction       = new Attraction();
        Closest_attraction.valid = false;
        DirectionToTarget        = new Direction_();

        //Set the initial state of the camera:
        SetLocVRObj(0, 0, "Player1");
        SetLocVRObj(0, 0, "MainCamera");


        //Create home:
        Location home_loc = new Location();

        home_loc.lat = 32.09834; home_loc.lng = 34.97702;
        //GetDirection(ref home_loc, ref home_loc, ref DirectionToTarget);
        //StartCoroutine(CreateAttractionInVR(0, 0, "Home"));
        SetLocVRObj(0, 0, "Home");

        //Create Safta home:
        Location tmp_loc = new Location();

        tmp_loc.lat = 32.09363; tmp_loc.lng = 34.88043;
        GetDirection(ref home_loc, ref tmp_loc, ref DirectionToTarget);
        SetLocVRObj(DirectionToTarget.x, DirectionToTarget.y, "Safta");
        //StartCoroutine(CreateAttractionInVR(DirectionToTarget.x, DirectionToTarget.y, "Safta"));

        //Create Sagive coodinates:
        //wpt lat = "32.09881" lon = "34.97494" >
        tmp_loc.lat = 32.09881; tmp_loc.lng = 34.97494;
        GetDirection(ref home_loc, ref tmp_loc, ref DirectionToTarget);
        //StartCoroutine(CreateAttractionInVR(DirectionToTarget.x, DirectionToTarget.y, "Grass"));
        SetLocVRObj(DirectionToTarget.x, DirectionToTarget.y, "Grass");

        //Get closest attraction:
        //GetClosestAttraction(latitude, longitude, ref Closest_attraction);
        StartCoroutine(GetClosestAttraction(latitude, longitude));

        GetClosestAttraction(latitude, longitude);
        CurrentLoc.lat = latitude; CurrentLoc.lng = longitude;

        if (Closest_attraction.valid)
        {
            //Get direction to target:
            GetDirection(ref CurrentLoc, ref Closest_attraction.location, ref DirectionToTarget);
            StartCoroutine(CreateAttractionInVR(DirectionToTarget.x, DirectionToTarget.y, "Billboard110"));
            //CreateAttractionInVR(DirectionToTarget.x, DirectionToTarget.y);
        }
    }