示例#1
0
        public Timer(SystemClock clock, Interconnect interconnect, InterruptController interruptController)
            : base(clock)
        {
            _interruptController = interruptController;

            interconnect.AddAddressHandler(0xFF04, 0xFF07, this);
        }
示例#2
0
        /// <summary>
        /// Generates a path around a turn
        /// </summary>
        /// <param name="initial"></param>
        /// <param name="final"></param>
        /// <param name="turn"></param>
        /// <param name="vehicleState"></param>
        /// <param name="vehicleRelative"></param>
        /// <returns></returns>
        public static IPath TurnPath(Lane initial, Lane final, Interconnect turn, VehicleState vehicleState, bool vehicleRelative)
        {
            // 1. list of absolute positions of lane coordinates
            List <Coordinates> absoluteCoordinates = new List <Coordinates>();

            // make sure not turning onto same lane
            if (!initial.LaneID.Equals(final.LaneID))
            {
                // 2. loop through initial lane's waypoints
                absoluteCoordinates.AddRange(GetLaneWaypointCoordinates(initial, true));

                // 3. check if the turn has user partitions
                if (turn.UserPartitions != null)
                {
                    // 3.1 loop through turn's waypoints if not rndfwaypoints (As will be included by lane coordinate generation
                    foreach (UserPartition partition in turn.UserPartitions)
                    {
                        // add if not an rndf waypoint
                        if (!(partition.InitialWaypoint is RndfWayPoint))
                        {
                            // add user waypoint's position
                            absoluteCoordinates.Add(partition.InitialWaypoint.Position);
                        }
                    }
                }

                // 4. add the next lane's waypoints
                absoluteCoordinates.AddRange(GetLaneWaypointCoordinates(final, true));
            }
            else
            {
                // get lanegth of lane / 4
                // HACK
                double length = RoadToolkit.LanePath(initial, vehicleState, true).Length / 4;

                // 2. loop through initial lane's waypoints
                absoluteCoordinates.AddRange(GetLaneWaypointCoordinates(initial, true, length, false));

                // 3. check if the turn has user partitions
                if (turn.UserPartitions != null)
                {
                    // 3.1 loop through turn's waypoints if not rndfwaypoints (As will be included by lane coordinate generation
                    foreach (UserPartition partition in turn.UserPartitions)
                    {
                        // add if not an rndf waypoint
                        if (!(partition.InitialWaypoint is RndfWayPoint))
                        {
                            // add user waypoint's position
                            absoluteCoordinates.Add(partition.InitialWaypoint.Position);
                        }
                    }
                }

                // 4. loop through final lane's waypoints
                absoluteCoordinates.AddRange(GetLaneWaypointCoordinates(final, true, length, true));
            }

            // 5. Generate path
            return(GeneratePathFromCoordinates(absoluteCoordinates, vehicleState.Position, vehicleState.Heading, vehicleRelative));
        }
示例#3
0
        public MasterSystem()
        {
            Clock        = new SystemClock();
            Interconnect = new Interconnect();

            CPU = new Z80(Clock, Interconnect);
        }
示例#4
0
        private uint _vblankClock;                  // counter of clock cycles elapsed in current scanline in vblank

        public LCDController(SystemClock clock, Interconnect interconnect, InterruptController interruptController, IVideoFrameSink frameSink)
            : base(clock)
        {
            _interconnect        = interconnect;
            _interruptController = interruptController;
            _frameSink           = frameSink;

            _interconnect.AddAddressHandler(0xFF40, 0xFF4B, this); // control registers
            _interconnect.AddAddressHandler(0x8000, 0x9FFF, this); // vram
            _interconnect.AddAddressHandler(0xFE00, 0xFE9F, this); // oam

            _screenData = new byte[ScreenWidth * ScreenHeight];

            _vram = new byte[0x2000];

            _tileCache = new byte[384][];

            for (int i = 0; i < _tileCache.Length; i++)
            {
                _tileCache[i] = new byte[64];
            }

            _tileCacheInvalid = new bool[384];

            _oam    = new byte[0xA0];
            _oamDma = default(OamDma);

            _backgroundPalette = new byte[4];

            _spritePalette = new byte[2][]
            {
                new byte[4],
                new byte[4]
            };
        }
