8.4 KiB
8.4 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T13:48:30.268564+00:00 | zai-org/GLM-5-FP8 | 1 | 09077834bf97663d |
Documentation: GraphMainViewModel
1. Purpose
The GraphMainViewModel class acts as the presentation logic controller for the Graph List module. It is responsible for transforming raw test summary data into a hierarchical, displayable tree of test channels (TestChannelsTree), managing the state of channel selection and locking (e.g., for reporting vs. viewing), and mediating communication between the data layer and the UI via Prism's IEventAggregator. It handles the logic for assigning distinct colors to channels, filtering channel lists, and enforcing constraints such as the maximum number of lockable channels.
2. Public Interface
Properties
IFilterView FilterView: Gets the filter view instance associated with this view model.IGraphMainView View: Gets or sets the associated view interface.IBaseViewModel Parent: Gets or sets the parent view model (used to scope event handling).InteractionRequest<Notification> NotificationRequest: Gets the interaction request for displaying notifications.InteractionRequest<Confirmation> ConfirmationRequest: Gets the interaction request for displaying confirmations.ObservableCollection<ITestChannel> ChannelList: Gets or sets the full list of available channels. Setting this updatesIsFilterEnabledand resetsFilteredChannelList.ObservableCollection<ITestChannel> FilteredChannelList: Gets or sets the list of channels currently displayed (after filtering). Setting this triggers a rebuild ofTestChannelsTree.List<ITestChannel> LockedChannelList: Gets or sets the list of channels currently locked by the user.List<ITestChannel> SelectedChannelList: Gets or sets the list of channels currently selected by the user.ObservableCollection<TreeViewChannels> TestChannelsTree: Gets or sets the hierarchical structure of tests, groups, and channels bound to the UI.bool IsFilterEnabled: Gets or sets a value indicating whether the filter UI is enabled (true ifChannelListhas items).string SelectedGroupName: Gets or sets the name of the currently selected group.string LockedGroupName: Gets or sets the name of the currently locked group.object ContextGraphMainRegion: Gets or sets the data context for theGraphMainRegionwithin the view.bool TestModified: Gets or sets a value indicating whether the underlying test has been modified.
Methods
void Initialize(): Overrides baseInitialize. Currently empty.void Initialize(object parameter): Overrides baseInitialize. Sets theParent, determines if locked-only mode is active (if Parent isIPSDReportMainViewModel), initializes theFilterView, and subscribes to events.void Activated(): Overrides baseActivated. Publishes aFilterParameterChangedEventwith an empty parameter to reset the filter.void PublishSelectedChannels(): Publishes the combined list ofLockedChannelListand (optionally)SelectedChannelListviaGraphSelectedChannelsNotification.void OnFilterChanged(FilterParameterArgs args): FiltersChannelListbased on the string provided inargs.Paramand updatesFilteredChannelList.void AddLockedGroupChannels(string testName, string groupName, List<ITestChannel> channels, bool isLocked): Adds or removes a group of channels to/from theLockedChannelList. Updates channel colors and locks. TriggersUpdateChannelLocks.void AddLockedChannel(ITestChannel channel, bool isLocked): Adds or removes a single channel to/from theLockedChannelList. Manages selection state if the channel was previously selected. TriggersUpdateChannelLocks.void AddSelectedGroupChannels(string groupName, List<ITestChannel> channels): Replaces theSelectedChannelListwith the provided channels and assigns colors.void AddSelectedGroup(TestGroup group): Marks a specificTestGroupas selected.void AddSelectedChannel(ITestChannel channel, bool reset): Adds a channel toSelectedChannelList. Ifresetis true, clears existing selection first. Handles graph channels by selecting their group instead.void AddSelectedChannel(ITestChannel channel): Overload that resets the selection before adding the new channel.void TestChannelsTree_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e): Handles collection change events for the tree, wiring upPropertyChangedlisteners.void GraphList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e): Handles collection change events for the channel list, wiring upPropertyChangedlisteners.
3. Invariants
- Maximum Locked Channels: The system enforces a hard limit of 8 locked channels (
MAX_LOCKED_CHANNELS). TheUpdateChannelLocksmethod disables the ability to lock further channels once this limit is reached. - Color Assignment: Channels are assigned colors from a predefined list (
_graphColors). Transparent is reserved (default). The system attempts to assign unused colors first; if all colors are exhausted, it cycles through them using modulo arithmetic. - Locked vs. Selected: A channel cannot be both locked and selected. Locking a channel removes it from
SelectedChannelList. - Parent Scoping: Event handlers (e.g.,
OnTestSummaryChanged) verify that the event'sParentVMmatches the instance'sParentbefore processing, ensuring multiple instances of the view model do not interfere with each other. - Locked-Only Mode: If the
Parentis of typeIPSDReportMainViewModel, the_lockedOnlyflag is set totrue. In this mode,PublishSelectedChannelsonly publishes locked channels, ignoring selected channels.
4. Dependencies
Internal Dependencies
DTS.Common.Base:BaseViewModelDTS.Common.Enums.Sensors:CalibrationBehaviors,IsoViewModeDTS.Common.Events:TestSummaryChangeNotificationArg,GraphClearNotificationArg,FilterParameterArgs, etc.DTS.Common.Interactivity:InteractionRequest,Notification,ConfirmationDTS.Common.Interface:ITestChannel,ITestSummary,IBaseViewModel,IFilterView, etc.DTS.Common.Utils:Utilsstatic helper.DTS.Serialization.SliceRaw.File.PersistentChannel: Used for ISO code retrieval delegate.
External Dependencies
Prism.Events:IEventAggregator(Pub/Sub events).Prism.Regions:IRegionManager(Navigation/Region management).Unity:IUnityContainer(Dependency Injection).System.Windows.Media:Color,Colors.
5. Gotchas
- Explicit GC Collection: The method
CleanSelection()explicitly callsGC.Collect(). This is generally discouraged in production code and may indicate a historical attempt to force cleanup of unmanaged resources or large objects. - Lazy Loading Side-Effect: In
OnTestSummaryChanged, there is a checkif (l.Channels.FirstOrDefault() == null). If the first channel is null, it forces a load operation usingUtils.SetChannelInfo. This implies thatITestSummaryobjects passed to this VM might be partially initialized stubs. - Commented Out Event Subscription: The subscription to
GraphChannelsReadCompletedNotificationis commented out with the note "It does not work", suggesting incomplete functionality or a known bug in the event chain. - Empty Event Handlers: Several event handlers (
OnCalibrationBehaviorSettableInViewerChanged,TestChannelsTree_PropertyChanged,GraphList_PropertyChanged) contain empty bodies or logic that does nothing (e.g.,if (e.PropertyName != "TestChannelsTree") { }). This suggests either dead code or placeholders for future logic. - Calibration Behavior Mutation: When
CalibrationBehaviors.UseBothIfAvailableis active, the code modifies theChannelDescriptionStringof the channel objects directly by appending "(NonLinear)" or "(Linear)". This mutates the data objects which might be shared elsewhere. - Color Index Logic: The logic in
GetNextColorfor handling the case wherechannelCount >= _graphColors.Countcontains a redundant check (if (nextColorIndex >= _graphColors.Count)), as the modulo math ensures the index is within bounds, though the+1offset logic makes it slightly fragile regarding the list size.