public double Seek(PositionVector newPosition) { if (!newPosition.isValid) { return 0; } direction = newPosition.Track > position.Track ? Direction.In : Direction.Out; double time = calculateSeek(newPosition); position.Track = newPosition.Track; position.Sector = newPosition.Sector; return time; }
public double calculateSeek(PositionVector newPosition) { double time = (10 + 0.1 * Math.Abs(position.Track - newPosition.Track)); if (newPosition.Sector >= position.Sector) { time += newPosition.Sector - position.Sector; } else { time += (8 - position.Sector) + newPosition.Sector; } //Include transfer time of 1 ms time++; return time; }
public Disk() { tracks = new Track[250]; position = new PositionVector(0, 0); direction = Direction.In; }
public Seek(int arrivalTime, PositionVector position) { this.arrivalTime = arrivalTime; this.position = position; }