From 82b13e98f22d9761111203ff7ff83fde8e0dd35a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 11 Sep 2017 22:27:50 -0400 Subject: [PATCH] =?UTF-8?q?Implements=20the=20real=20hardware=20ready=20te?= =?UTF-8?q?st=20for=20Drives=20=E2=80=94=20motor=20on=20plus=20two=20index?= =?UTF-8?q?=20holes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Storage/Disk/Drive.cpp | 9 +++++---- Storage/Disk/Drive.hpp | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Storage/Disk/Drive.cpp b/Storage/Disk/Drive.cpp index 21d769a97..b019f5c4e 100644 --- a/Storage/Disk/Drive.cpp +++ b/Storage/Disk/Drive.cpp @@ -26,9 +26,6 @@ void Drive::set_disk(const std::shared_ptr &disk) { invalidate_track(); update_sleep_observer(); - - // TODO: implement ready properly. - is_ready_ = true; } bool Drive::has_disk() { @@ -76,11 +73,14 @@ bool Drive::get_is_read_only() { } bool Drive::get_is_ready() { - return is_ready_; + return ready_index_count_ == 2; } void Drive::set_motor_on(bool motor_is_on) { motor_is_on_ = motor_is_on; + if(!motor_is_on) { + ready_index_count_ = 0; + } update_sleep_observer(); } @@ -160,6 +160,7 @@ void Drive::process_next_event() { // TODO: ready test here. if(current_event_.type == Track::Event::IndexHole) { assert(get_time_into_track() == Time(1) || get_time_into_track() == Time(0)); + if(ready_index_count_ < 2) ready_index_count_++; cycles_since_index_hole_ = 0; } if(event_delegate_) event_delegate_->process_event(current_event_); diff --git a/Storage/Disk/Drive.hpp b/Storage/Disk/Drive.hpp index 59a25201c..81e01c48c 100644 --- a/Storage/Disk/Drive.hpp +++ b/Storage/Disk/Drive.hpp @@ -155,8 +155,8 @@ class Drive: public Sleeper, public TimedEventLoop { PCMSegment write_segment_; Time write_start_time_; - // Indicates drive ready state. - bool is_ready_ = false; + // Indicates progress towards drive ready state. + int ready_index_count_ = 0; // Maintains appropriate counting to know when to indicate that writing // is complete.