示例#5
0
        /// <summary>Snippet for PatchAsync</summary>
        public async Task PatchAsync()
        {
            // Snippet: PatchAsync(string, string, Interconnect, CallSettings)
            // Additional: PatchAsync(string, string, Interconnect, CancellationToken)
            // Create client
            InterconnectsClient interconnectsClient = await InterconnectsClient.CreateAsync();

            // Initialize request argument(s)
            string       project              = "";
            string       interconnect         = "";
            Interconnect interconnectResource = new Interconnect();
            // Make the request
            lro::Operation <Operation, Operation> response = await interconnectsClient.PatchAsync(project, interconnect, interconnectResource);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Operation result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            lro::Operation <Operation, Operation> retrievedResponse = await interconnectsClient.PollOncePatchAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
示例#6
0
        /// <summary>Snippet for Insert</summary>
        public void Insert()
        {
            // Snippet: Insert(string, Interconnect, CallSettings)
            // Create client
            InterconnectsClient interconnectsClient = InterconnectsClient.Create();
            // Initialize request argument(s)
            string       project = "";
            Interconnect interconnectResource = new Interconnect();
            // Make the request
            lro::Operation <Operation, Operation> response = interconnectsClient.Insert(project, interconnectResource);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Operation result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            lro::Operation <Operation, Operation> retrievedResponse = interconnectsClient.PollOnceInsert(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
示例#7
0
        public InputController(Interconnect interconnect, InterruptController interruptController, IInputSource inputSource)
        {
            _interruptController = interruptController;
            _inputSource         = inputSource;

            interconnect.AddAddressHandler(0xFF00, this);
        }
        /// <summary>
        /// Creates a Interconnect in the specified project using the data included in the request.
        /// Documentation https://developers.google.com/compute/alpha/reference/interconnects/insert
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="body">A valid Compute alpha body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Insert(ComputeService service, string project, Interconnect body, InterconnectsInsertOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }

                // Building the initial request.
                var request = service.Interconnects.Insert(body, project);

                // Applying optional parameters to the request.
                request = (InterconnectsResource.InsertRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Interconnects.Insert failed.", ex);
            }
        }
示例#9
0
 public TriggeredMemoryMapping(Interconnect internconnect, uint addressFrom, uint addressTo, TriggerType triggerType, IMemoryMappedComponent component)
 {
     _interconnect = internconnect;
     _addressFrom  = addressFrom;
     _addressTo    = addressTo;
     _triggerType  = triggerType;
     _component    = component;
 }
示例#10
0
        public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <Interconnects.InterconnectsClient> mockGrpcClient = new moq::Mock <Interconnects.InterconnectsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetInterconnectRequest request = new GetInterconnectRequest
            {
                Interconnect = "interconnect253e8bf5",
                Project      = "projectaa6ff846",
            };
            Interconnect expectedResponse = new Interconnect
            {
                Id                 = 11672635353343658936UL,
                Kind               = "kindf7aa39d9",
                Name               = "name1c9368b0",
                CustomerName       = "customer_name2ace137a",
                NocContactEmail    = "noc_contact_email1d95c1b6",
                CreationTimestamp  = "creation_timestamp235e59a1",
                RequestedLinkCount = 2020560861,
                State              = Interconnect.Types.State.UndefinedState,
                CircuitInfos       =
                {
                    new InterconnectCircuitInfo(),
                },
                OperationalStatus = Interconnect.Types.OperationalStatus.UndefinedOperationalStatus,
                PeerIpAddress     = "peer_ip_address07617b81",
                ExpectedOutages   =
                {
                    new InterconnectOutageNotification(),
                },
                Location                = "locatione09d18d5",
                ProvisionedLinkCount    = 1441690745,
                Description             = "description2cf9da67",
                InterconnectAttachments =
                {
                    "interconnect_attachmentsdc10a889",
                },
                GoogleIpAddress   = "google_ip_address246d4427",
                AdminEnabled      = true,
                SelfLink          = "self_link7e87f12d",
                SatisfiesPzs      = false,
                InterconnectType  = Interconnect.Types.InterconnectType.Partner,
                LinkType          = Interconnect.Types.LinkType.UndefinedLinkType,
                GoogleReferenceId = "google_reference_id815b6ab4",
            };

            mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Interconnect>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            InterconnectsClient client = new InterconnectsClientImpl(mockGrpcClient.Object, null);
            Interconnect        responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Interconnect responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
示例#11
0
        public void GetRequestObject()
        {
            moq::Mock <Interconnects.InterconnectsClient> mockGrpcClient = new moq::Mock <Interconnects.InterconnectsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetInterconnectRequest request = new GetInterconnectRequest
            {
                Interconnect = "interconnect253e8bf5",
                Project      = "projectaa6ff846",
            };
            Interconnect expectedResponse = new Interconnect
            {
                Id                 = 11672635353343658936UL,
                Kind               = "kindf7aa39d9",
                Name               = "name1c9368b0",
                CustomerName       = "customer_name2ace137a",
                NocContactEmail    = "noc_contact_email1d95c1b6",
                CreationTimestamp  = "creation_timestamp235e59a1",
                RequestedLinkCount = 2020560861,
                State              = "state2e9ed39e",
                CircuitInfos       =
                {
                    new InterconnectCircuitInfo(),
                },
                OperationalStatus = "operational_status14a476d9",
                PeerIpAddress     = "peer_ip_address07617b81",
                ExpectedOutages   =
                {
                    new InterconnectOutageNotification(),
                },
                Location                = "locatione09d18d5",
                ProvisionedLinkCount    = 1441690745,
                Description             = "description2cf9da67",
                InterconnectAttachments =
                {
                    "interconnect_attachmentsdc10a889",
                },
                GoogleIpAddress   = "google_ip_address246d4427",
                AdminEnabled      = true,
                SelfLink          = "self_link7e87f12d",
                SatisfiesPzs      = false,
                InterconnectType  = "interconnect_type87ba691d",
                LinkType          = "link_type65f7baf6",
                GoogleReferenceId = "google_reference_id815b6ab4",
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            InterconnectsClient client   = new InterconnectsClientImpl(mockGrpcClient.Object, null);
            Interconnect        response = client.Get(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public SerialCommunicationController(SystemClock clock, Interconnect interconnect, InterruptController interruptController)
            : base(clock)
        {
            _interruptController = interruptController;

            interconnect.AddAddressHandler(0xFF01, 0xFF02, this);

            // internal shift clock is 8192Hz
            _internalShiftClockInterval = SystemClock.ClockFrequency / 8192;

            _internalClock = true;
        }
示例#13
0
 /// <summary>Snippet for Get</summary>
 public void Get()
 {
     // Snippet: Get(string, string, CallSettings)
     // Create client
     InterconnectsClient interconnectsClient = InterconnectsClient.Create();
     // Initialize request argument(s)
     string project      = "";
     string interconnect = "";
     // Make the request
     Interconnect response = interconnectsClient.Get(project, interconnect);
     // End snippet
 }
示例#14
0
 /// <summary>Snippet for Insert</summary>
 public void Insert()
 {
     // Snippet: Insert(string, Interconnect, CallSettings)
     // Create client
     InterconnectsClient interconnectsClient = InterconnectsClient.Create();
     // Initialize request argument(s)
     string       project = "";
     Interconnect interconnectResource = new Interconnect();
     // Make the request
     Operation response = interconnectsClient.Insert(project, interconnectResource);
     // End snippet
 }
示例#15
0
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetInterconnectRequest, CallSettings)
     // Create client
     InterconnectsClient interconnectsClient = InterconnectsClient.Create();
     // Initialize request argument(s)
     GetInterconnectRequest request = new GetInterconnectRequest
     {
         Interconnect = "",
         Project      = "",
     };
     // Make the request
     Interconnect response = interconnectsClient.Get(request);
     // End snippet
 }
示例#16
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, Interconnect, CallSettings)
            // Additional: InsertAsync(string, Interconnect, CancellationToken)
            // Create client
            InterconnectsClient interconnectsClient = await InterconnectsClient.CreateAsync();

            // Initialize request argument(s)
            string       project = "";
            Interconnect interconnectResource = new Interconnect();
            // Make the request
            Operation response = await interconnectsClient.InsertAsync(project, interconnectResource);

            // End snippet
        }
示例#17
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetAsync()
        {
            // Snippet: GetAsync(string, string, CallSettings)
            // Additional: GetAsync(string, string, CancellationToken)
            // Create client
            InterconnectsClient interconnectsClient = await InterconnectsClient.CreateAsync();

            // Initialize request argument(s)
            string project      = "";
            string interconnect = "";
            // Make the request
            Interconnect response = await interconnectsClient.GetAsync(project, interconnect);

            // End snippet
        }
示例#18
0
        public GameBoy(IVideoFrameSink frameSink, IInputSource inputSource)
        {
            Clock        = new SystemClock();
            Interconnect = new Interconnect();

            Interconnect.AddAddressHandler(0x0000, 0x00FF, new BootRom());
            Memory = new SystemMemory(Interconnect);

            InterruptController = new InterruptController(Interconnect);

            CPU      = new SM83(Clock, Interconnect, InterruptController);
            Timer    = new Timer(Clock, Interconnect, InterruptController);
            SerialIO = new SerialCommunicationController(Clock, Interconnect, InterruptController);
            LCD      = new LCDController(Clock, Interconnect, InterruptController, frameSink);
            PSG      = new SoundController(Clock, Interconnect);
            Input    = new InputController(Interconnect, InterruptController, inputSource);
        }
示例#19
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetInterconnectRequest, CallSettings)
            // Additional: GetAsync(GetInterconnectRequest, CancellationToken)
            // Create client
            InterconnectsClient interconnectsClient = await InterconnectsClient.CreateAsync();

            // Initialize request argument(s)
            GetInterconnectRequest request = new GetInterconnectRequest
            {
                Interconnect = "",
                Project      = "",
            };
            // Make the request
            Interconnect response = await interconnectsClient.GetAsync(request);

            // End snippet
        }
