--- nono/vm/rtc.cpp 2026/04/29 17:05:18 1.1.1.9 +++ nono/vm/rtc.cpp 2026/04/29 17:05:43 1.1.1.12 @@ -17,9 +17,6 @@ RTCDevice::RTCDevice() : inherited(OBJ_RTC) { - event.Regist("RTC ClockIn"); - event.time = period; - event.func = ToEventCallback(&RTCDevice::Callback); } // デストラクタ @@ -31,10 +28,6 @@ RTCDevice::~RTCDevice() bool RTCDevice::Init() { - if (inherited::Init() == false) { - return false; - } - syncer = GetSyncer(); // TODO: use_localtime を設定可能にするべきかどうか @@ -46,17 +39,7 @@ RTCDevice::Init() // VM を作り、パフォーマンス測定を安定させる。 force_fixed = gConfig->Find(".rtc-force-fixed").AsInt(); - // クロックの同期方法 - const ConfigItem& item_sync = gConfig->Find("clock-sync"); - auto clock_sync = item_sync.AsString(); - if (clock_sync == "real") { - sync_rt = true; - } else if (clock_sync == "virtual") { - sync_rt = false; - } else { - item_sync.Err(); - return false; - } + sync_rt = syncer->GetSyncRealtime(); rtc_tm.tm_year = -1; rtc_tm.tm_mon = -1; @@ -96,6 +79,11 @@ RTCDevice::Init() rtc_tm.tm_sec = ss; } + event.func = ToEventCallback(&RTCDevice::Callback); + event.time = period; + event.SetName("RTC ClockIn"); + scheduler->RegistEvent(event); + return true; } @@ -107,7 +95,6 @@ RTCDevice::StartTime() struct tm tm; if (force_fixed) { - putmsgn("force_fixed"); // 固定の時刻を設定 struct tm fixed { .tm_sec = 16, @@ -378,11 +365,11 @@ RTCDevice::CountUpMin() } // 現在の月の最終日を返す (月の繰り上がり処理用) -int +uint RTCDevice::GetLastMday() const { // 下記の理由により 0 月が必要。値は適当。 - static const int mdays[] = { + static const uint mdays[] = { 30, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; @@ -391,8 +378,8 @@ RTCDevice::GetLastMday() const // 範囲外の値に対するロジックは違うだろうが規定されていないので // こっち都合で実装しておく。 // m は 0..12 - int m = GetMon() % 13; - int lastday = mdays[m]; + uint m = GetMon() % 13; + uint lastday = mdays[m]; if (m == 2 && GetLeap() == 0) { lastday++; }