Esempio n. 1
0
        private void UpdateHeading(CShipHlaObject ship)
        {
            // Add Values
            ship.AddAttributeValue(Som.ShipOC.Heading, (uint)ship.Ship.Heading);
            UpdateAttributeValues(ship);

            // Update attribute using a logical timestamp
            //EventRetractionHandle handle = UpdateAttributeValues(user, 3.14);
        }
Esempio n. 2
0
 // Update attribute values
 private void UpdateAll(CShipHlaObject ship)
 {
     // Add Values
     ship.AddAttributeValue(Som.ShipOC.Callsign, ship.Ship.Callsign);
     ship.AddAttributeValue(Som.ShipOC.Heading, (uint)ship.Ship.Heading);
     ship.AddAttributeValue <PositionType>(Som.ShipOC.Position, ship.Ship.Position);
     ship.AddAttributeValue(Som.ShipOC.Speed, (uint)ship.Ship.Speed);
     UpdateAttributeValues(ship);
 }
Esempio n. 3
0
        // Set ship configuration
        private static void setShipConfiguration()
        {
            //Console.ForegroundColor = ConsoleColor.Yellow;
            //Console.WriteLine();
            //Console.Write("Enter Callsign: ");
            //ship.Callsign = Console.ReadLine();
            //int pos = 0;
            //do
            //{
            //  Console.Write("Enter Initial Location (0-west, 1-east): ");
            //  int.TryParse(Console.ReadLine(), out pos);
            //} while ((pos != 0) && (pos != 1));
            //ship.Heading = (LocationEnum)((pos == 0) ? 1 : 0); // heading is the reverse of position
            //ship.Location = (LocationEnum)(pos);
            //if (pos == 0)
            //{
            //  ship.Position.X = -10;
            //  ship.Position.Y = -1;
            //}
            //else
            //{
            //  ship.Position.X = 10;
            //  ship.Position.Y = 1;
            //}
            //int sp;
            //do
            //{
            //  Console.Write("Enter Speed (0-very slow, 1-slow, 2-fast, 3-very fast): ");
            //  int.TryParse(Console.ReadLine(), out sp);
            //} while ((sp < 0) || (sp > 3));
            //Console.WriteLine();
            //ship.Speed = (SpeedEnum)sp;

            // Initialization with default settings
            ship.Callsign   = "Ship-" + DateTime.Now.Second.ToString();
            ship.Heading    = LocationEnum.West;
            ship.Position.X = 10;
            ship.Position.Y = 1;
            ship.Speed      = SpeedEnum.VerySlow;
            ship.Location   = LocationEnum.East;

            // Encapsulate own ship and add to list
            CShipHlaObject encapsulatedShipObject = new CShipHlaObject(manager.federate.Som.ShipOC);

            encapsulatedShipObject.Ship = ship;
            manager.ShipObjects.Add(encapsulatedShipObject);
        }
Esempio n. 4
0
        public override void FdAmb_ObjectDiscoveredHandler(object sender, HlaObjectEventArgs data)
        {
            // Call the base class handler
            base.FdAmb_ObjectDiscoveredHandler(sender, data);

            #region User Code
            // Check the class type of the discovered object
            if (data.ClassHandle == Som.ShipOC.Handle) // A ship
            {
                // Create and add a new ship to the list
                CShipHlaObject newShip = new CShipHlaObject(data.ObjectInstance);
                newShip.Type = Som.ShipOC;// if user forgets to set type of the object, then an exception generated
                manager.ShipObjects.Add(newShip);

                // Request Update Values of Attributes
                // (1) Request update values of all attributes for a specific object instance
                //RequestAttributeValueUpdate(newShip);


                // (2) Request an update for all attribute values of all object instances of a specific object class
                //RequestAttributeValueUpdate(Som.ShipOC);

                // (3) Request Update Values for specific attributes only
                List <HlaAttribute> attributes = new List <HlaAttribute>();
                attributes.Add(Som.ShipOC.Callsign);
                RequestAttributeValueUpdate(newShip, attributes);
            }
            else if (data.ClassHandle == Som.StationOC.Handle) // A station
            {
                // Create and add a new station to the list
                CStationHlaObject newStation = new CStationHlaObject(data.ObjectInstance);
                newStation.Type = Som.StationOC;
                manager.StationObjects.Add(newStation);

                // Request Update Values of Attributes
                RequestAttributeValueUpdate(newStation);
            }
            #endregion //User Code
        }
Esempio n. 5
0
        public override void FdAmb_ObjectDiscoveredHandler(object sender, HlaObjectEventArgs data)
        {
            // Call the base class handler
            base.FdAmb_ObjectDiscoveredHandler(sender, data);

            #region User Code
            // Check the class type of the discovered object
            if (data.ClassHandle == Som.ShipOC.Handle) // A ship
            {
                // Create and add a new ship to the list
                CShipHlaObject newShip = new CShipHlaObject(data.ObjectInstance);
                newShip.Type = Som.ShipOC;
                Program.ShipObjects.Add(newShip);
                // Create a new track
                CTrackHlaObject track = new CTrackHlaObject(Som.TrackOC);
                track.TrackNo = data.ObjectInstance.Handle;
                Program.MyTracks.Add(track);
                // hook to track event
                track.OutOfZone += HandleTrackOutOfZone;
                // Request Update Values of Attributes
                RequestAttributeValueUpdate(newShip);
                // register the track object
                RegisterHlaObject(track);
            }
            else if (data.ClassHandle == Som.StationOC.Handle) // A station
            {
                // Create and add a new ship to the list
                CStationHlaObject newStation = new CStationHlaObject(data.ObjectInstance);
                newStation.Type = Som.StationOC;
                Program.StationObjects.Add(newStation);

                // Request Update Values of Attributes
                // (1) Request update values of all attributes for a specific object instance
                RequestAttributeValueUpdate(newStation);
            }
            #endregion //User Code
        }
Esempio n. 6
0
 private void UpdateSpeed(CShipHlaObject ship)
 {
     // Add Values
     ship.AddAttributeValue(Som.ShipOC.Speed, (uint)ship.Ship.Speed);
     UpdateAttributeValues(ship);
 }
Esempio n. 7
0
 public void UpdatePosition(CShipHlaObject ship)
 {
     // Add Values
     ship.AddAttributeValue <PositionType>(Som.ShipOC.Position, ship.Ship.Position);
     UpdateAttributeValues(ship);
 }
Esempio n. 8
0
 private void UpdateName(CShipHlaObject ship)
 {
     // Add Values
     ship.AddAttributeValue(Som.ShipOC.Callsign, ship.Ship.Callsign);
     UpdateAttributeValues(ship);
 }