--- nono/vm/rtc.cpp 2026/04/29 17:05:29 1.1.1.10 +++ nono/vm/rtc.cpp 2026/04/29 17:05:51 1.1.1.13 @@ -10,6 +10,7 @@ #include "rtc.h" #include "config.h" +#include "event.h" #include "scheduler.h" #include "syncer.h" @@ -28,10 +29,6 @@ RTCDevice::~RTCDevice() bool RTCDevice::Init() { - if (inherited::Init() == false) { - return false; - } - syncer = GetSyncer(); // TODO: use_localtime を設定可能にするべきかどうか @@ -43,17 +40,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; @@ -93,10 +80,12 @@ RTCDevice::Init() rtc_tm.tm_sec = ss; } - event.func = ToEventCallback(&RTCDevice::Callback); - event.time = period; - event.SetName("RTC ClockIn"); - scheduler->RegistEvent(event); + auto evman = GetEventManager(); + event = evman->Regist(this, + ToEventCallback(&RTCDevice::Callback), + "RTC ClockIn"); + event->time = period; + return true; } @@ -243,7 +232,7 @@ RTCDevice::ParseTime(const std::string& // イベントハンドラ void -RTCDevice::Callback(Event& ev) +RTCDevice::Callback(Event *ev) { stime += period; ClockIn();