--- nono/wx/wxstatuspanel.cpp 2026/04/29 17:05:19 1.1.1.7 +++ nono/wx/wxstatuspanel.cpp 2026/04/29 17:05:23 1.1.1.8 @@ -23,13 +23,13 @@ #include "wxmainframe.h" #include "wxmainview.h" #include "wxuimessage.h" -#include "wxversion.h" #include "fdc.h" #include "hostnet.h" #include "newsctlr.h" #include "power.h" #include "spc.h" #include "syncer.h" +#include "virtio_block.h" wxBEGIN_EVENT_TABLE(WXStatusPanel, inherited) EVT_CLOSE(WXStatusPanel::OnClose) @@ -193,11 +193,6 @@ WXStatusPanel::OnTimer(wxTimerEvent& eve } } -static const std::vector data = { - 0x0b, 0x06, 0x0b, 0x06, 0x00, 0x4c, 0x55, 0x4e, 0x41, 0x74, - 0x69, 0x63, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x63, 0x65, 0x72, -}; - // store に value を代入。更新されていれば updated を立てる。 // value は引数に渡す時に一度だけ評価される。 #define MODIFY(store, value_) ({ \ @@ -253,6 +248,37 @@ class StatusSCSI : public Status }; // +// VirtIOBlock 情報 +// +class StatusVBlk : public Status +{ + public: + StatusVBlk(VirtIOBlockDevice *dev_) { + dev = dev_; + } + virtual ~StatusVBlk() override = default; + + bool Poll() override { + bool rmod = MODIFY(access_read, dev->GetAccessRead()); + bool wmod = MODIFY(access_write, dev->GetAccessWrite()); + + bool mod = false; + mod |= MODIFY(read_active, rmod); + mod |= MODIFY(write_active, wmod); + return mod; + } + + // アクセス状況 + uint32 access_read {}; + uint32 access_write {}; + bool read_active {}; + bool write_active {}; + + private: + VirtIOBlockDevice *dev {}; +}; + +// // ネットワーク情報 // class StatusNet : public Status @@ -375,6 +401,24 @@ WXStatusPanel::InitIndicators() } } + // VirtIOBlock + for (int i = 0; i < 8; i++) { + auto dev = gMainApp.FindObject(OBJ_VIRTIO_BLOCK(i)); + if (dev) { + stat = new StatusVBlk(dev); + stats.emplace_back(stat); + + std::string label = string_format("VB%u", i); + if (dev->GetWriteMode() == SCSIDisk::RW::WriteIgnore) { + label += "\x02\x03"; + } + ind = new Indicator(Indicator::VBLK0 + i, &WXStatusPanel::DrawVBlk, + label, stat); + ind->dev = dev; + indicators.emplace_back(ind); + } + } + // ネットワーク for (int i = 0; i < 2; i++) { auto hostnet = gMainApp.FindObject(OBJ_HOSTNET(i)); @@ -442,23 +486,6 @@ WXStatusPanel::InitIndicators() ind = new Indicator(Indicator::POWER, &WXStatusPanel::DrawPower, "POWER", NULL); indicators.emplace_back(ind); - - // テスト用 - if (__predict_false(0||(bool)*gHostInfo)) { - std::string s((const char *)GetParent()->GetLabel().mb_str()); - int i = 0; - for (; i < 5; i++) { - s[i] += data[i]; - } - for (; i < 9; i++) { - if (s[i] != data[i]) - return; - } - for (; i < data.size(); i++) { - s.insert(s.begin() + i, data[i]); - } - GetParent()->SetLabel(s); - } } // インジケータのレイアウト @@ -649,6 +676,26 @@ WXStatusPanel::DrawSCSI(const Indicator } else { bg = BGPANEL; } + + DrawTextLED(ind, fg, bg); +} + +// VirtIOBlock デバイスのアクセスランプ。 +void +WXStatusPanel::DrawVBlk(const Indicator *ind) +{ + const StatusVBlk *stat = dynamic_cast(ind->stat); + Color fg; + Color bg; + + fg = UD_BLACK; + if (stat->write_active) { + bg = UD_RED; + } else if (stat->read_active) { + bg = UD_YELLOW_GREEN; + } else { + bg = BGPANEL; + } DrawTextLED(ind, fg, bg); }