Skip to content

ASITiger: refactor the device base classes (plain ASIBase + ASIDevice template) - #1041

Merged
marktsuchida merged 7 commits into
micro-manager:mainfrom
bls337:ASITiger6
Nov 19, 2026
Merged

marktsuchida merged 7 commits into
micro-manager:mainfrom
bls337:ASITiger6

Conversation

@bls337

@bls337 bls337 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces the ASIBase<TDeviceBase, UConcreteDevice> / ASIPeripheralBase<...> class templates in ASITiger with a plain ASIBase class plus a small ASIDevice<T> template, which lets the hub use the same code as the peripherals. The hub is no longer a special case: ASIHub derives from ASIDevice<HubBase<ASIHub>> and leaves hub_ null.

Class hierarchy

Arrows point from a class to its base class. CZStage stands for the 13 device classes built on these bases; they all change the same way.

  • Gray: MMDevice classes
  • Orange: the old class templates, instantiated per device class
  • Green: the new plain ASIBase class
  • Blue: the new ASIDevice<T> template

Before: ASIBase and ASIPeripheralBase sit inside each device's CRTP chain, so every device class has its own ASIBase<...>. The hub derives from ASIBase directly, because it could not use ASIPeripheralBase.

flowchart BT
    SB["CStageBase#lt;CZStage#gt;"]
    HB["HubBase#lt;ASIHub#gt;"]
    AB_Z["ASIBase#lt;CStageBase, CZStage#gt;"]
    AB_H["ASIBase#lt;HubBase, ASIHub#gt;"]
    APB_Z["ASIPeripheralBase#lt;CStageBase, CZStage#gt;"]
    CZ["CZStage"]
    AH["ASIHub"]
    TC["CTigerCommHub"]
    AB_Z --> SB
    APB_Z --> AB_Z
    CZ --> APB_Z
    AB_H --> HB
    AH --> AB_H
    TC --> AH
    classDef mm fill:#e8e8e8,stroke:#888888,color:#222222
    classDef perdevice fill:#fde2c8,stroke:#d9822b,color:#222222
    classDef dev fill:#ffffff,stroke:#666666,color:#222222
    class SB,HB mm
    class AB_Z,AB_H,APB_Z perdevice
    class CZ,AH,TC dev
Loading

After: one plain ASIBase class holds the shared state and the helper functions, most of which live in ASIBase.cpp. ASIDevice<T> derives from both the MM base class and ASIBase, and the hub uses it like every other device.

flowchart BT
    SB["CStageBase#lt;CZStage#gt;"]
    AB["ASIBase"]
    HB["HubBase#lt;ASIHub#gt;"]
    AD_Z["ASIDevice#lt;CStageBase#lt;CZStage#gt;#gt;"]
    AD_H["ASIDevice#lt;HubBase#lt;ASIHub#gt;#gt;"]
    CZ["CZStage"]
    AH["ASIHub"]
    TC["CTigerCommHub"]
    AD_Z --> SB
    AD_Z --> AB
    CZ --> AD_Z
    AD_H --> AB
    AD_H --> HB
    AH --> AD_H
    TC --> AH
    classDef mm fill:#e8e8e8,stroke:#888888,color:#222222
    classDef shared fill:#cfe8cf,stroke:#3d8b3d,color:#222222
    classDef tmpl fill:#d6e4f5,stroke:#3b6ea8,color:#222222
    classDef dev fill:#ffffff,stroke:#666666,color:#222222
    class SB,HB mm
    class AB shared
    class AD_Z,AD_H tmpl
    class CZ,AH,TC dev
Loading

Where the old code went

Before After
ASIBase<> constructor (Name property, error messages) ASIDevice constructor
ASIPeripheralBase<> constructor (card address) ASIDevice constructor
Shutdown(), GetName(), Busy() ASIDevice
PeripheralInitialize() ASIDevice::PeripheralInitialize(), using ASIBase::AttachHub(), QueryFirmwareInfo(), RegisterWithHub()
name/address helpers ASIBase.cpp
member variables (hub pointer, card address, firmware info, refresh flags), FirmwareVersionAtLeast() ASIBase.h
CTigerCommHub::Initialize()'s duplicate V/CD/BU queries and firmware properties ASIBase::QueryFirmwareInfo() and ASIDevice::CreateFirmwareProperties() (commit 5)

Behavior changes

Behavior is unchanged, except:

  • The hub sends its three firmware queries to the comm card's address without a space: 0V, 0CD and 0BU instead of 0 V, 0 CD and 0 BU.
  • A garbled hub version reply now gives ERR_UNRECOGNIZED_ANSWER, as on the peripherals. A controller that isn't a Tiger still gets DEVICE_NOT_SUPPORTED from TalkToTiger(), which runs first.

Notes

  • AttachHub() uses static_cast<ASIHub*> instead of dynamic_cast: GetParentHub() only returns a hub from the same device library, and every ASITiger hub is an ASIHub.
  • ASITiger, one of the examples in Stop requiring the CRTP type parameter to device base class templates #422, no longer uses template template parameters: ASIDevice<T> takes the MM base class as an ordinary type parameter.

@marktsuchida

Copy link
Copy Markdown
Member

Nice!

@marktsuchida
marktsuchida merged commit b12689d into micro-manager:main Nov 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants