Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 9 additions & 66 deletions crates/lantern-app/src/application.rs
Original file line number Diff line number Diff line change
@@ -1,92 +1,35 @@
use std::{path::PathBuf, sync::Arc};

use lantern_domain::{DriveState, ParameterId, ProfileId, SessionId, SlaveId};
use lantern_domain::{DriveState, ProfileId, SessionId, SlaveId};
use lantern_profile::ValidatedDeviceProfile;
use thiserror::Error;

use crate::{
AuditHealth, Authorization, BackupCaptureRequest, BackupRestoreAction, BackupRestoreEffect,
BackupRestoreState, BusError, ConnectionAction, ConnectionAttemptKind, ConnectionEffect,
ConnectionFailure, ConnectionStep, ConnectionWizardState, Connectivity, CsvLoggingFaultSummary,
CsvLoggingRuntimeStatus, CsvLoggingStateView, FaultAction, FaultEffect, FaultTracker,
MAX_PARAMETER_BROWSER_VISIBLE, MonitoringAction, MonitoringEffect, MonitoringRuntimeSnapshot,
MonitoringView, OperationState, ParameterAction, ParameterBrowserView, ParameterDescriptorView,
ParameterIntentContext, ParameterWritePresentation, PreparedWritePlan, ProfileRegistry,
RestoreConfirmation, ScopeSelection, SerialConnectError, SessionEffect, SessionFault,
SessionInput, SessionState, SessionStateMachine, StagedWriteIntent, WriteConfirmation,
WriteConfirmationModel, WriteEffect, WriteSessionSnapshot, default_dashboard_parameters,
parameter_catalog, prepare_parameter_intent, project_monitoring_view,
CsvLoggingStateView, FaultAction, FaultEffect, FaultTracker, MAX_PARAMETER_BROWSER_VISIBLE,
MonitoringAction, MonitoringEffect, MonitoringView, OperationState, ParameterAction,
ParameterBrowserView, ParameterIntentContext, ParameterWritePresentation, ProfileRegistry,
RestoreConfirmation, SerialConnectError, SessionEffect, SessionFault, SessionInput,
SessionState, SessionStateMachine, WriteConfirmation, WriteConfirmationModel, WriteEffect,
WriteSessionSnapshot, prepare_parameter_intent, project_monitoring_view,
project_parameter_browser_view,
};

mod connection;
mod faults;
mod monitoring;
mod state;
mod view;

use state::{ApplicationMonitoringState, ApplicationParameterState};
use view::port_label;
pub use view::{
ApplicationView, AuditHealthView, AuthorizationView, OperationView, SessionPhaseView,
SessionView,
};

#[derive(Clone, Debug, Default)]
struct ApplicationMonitoringState {
dashboard_parameters: Vec<ParameterId>,
scope: ScopeSelection,
snapshot: Option<MonitoringRuntimeSnapshot>,
csv_parameters: Vec<ParameterId>,
csv_status: CsvLoggingRuntimeStatus,
next_logging_id: u128,
error: Option<String>,
}

impl ApplicationMonitoringState {
fn for_profile(profile: &ValidatedDeviceProfile) -> Self {
Self {
dashboard_parameters: default_dashboard_parameters(profile),
scope: ScopeSelection::default(),
snapshot: None,
csv_parameters: Vec::new(),
csv_status: CsvLoggingRuntimeStatus::default(),
next_logging_id: 1,
error: None,
}
}
}

#[derive(Clone, Debug)]
struct ApplicationParameterState {
catalog: Arc<[ParameterDescriptorView]>,
visible: Vec<ParameterId>,
staged_intent: Option<StagedWriteIntent>,
prepared_write: Option<PreparedWritePlan>,
write_status: Option<String>,
error: Option<String>,
}

impl Default for ApplicationParameterState {
fn default() -> Self {
Self {
catalog: Vec::<ParameterDescriptorView>::new().into(),
visible: Vec::new(),
staged_intent: None,
prepared_write: None,
write_status: None,
error: None,
}
}
}

impl ApplicationParameterState {
fn for_profile(profile: &ValidatedDeviceProfile) -> Self {
Self {
catalog: parameter_catalog(profile),
..Self::default()
}
}
}

#[derive(Clone, Debug)]
pub struct ApplicationState {
active_profile: Option<ProfileId>,
Expand Down
66 changes: 66 additions & 0 deletions crates/lantern-app/src/application/state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
use std::sync::Arc;

use lantern_domain::ParameterId;
use lantern_profile::ValidatedDeviceProfile;

use crate::{
CsvLoggingRuntimeStatus, MonitoringRuntimeSnapshot, ParameterDescriptorView, PreparedWritePlan,
ScopeSelection, StagedWriteIntent, default_dashboard_parameters, parameter_catalog,
};

#[derive(Clone, Debug, Default)]
pub(super) struct ApplicationMonitoringState {
pub(super) dashboard_parameters: Vec<ParameterId>,
pub(super) scope: ScopeSelection,
pub(super) snapshot: Option<MonitoringRuntimeSnapshot>,
pub(super) csv_parameters: Vec<ParameterId>,
pub(super) csv_status: CsvLoggingRuntimeStatus,
pub(super) next_logging_id: u128,
pub(super) error: Option<String>,
}

impl ApplicationMonitoringState {
pub(super) fn for_profile(profile: &ValidatedDeviceProfile) -> Self {
Self {
dashboard_parameters: default_dashboard_parameters(profile),
scope: ScopeSelection::default(),
snapshot: None,
csv_parameters: Vec::new(),
csv_status: CsvLoggingRuntimeStatus::default(),
next_logging_id: 1,
error: None,
}
}
}

#[derive(Clone, Debug)]
pub(super) struct ApplicationParameterState {
pub(super) catalog: Arc<[ParameterDescriptorView]>,
pub(super) visible: Vec<ParameterId>,
pub(super) staged_intent: Option<StagedWriteIntent>,
pub(super) prepared_write: Option<PreparedWritePlan>,
pub(super) write_status: Option<String>,
pub(super) error: Option<String>,
}

impl Default for ApplicationParameterState {
fn default() -> Self {
Self {
catalog: Vec::<ParameterDescriptorView>::new().into(),
visible: Vec::new(),
staged_intent: None,
prepared_write: None,
write_status: None,
error: None,
}
}
}

impl ApplicationParameterState {
pub(super) fn for_profile(profile: &ValidatedDeviceProfile) -> Self {
Self {
catalog: parameter_catalog(profile),
..Self::default()
}
}
}
Loading