pub struct FxpSimulator {
pub actors: BTreeMap<String, ActorState>,
pub outbox: Vec<Message>,
pub delivered: Vec<Message>,
/* private fields */
}Expand description
Barramento FXP simulado e determinístico.
Fields§
§actors: BTreeMap<String, ActorState>§outbox: Vec<Message>Mensagens serializadas (todo comando, mesmo rejeitado).
delivered: Vec<Message>Entregas efetivadas (ator correto).
Implementations§
Source§impl FxpSimulator
impl FxpSimulator
pub fn new() -> Self
pub fn set_sensor(&mut self, name: &str, value: f64)
Sourcepub fn fail_sensor(&mut self, name: &str)
pub fn fail_sensor(&mut self, name: &str)
Sensor registrado porém inacessível (FORMAL §4.7).
pub fn recover_sensor(&mut self, name: &str)
Sourcepub fn unregister_sensor(&mut self, name: &str)
pub fn unregister_sensor(&mut self, name: &str)
Remove sensor do registro (falha sensor_nao_registrado).
Sourcepub fn schedule(&mut self, tick: u64, sensor: &str, value: f64)
pub fn schedule(&mut self, tick: u64, sensor: &str, value: f64)
Agenda valor absoluto para um tick (1-based).
Sourcepub fn fail_actor(&mut self, name: &str)
pub fn fail_actor(&mut self, name: &str)
Ator para de responder (heartbeat falho — BDD Caso 3).
pub fn recover_actor(&mut self, name: &str)
Sourcepub fn set_fallback(&mut self, primary: &str, alternativos: &[&str])
pub fn set_fallback(&mut self, primary: &str, alternativos: &[&str])
Política de fallback fica no REGISTRO do FXP (FORMAL §4.3).
Sourcepub fn register_actor(&mut self, name: &str, limits: ActorLimits)
pub fn register_actor(&mut self, name: &str, limits: ActorLimits)
Registra ator extra (extensão opcional, ex.: ReserveFan).
Sourcepub fn register_sensor(&mut self, name: &str, info: SensorInfo)
pub fn register_sensor(&mut self, name: &str, info: SensorInfo)
Registra (ou substitui) um sensor no registro/simulador — usado pelo
bus da Etapa 3 para sincronizar o DeviceRegistry (fonte única) com
o backend simulado; valor inicial plausível é 0.0 até roteirização.
pub fn current_actor(&self, name: &str) -> Option<&Value>
pub fn sensor_value(&self, name: &str) -> Option<f64>
Trait Implementations§
Source§impl Clone for FxpSimulator
impl Clone for FxpSimulator
Source§fn clone(&self) -> FxpSimulator
fn clone(&self) -> FxpSimulator
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FxpSimulator
impl Debug for FxpSimulator
Source§impl Default for FxpSimulator
impl Default for FxpSimulator
Source§impl Fxp for FxpSimulator
impl Fxp for FxpSimulator
Source§fn read_sensor(
&mut self,
name: &str,
ledger: &mut dyn Ledger,
) -> Result<f64, SensorFailure>
fn read_sensor( &mut self, name: &str, ledger: &mut dyn Ledger, ) -> Result<f64, SensorFailure>
Leitura por nome simbólico. Falha →
SensorFailure + alerta no Caderno
(§4.7: sensor ausente NUNCA é 0.0 — zero é leitura física válida).Source§fn act(
&mut self,
actor: &str,
value: Value,
ledger: &mut dyn Ledger,
) -> ActOutcome
fn act( &mut self, actor: &str, value: Value, ledger: &mut dyn Ledger, ) -> ActOutcome
Comando a ator: serializa, valida limites (inclusivos) e entrega;
o Caderno registra tentativa, falha e fallback (§4.3).
Source§fn on_tick(&mut self, _ledger: &mut dyn Ledger)
fn on_tick(&mut self, _ledger: &mut dyn Ledger)
Avanço do tick no mundo (roteirização do simulador; Etapa 3: também
re-entrega a fila de comandos, auditada no Caderno).
Source§fn disk_bytes_used(&self) -> u64
fn disk_bytes_used(&self) -> u64
Bytes em suporte estável (persistência — FORMAL §4.1).
fn add_disk_bytes(&mut self, n: u64)
Source§fn act_with_priority(
&mut self,
actor: &str,
value: Value,
priority: u8,
ledger: &mut dyn Ledger,
) -> ActOutcome
fn act_with_priority( &mut self, actor: &str, value: Value, priority: u8, ledger: &mut dyn Ledger, ) -> ActOutcome
Comando com prioridade de fila (Etapa 3): default ignora a prioridade
e delega a
Fxp::act — barramentos com fila prioritária (vbl-fxp)
sobrescrevem. O engine usa PRIORITY_SUBVERT para a act que
segue um subvert na mesma regra (FORMAL §4.5: sem atraso
perceptível).Auto Trait Implementations§
impl Freeze for FxpSimulator
impl RefUnwindSafe for FxpSimulator
impl Send for FxpSimulator
impl Sync for FxpSimulator
impl Unpin for FxpSimulator
impl UnsafeUnpin for FxpSimulator
impl UnwindSafe for FxpSimulator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more