--- nono/wx/wxstatuspanel.cpp 2026/04/29 17:05:12 1.1.1.5 +++ nono/wx/wxstatuspanel.cpp 2026/04/29 17:05:23 1.1.1.8 @@ -23,15 +23,13 @@ #include "wxmainframe.h" #include "wxmainview.h" #include "wxuimessage.h" -#include "wxversion.h" -#include "ethernet.h" #include "fdc.h" #include "hostnet.h" +#include "newsctlr.h" #include "power.h" #include "spc.h" -#include "sync.h" - -WXStatusPanel *gStatusPanel; +#include "syncer.h" +#include "virtio_block.h" wxBEGIN_EVENT_TABLE(WXStatusPanel, inherited) EVT_CLOSE(WXStatusPanel::OnClose) @@ -51,10 +49,14 @@ static const long STATUS_PANEL_STYLE = 0 // コンストラクタ WXStatusPanel::WXStatusPanel(wxWindow *parent) - : inherited(parent, wxDefaultSize, STATUS_PANEL_STYLE) + : inherited(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, + STATUS_PANEL_STYLE) { timer.SetOwner(this); + power = GetPowerDevice(); + syncer = GetSyncer(); + // インジケータ用のパラメータを用意。 InitIndicators(); @@ -66,10 +68,12 @@ WXStatusPanel::WXStatusPanel(wxWindow *p // 分かりづらくて、こっちがフォーカス持ってしまうと (というか起動後は // こっちにある) VM にキー入力が出来ずに焦ることになるので、ここへの // キー入力イベントは全部メインビューに飛ばす。 + auto mainframe = dynamic_cast(GetParent()); + auto mainview = mainframe->GetMainView(); Connect(wxEVT_KEY_UP, wxKeyEventHandler(WXMainView::OnKeyUp), NULL, - gMainView); + mainview); Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(WXMainView::OnKeyDown), NULL, - gMainView); + mainview); // VM からの通知を受け取る WXUIMessage::Connect(UIMessage::SCSI_MEDIA_CHANGE, this, @@ -89,11 +93,11 @@ WXStatusPanel::~WXStatusPanel() delete ind; } - WXUIMessage::Disconnect(UIMessage::SCSI_MEDIA_CHANGE, + WXUIMessage::Disconnect(UIMessage::SCSI_MEDIA_CHANGE, this, wxCommandEventHandler(WXStatusPanel::OnSCSIMediaChanged)); - WXUIMessage::Disconnect(UIMessage::FDD_MEDIA_CHANGE, + WXUIMessage::Disconnect(UIMessage::FDD_MEDIA_CHANGE, this, wxCommandEventHandler(WXStatusPanel::OnFDDMediaChanged)); - WXUIMessage::Disconnect(UIMessage::LED, + WXUIMessage::Disconnect(UIMessage::LED, this, wxCommandEventHandler(WXStatusPanel::OnLEDChanged)); } @@ -134,6 +138,23 @@ WXStatusPanel::FontChanged() { inherited::FontChanged(); + // アクセスマークをサイズに応じて作り直す + const uint8 *src; + switch (font_height) { + case 12: + src = AccessMark12; + break; + case 16: + src = AccessMark16; + break; + case 24: + src = AccessMark24; + break; + default: + PANIC("Unexpected font_height=%d", font_height); + } + accmark.reset(new BitmapI8(src, font_height, font_height)); + // インジケータを再レイアウト LayoutIndicators(); @@ -172,109 +193,299 @@ 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_) ({ \ + bool mod_; \ + decltype(value_) value = value_; \ + if (store != value) { \ + store = value; \ + mod_ = true; \ + } else { \ + mod_ = false; \ + } \ + mod_; /* return value */ \ +}) + +// +// インジケータ用の情報 +// +class Status +{ + public: + virtual ~Status() = default; + + // 情報取得メソッド + virtual bool Poll() = 0; +}; + +// +// SCSI 情報 +// +class StatusSCSI : public Status +{ + public: + StatusSCSI(SCSIBus *scsibus_) { + scsibus = scsibus_; + } + virtual ~StatusSCSI() override = default; + + bool Poll() override { + bool mod = false; + mod |= MODIFY(bsy, scsibus->GetBSY()); + // 転送フェーズで DataOut の時だけ書き込みとみなす + bool out = (scsibus->GetPhase() == SCSI::Phase::Transfer) + && (scsibus->GetXfer() == SCSI::XferPhase::DataOut); + mod |= MODIFY(dataout, out); + return mod; + } + + uint8 bsy {}; // BSY (ID0-7) + bool dataout {}; // DataOut フェーズなら true + + private: + SCSIBus *scsibus {}; +}; + +// +// 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 +{ + public: + StatusNet(HostNetDevice *hostnet_) { + hostnet = hostnet_; + } + virtual ~StatusNet() override = default; + + bool Poll() override { + // パケット数が変化したとき、および + // その変化を監視しているアクティブ状態が変化したときに + // 変更があったとしたいので二重になっている。 + bool tx_mod = MODIFY(tx_pkts, hostnet->GetTXPkts()); + bool rx_mod = MODIFY(rx_pkts, hostnet->GetRXPkts()); + + bool mod = false; + mod |= MODIFY(tx_active, tx_mod); + mod |= MODIFY(rx_active, rx_mod); + return mod; + } + + bool enable {}; + uint64 tx_pkts {}; + uint64 rx_pkts {}; + bool tx_active {}; + bool rx_active {}; + + private: + HostNetDevice *hostnet {}; +}; + +// +// FDD 情報 +// +class StatusFDD : public Status +{ + public: + StatusFDD(FDDDevice *fdd_) { + fdd = fdd_; + } + virtual ~StatusFDD() override = default; + + bool Poll() override { + bool mod = false; + mod |= MODIFY(access_led, fdd->GetAccessLED()); + mod |= MODIFY(eject_led, fdd->GetEjectLED()); + return mod; + } + + FDDDevice::LED access_led {}; // アクセス LED の状態 + bool eject_led {}; // イジェクト LED 点灯なら true + private: + FDDDevice *fdd {}; }; +// +// NEWS の LED 情報 +// +class StatusNEWS : public Status +{ + public: + StatusNEWS(NewsCtlrDevice *newsctlr_) { + newsctlr = newsctlr_; + } + virtual ~StatusNEWS() override = default; + + bool Poll() override { + return MODIFY(led, newsctlr->GetLED()); + } + + uint led {}; + private: + NewsCtlrDevice *newsctlr {}; +}; + + // インジケータの初期化 void WXStatusPanel::InitIndicators() { + Status *stat; + Indicator *ind; + // パフォーマンスカウンタ - Indicator *perf = new Indicator(Indicator::PERF, 8/* >>>9999% */, - &WXStatusPanel::DrawPerf); - perf->dclick = &WXStatusPanel::DClickPerf; - indicators.emplace_back(perf); + ind = new Indicator(Indicator::PERF, &WXStatusPanel::DrawPerf, + 8/* >>>9999% */, NULL); + ind->dclick = &WXStatusPanel::DClickPerf; + indicators.emplace_back(ind); // SCSI // SPC の接続済みデバイスリストから取得。 // (ホストアダプタ2つ目のことは考えてない) - const std::vector& conn = gSPC->GetConnectedDevices(); - for (const auto& dev : conn) { - SCSI::DevType devtype = dev->GetDevType(); - if (devtype == SCSI::DevType::Initiator) { - continue; - } - int scsiid = dev->GetMyID(); - - // 文字列は OnSCSIMediaChanged() でセットする。 - Indicator *si = new Indicator(Indicator::SCSI0 + scsiid, 3, - &WXStatusPanel::DrawSCSI); - si->contextmenu = &WXStatusPanel::ContextMenuCD; - si->dev = dev; - si->panel = new wxPanel(this); - // このパネルがフォーカスを受け取らないようにする。 - // StatusPanel がフォーカスを持っていてもキー入力を MainFrame に渡す - // ようにしているため、StatusPanel のフォーカスを奪ってはいけない。 - si->panel->SetCanFocus(false); + auto spc = gMainApp.FindObject(OBJ_SPC); + if (spc) { + stat = new StatusSCSI(spc->GetSCSIBus()); + stats.emplace_back(stat); + + const std::vector& conn = spc->GetConnectedDevices(); + for (const auto& dev : conn) { + SCSI::DevType devtype = dev->GetDevType(); + if (devtype == SCSI::DevType::Initiator) { + continue; + } + int scsiid = dev->GetMyID(); - indicators.emplace_back(si); + // 文字列は OnSCSIMediaChanged() でセットする。 + ind = new Indicator(Indicator::SCSI0 + scsiid, + &WXStatusPanel::DrawSCSI, 3, stat); + ind->contextmenu = &WXStatusPanel::ContextMenuCD; + ind->dev = dev; + ind->panel = new wxPanel(this); + // このパネルがフォーカスを受け取らないようにする。 + // StatusPanel がフォーカスを持っていてもキー入力を MainFrame に渡す + // ようにしているため、StatusPanel のフォーカスを奪ってはいけない。 + ind->panel->SetCanFocus(false); + + indicators.emplace_back(ind); + } } - // BSY 取得用 - scsibus = gSPC->GetSCSIBus(); - // ネットワーク - if (gEthernet) { - hostnet = gEthernet->GetHostNet(); - assert(hostnet); - if (hostnet->GetDriverName() == "none") { - net_ok = DISABLE; - } else { - net_ok = ENABLE; + // 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); } - // \x1e は上向き矢印、\x1f は下向き矢印 - Indicator *net = new Indicator(Indicator::LAN, 5, - &WXStatusPanel::DrawNet); - net->text = "LAN\x1e\x1f"; - indicators.emplace_back(net); - } else { - net_ok = NOT_AVAILABLE; } - // FD - if (gFDC) { - const std::vector& fdd_vector = gFDC->GetFDD(); - for (const auto fdd : fdd_vector) { - if (fdd) { - int unit = fdd->GetUnitNo(); - // 文字列は OnFDDMediaChanged() でセットする。 - Indicator *ind = new Indicator(Indicator::FDD0 + unit, 7, - &WXStatusPanel::DrawFD); - - ind->contextmenu = &WXStatusPanel::ContextMenuFD; - ind->dev = fdd; - ind->panel = new wxPanel(this); - // フォーカスを受け取らない。少し上の CD のところ参照。 - ind->panel->SetCanFocus(false); + // ネットワーク + for (int i = 0; i < 2; i++) { + auto hostnet = gMainApp.FindObject(OBJ_HOSTNET(i)); + if (hostnet) { + auto statnet = new StatusNet(hostnet); + stat = statnet; + stats.emplace_back(stat); - indicators.emplace_back(ind); + if (hostnet->GetDriverName() == "none") { + statnet->enable = false; + } else { + statnet->enable = true; } + // \x1e は上向き矢印、\x1f は下向き矢印。 + // ラベルは結局機種で変わる… + std::string label; + if (gMainApp.IsX68030()) { + label = string_format("LAN%d\x1e\x1f", i); + } else { + label = "LAN\x1e\x1f"; + } + ind = new Indicator(Indicator::LAN0 + i, &WXStatusPanel::DrawNet, + label, stat); + indicators.emplace_back(ind); } } - // 電源 LED - Indicator *power = new Indicator(Indicator::POWER, 5, - &WXStatusPanel::DrawPower); - power->text = "POWER"; - indicators.emplace_back(power); - - // テスト用 - 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]); + // FD + for (int unit = 0; unit < FDCDevice::MAX_DRIVE; unit++) { + auto fdd = gMainApp.FindObject(OBJ_FDD(unit)); + if (fdd) { + stat = new StatusFDD(fdd); + stats.emplace_back(stat); + + // 文字列は OnFDDMediaChanged() でセットする。 + ind = new Indicator(Indicator::FDD0 + unit, + &WXStatusPanel::DrawFD, 7, stat); + + ind->contextmenu = &WXStatusPanel::ContextMenuFD; + ind->dev = fdd; + ind->panel = new wxPanel(this); + // フォーカスを受け取らない。少し上の CD のところ参照。 + ind->panel->SetCanFocus(false); + + indicators.emplace_back(ind); } - GetParent()->SetLabel(s); } + + // NEWS の LED (2->1 の順で並べる) + auto newsctlr = gMainApp.FindObject(OBJ_NEWSCTLR); + if (newsctlr) { + stat = new StatusNEWS(newsctlr); + stats.emplace_back(stat); + + ind = new Indicator(Indicator::NEWSLED2, &WXStatusPanel::DrawNewsLED2, + "LED2", stat); + indicators.emplace_back(ind); + + ind = new Indicator(Indicator::NEWSLED1, &WXStatusPanel::DrawNewsLED1, + "LED1", stat); + indicators.emplace_back(ind); + } + + // 電源 LED + ind = new Indicator(Indicator::POWER, &WXStatusPanel::DrawPower, + "POWER", NULL); + indicators.emplace_back(ind); } // インジケータのレイアウト @@ -344,56 +555,22 @@ WXStatusPanel::LayoutIndicators() bool WXStatusPanel::UpdateStat() { - bool updated = false; - - // store に value を代入。更新されていれば updated を立てる。 - // value は一度だけ評価される。 - auto MODIFY = [&](auto& store, auto value) { - bool rv = store != value; - updated |= rv; - store = value; - return rv; - }; + bool mod = false; - // 電源オンか - MODIFY(ispower, gPower->IsPower()); - MODIFY(powerled, gPower->GetPowerLED()); + // 電源オン + mod |= MODIFY(ispower, power->IsPower()); + mod |= MODIFY(powerled, power->GetPowerLED()); // パフォーマンスカウンタ - MODIFY(perf_mode, gSync->GetRunMode()); - MODIFY(perf_rate, gSync->GetPerfCounter()); - - // SCSI アクセス - MODIFY(scsi_bsy, scsibus->GetBSY()); - // 転送フェーズで DataOut の時だけ書き込みとみなす - bool out = (scsibus->GetPhase() == SCSI::Phase::Transfer) - && (scsibus->GetXfer() == SCSI::XferPhase::DataOut); - MODIFY(scsi_out, out); - - // ネットワーク - // パケット数が変化したとき、 - // およびその変化を監視しているアクティブ状態が変化したとき - // に変更があったとしたいので二重になっている - if (net_ok != NOT_AVAILABLE) { - MODIFY(net_tx_active, MODIFY(net_tx_pkts, hostnet->GetTXPkts())); - MODIFY(net_rx_active, MODIFY(net_rx_pkts, hostnet->GetRXPkts())); - } + mod |= MODIFY(perf_mode, syncer->GetRunMode()); + mod |= MODIFY(perf_rate, syncer->GetPerfCounter()); - // FD - if (gFDC) { - const std::vector& fdd_vector = gFDC->GetFDD(); - for (const auto fdd : fdd_vector) { - if (fdd) { - int unit = fdd->GetUnitNo(); - MODIFY(fd_access_led[unit], fdd->GetAccessLED()); - MODIFY(fd_eject_led[unit], fdd->GetEjectLED()); - } - } + // それ以外 + for (const auto stat : stats) { + mod |= stat->Poll(); } - // 電源 - - return updated; + return mod; } // 描画本体 @@ -446,7 +623,7 @@ WXStatusPanel::DrawPerf(const Indicator // パフォーマンス表示は // o 高速モード指示中なら倍率表記 (115% なら 1.2x) // o 通常モード指示中ならパーセント表記 - if ((perf_mode & Sync::SCHED_SYNC) == 0) { + if ((perf_mode & Syncer::SCHED_SYNC) == 0) { // 高速モード指示 if (perf_mode == 0) { // 高速走行中 @@ -474,6 +651,7 @@ WXStatusPanel::DrawPerf(const Indicator void WXStatusPanel::DrawSCSI(const Indicator *ind) { + const StatusSCSI *stat = dynamic_cast(ind->stat); Color fg; Color bg; int scsiid; @@ -483,14 +661,14 @@ WXStatusPanel::DrawSCSI(const Indicator assertmsg(scsiid >= 0, "id=%d", ind->id); idmask = 1U << scsiid; - if ((scsi_loaded & idmask) != 0) { + if (scsi_loaded[scsiid]) { fg = UD_BLACK; } else { fg = UD_GREY; } - if ((scsi_bsy & idmask) != 0) { - if (scsi_out) { + if ((stat->bsy & idmask) != 0) { + if (stat->dataout) { bg = UD_RED; } else { bg = UD_YELLOW_GREEN; @@ -502,17 +680,38 @@ WXStatusPanel::DrawSCSI(const Indicator 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); +} + // ネットワーク(LAN) void WXStatusPanel::DrawNet(const Indicator *ind) { + const StatusNet *stat = dynamic_cast(ind->stat); + const Rect& rect = ind->rect; Color fg; Color bg = BGPANEL; - const Rect& rect = ind->rect; - if (net_ok) { + if (stat->enable) { fg = UD_BLACK; - if (net_tx_active || net_rx_active) { + if (stat->tx_active || stat->rx_active) { bg = UD_YELLOW_GREEN; } } else { @@ -530,14 +729,14 @@ WXStatusPanel::DrawNet(const Indicator * auto c = ind->text[i]; switch (c) { case '\x1e': // 上向き矢印 - if (net_tx_active) { + if (stat->tx_active) { fg = UD_BLACK; } else { fg = UD_GREY; } break; case '\x1f': // 下向き矢印 - if (net_rx_active) { + if (stat->rx_active) { fg = UD_BLACK; } else { fg = UD_GREY; @@ -555,19 +754,18 @@ WXStatusPanel::DrawNet(const Indicator * void WXStatusPanel::DrawFD(const Indicator *ind) { - BitmapI8 accmark; + const StatusFDD *stat = dynamic_cast(ind->stat); + const Rect& rect = ind->rect; Rect iconrect; - const uint8 *src; Color pal[3]; + int unit; enum { BG = 0, FG, IN, }; - int unit; unit = ind->GetFDUnit(); - const Rect& rect = ind->rect; pal[BG] = BGPANEL; if (fd_loaded[unit]) { @@ -587,7 +785,7 @@ WXStatusPanel::DrawFD(const Indicator *i iconrect.h = font_height - 2; bitmap.DrawRect(pal[FG], iconrect); // ディスク挿入(取り出し可)なら黄緑点灯 - if (fd_eject_led[unit]) { + if (stat->eject_led) { iconrect.x += 1; iconrect.y += 1; iconrect.w -= 2; @@ -596,24 +794,13 @@ WXStatusPanel::DrawFD(const Indicator *i } // その後で 3,4文字目の空き地に丸いインジケータを描画。 - switch (font_height) { - case 12: - src = AccessMark12; - break; - case 16: - src = AccessMark16; - break; - default: - PANIC("Unexpected font_height=%d", font_height); - } - accmark.Create(src, font_height, font_height); int dx = rect.x + 2 + font_width * 3; int dy = rect.y + 2; // アクセス LED はディスク非挿入時に点滅するケースがあって、 // その場合、フチがグレーのまま中を黄緑で塗りつぶすのは見えづらいので // 中を塗りつぶす時はフチを濃くしたほうがいい。 - switch (fd_access_led[unit]) { + switch (stat->access_led) { case FDDDevice::LED::GREEN: pal[FG] = UD_BLACK; pal[IN] = UD_YELLOW_GREEN; @@ -626,7 +813,7 @@ WXStatusPanel::DrawFD(const Indicator *i pal[IN] = pal[BG]; break; } - bitmap.DrawBitmap(dx, dy, accmark, pal); + bitmap.DrawBitmap(dx, dy, *accmark, pal); } /*static*/ const uint8 @@ -663,6 +850,63 @@ WXStatusPanel::AccessMark16[] = { 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; +/*static*/ const uint8 +WXStatusPanel::AccessMark24[] = { + 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, 0,1,1,1,1,1,1,0, 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,1, 1,2,2,2,2,2,2,1, 1,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,2, 2,2,2,2,2,2,2,2, 2,1,1,0,0,0,0,0, + 0,0,0,0,1,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,1,0,0,0,0, + 0,0,0,1,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,1,0,0,0, + 0,0,0,1,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,1,0,0,0, + 0,0,1,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,1,0,0, + 0,0,1,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,1,0,0, + 0,1,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,1,0, + 0,1,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,1,0, + 0,1,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,1,0, + 0,1,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,1,0, + 0,1,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,1,0, + 0,1,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,1,0, + 0,0,1,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,1,0,0, + 0,0,1,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,1,0,0, + 0,0,0,1,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,1,0,0,0, + 0,0,0,1,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,1,0,0,0, + 0,0,0,0,1,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,1,0,0,0,0, + 0,0,0,0,0,1,1,2, 2,2,2,2,2,2,2,2, 2,1,1,0,0,0,0,0, + 0,0,0,0,0,0,0,1, 1,2,2,2,2,2,2,1, 1,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, 0,1,1,1,1,1,1,0, 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, +}; + +// NEWS LED1 +void +WXStatusPanel::DrawNewsLED1(const Indicator *ind) +{ + const StatusNEWS *stat = dynamic_cast(ind->stat); + Color bg; + + if ((stat->led & NewsCtlrDevice::LED_ORANGE) != 0) { + bg = UD_ORANGE; + } else { + bg = BGPANEL; + } + DrawTextLED(ind, UD_BLACK, bg); +} + +// NEWS LED2 +void +WXStatusPanel::DrawNewsLED2(const Indicator *ind) +{ + const StatusNEWS *stat = dynamic_cast(ind->stat); + Color bg; + + if ((stat->led & NewsCtlrDevice::LED_GREEN) != 0) { + bg = UD_GREEN; + } else { + bg = BGPANEL; + } + DrawTextLED(ind, UD_BLACK, bg); +} // 電源 LED void @@ -720,7 +964,7 @@ void WXStatusPanel::DClickPerf(const Indicator *ind) { // モードを切り替える - gSync->RequestFullSpeed(!gSync->GetFullSpeed()); + syncer->RequestFullSpeed(!syncer->GetFullSpeed()); } // コンテキストメニューイベント @@ -745,7 +989,8 @@ WXStatusPanel::ContextMenuCD(const Indic int scsiid = ind->GetSCSIID(); assertmsg(scsiid >= 0, "id=%d", ind->id); - auto menu = gMainFrame->CreateSCSIRemovableMenu(scsiid); + auto mainframe = dynamic_cast(GetParent()); + auto menu = mainframe->CreateSCSIRemovableMenu(scsiid); if (menu) { PopupMenu(menu); } @@ -758,7 +1003,8 @@ WXStatusPanel::ContextMenuFD(const Indic int unit = ind->GetFDUnit(); assertmsg(unit >= 0, "id=%d", ind->id); - auto menu = gMainFrame->CreateFDMenu(unit); + auto mainframe = dynamic_cast(GetParent()); + auto menu = mainframe->CreateFDMenu(unit); if (menu) { PopupMenu(menu); } @@ -769,7 +1015,7 @@ void WXStatusPanel::OnSCSIMediaChanged(wxCommandEvent& event) { Indicator *ind = NULL; - uint8 new_loaded; + bool new_loaded; // 該当の Indicator を探す (見付かるはず) int scsiid = event.GetInt(); @@ -784,8 +1030,7 @@ WXStatusPanel::OnSCSIMediaChanged(wxComm const auto disk = dynamic_cast(ind->dev); // メディアの状態を一旦クリア - new_loaded = scsi_loaded; - new_loaded &= ~(1U << scsiid); + new_loaded = false; // ツールチップを設定 SCSI::DevType devtype = disk->GetDevType(); @@ -797,7 +1042,7 @@ WXStatusPanel::OnSCSIMediaChanged(wxComm tip += "-"; } else { tip += path; - new_loaded |= (1U << scsiid); + new_loaded = true; } switch (disk->GetWriteMode()) { case SCSIDisk::RW::ReadOnly: @@ -819,7 +1064,7 @@ WXStatusPanel::OnSCSIMediaChanged(wxComm // 無駄に幅を取らないためメディア挿入時のみ表示。 // MO のライトプロテクト表示は必要になったら考える…。 ind->text = string_format("%s%d", SCSI::GetDevTypeName(devtype), scsiid); - if ((new_loaded & (1U << scsiid))) { + if (new_loaded) { if (disk->GetWriteMode() == SCSIDisk::RW::WriteIgnore) { ind->text += "\x02\x03"; } @@ -828,8 +1073,8 @@ WXStatusPanel::OnSCSIMediaChanged(wxComm // メディアのロード状態が変われば (再配置して) 再描画。 // 通常周期のタイマーによる更新チェックではメディア状態はチェックして // いないので、ここで自発的に行う。 - if (scsi_loaded != new_loaded) { - scsi_loaded = new_loaded; + if (scsi_loaded[scsiid] != new_loaded) { + scsi_loaded[scsiid] = new_loaded; LayoutIndicators(); Refresh();