示例#20
0
 public InterruptController(Interconnect interconnect)
 {
     interconnect.AddAddressHandler(Registers.IF, this);
     interconnect.AddAddressHandler(Registers.IE, this);
 }
示例#21
0
 public SoundController(SystemClock clock, Interconnect interconnect)
     : base(clock)
 {
 }
示例#22
0
        /// <summary>
        /// Generates a UTurn Behavior
        /// </summary>
        /// <param name="initial"></param>
        /// <param name="final"></param>
        /// <returns></returns>
        public static UTurnBehavior GenerateDefaultUTurnBehavior(Lane initial, Lane final, Interconnect turn, VehicleState vehicleState, bool relative)
        {
            // generate polygon

            /*List<BoundaryLine> boundaryPolygon = GenerateUTurnPolygon(turn.InitialWaypoint, turn.FinalWaypoint);
             * List<Coordinates> boundaryInOrder = new List<Coordinates>();
             * foreach(BoundaryLine b in boundaryPolygon)
             *      boundaryInOrder.Add(b.p1);
             * Polygon polygon = new Polygon(boundaryInOrder, CoordinateMode.AbsoluteProjected);
             *
             * // generate paths
             * IPath initialPath = RoadToolkit.LanePath(initial, vehicleState, relative);
             * IPath finalPath = RoadToolkit.LanePath(final, vehicleState, relative);
             *
             * // generate speeds
             * SpeedCommand initialSpeed = new ScalarSpeedCommand(initial.Way.Segment.SpeedInformation.MaxSpeed);
             * SpeedCommand finalSpeed = new ScalarSpeedCommand(final.Way.Segment.SpeedInformation.MaxSpeed);
             *
             * // generate path behaviors
             * PathFollowingBehavior initialPathBehavior = new PathFollowingBehavior(initialPath, initialSpeed);
             * PathFollowingBehavior finalPathBehavior = new PathFollowingBehavior(finalPath, finalSpeed);
             *
             * // generate U-Turn
             * return new UTurnBehavior(initialPathBehavior, finalPathBehavior, polygon);*/
            return(null);
        }
