コード例 #1
0
ファイル: Drive.cs プロジェクト: Ryxai/DriveTest
 public Drive(XElement driveStats)
 {
     this.populateDriveSpecs(driveStats);
     this.requestQueue = new Queue<Request>();
     this.activeRequest = null;
     this.activeRequestCompletionTime = 0;
 }
コード例 #2
0
 public void SSTF_Test()
 {
     Queue<Request> queue = new Queue<Request>(array);
     queue = RequestAlgorithms.SSTF(
         queue,
         new Drive.Stats(100, 50, i => 10 + i * 0.2, 0.3, 0.5, null, 0, 0, true, 10, 0.2));
     var expected = new Request[] { array[0], array[2], array[1], array[5], array[4], array[3] };
     Assert.IsTrue(expected.Zip(queue, comparisonFunc).Aggregate((b, b1) => b && b1));
 }
コード例 #3
0
 public void LOOK_Test()
 {
     Queue<Request> queue = new Queue<Request>(array);
     var expected1 = new Request[] { array[5], array[4], array[3], array[1], array[0], array[2] };
     var expected2 = new Request[] { array[1], array[0], array[2], array[5], array[4], array[3] };
     var queue1 = RequestAlgorithms.LOOK(
         queue,
         new Drive.Stats(100, 50, i => 10 + i * 0.2, 0.3, 0.5, null, 15, 0, true, 10, 0.2));
     var queue2 = RequestAlgorithms.LOOK(
         queue,
         new Drive.Stats(100, 50, i => 10 + i * 0.2, 0.3, 0.5, null, 15, 0, false, 10, 0.2));
     Assert.IsTrue(expected1.Zip(queue1,comparisonFunc).Aggregate((b, b1) => b && b1));
     Assert.IsTrue(expected2.Zip(queue2,comparisonFunc).Aggregate((b, b1) => b && b1));
 }
コード例 #4
0
ファイル: Drive.cs プロジェクト: Ryxai/DriveTest
 public Tuple<double, double> CompleteJob()
 {
     this.driveSpecs.TrackPosition = this.ActiveRequest.Track;
     this.driveSpecs.SectorPosition = this.ActiveRequest.Sector;
     var activeRequestArrivalTime = activeRequest.ArrivalTime;
     mostRecentlyCompletedRequest = activeRequest;
     this.activeRequest = null;
     return new Tuple<double, double>(this.activeRequestCompletionTime, activeRequestArrivalTime);
 }
コード例 #5
0
ファイル: Drive.cs プロジェクト: Ryxai/DriveTest
 public void AddRequest(Request newRequest)
 {
     requestQueue.Enqueue(newRequest);
 }
コード例 #6
0
ファイル: Drive.cs プロジェクト: Ryxai/DriveTest
 public void ActivateNewJob(Func<Queue<Request>, Stats, Queue<Request>> driveSeekAlgorithm, double time)
 {
     requestQueue = driveSeekAlgorithm(requestQueue, driveSpecs.CopyStats());
     activeRequest = requestQueue.Dequeue();
     activeRequestCompletionTime = time + this.calculateRequiredTimeForRequest();
 }