示例#23
0
        /// <summary>
        /// Generates a default turn behavior
        /// </summary>
        /// <param name="initial"></param>
        /// <param name="final"></param>
        /// <param name="turn"></param>
        /// <param name="vehicleState"></param>
        /// <param name="relative"></param>
        /// <returns></returns>
        public static PathFollowingBehavior GenerateDefaultTurnBehavior(Lane initial, Lane final, Interconnect turn, bool relative)
        {
            CubicBezier[] spline;

            if (turn.UserPartitions.Count == 2)
            {
                Coordinates   p0  = turn.InitialWaypoint.PreviousLanePartition.InitialWaypoint.Position;
                Coordinates   p1  = turn.InitialWaypoint.Position;
                Coordinates   p2  = turn.UserPartitions[0].FinalWaypoint.Position;
                Coordinates   p3  = turn.FinalWaypoint.Position;
                Coordinates   p4  = turn.FinalWaypoint.NextLanePartition.FinalWaypoint.Position;
                Coordinates[] pts = { p0, p1, p2, p3, p4 };
                spline = SmoothingSpline.BuildC2Spline(pts, null, null, 0.5);
            }
            else if (turn.UserPartitions.Count > 2)
            {
                Coordinates p0     = turn.InitialWaypoint.PreviousLanePartition.InitialWaypoint.Position;
                Coordinates p1     = turn.InitialWaypoint.Position;
                Coordinates p0head = p0 - p1;
                p0 = p1 + p0head.Normalize(4);

                List <Coordinates> middleUsers = new List <Coordinates>();

                for (int i = 0; i < turn.UserPartitions.Count - 1; i++)
                {
                    middleUsers.Add(turn.UserPartitions[i].FinalWaypoint.Position);
                }

                Coordinates p2     = turn.FinalWaypoint.Position;
                Coordinates p3     = turn.FinalWaypoint.NextLanePartition.FinalWaypoint.Position;
                Coordinates p3head = p3 - p2;
                p3 = p2 + p3head.Normalize(4);

                List <Coordinates> finalList = new List <Coordinates>();
                finalList.Add(p0);
                finalList.Add(p1);
                finalList.AddRange(middleUsers);
                finalList.Add(p2);
                finalList.Add(p3);

                spline = SmoothingSpline.BuildC2Spline(finalList.ToArray(), null, null, 0.5);
            }
            else
            {
                Coordinates   p0  = turn.InitialWaypoint.PreviousLanePartition.InitialWaypoint.Position;
                Coordinates   p1  = turn.InitialWaypoint.Position;
                Coordinates   p3  = turn.FinalWaypoint.Position;
                Coordinates   p4  = turn.FinalWaypoint.NextLanePartition.FinalWaypoint.Position;
                Coordinates[] pts = { p0, p1, p3, p4 };
                spline = SmoothingSpline.BuildC2Spline(pts, null, null, 0.5);
            }

            // Create the Path Segments
            List <IPathSegment> bezierPathSegments = new List <IPathSegment>();

            foreach (CubicBezier bezier in spline)
            {
                bezierPathSegments.Add(new BezierPathSegment(bezier, null, false));
            }

            // get the method from the road toolkit
            //IPath turnPath = RoadToolkit.TurnPath(initial, final, turn, vehicleState, relative);// CHANGED
            IPath turnPath = new Path(bezierPathSegments, CoordinateMode.AbsoluteProjected);

            // make a speed command (set to 2m/s)
            SpeedCommand speedCommand = new ScalarSpeedCommand(1);

            // make behavior
            //return new PathFollowingBehavior(turnPath, speedCommand);
            return(null);
        }