products/Sources/formale Sprachen/VDM/VDMRT/HomeAutomationRT image not shown  

Quellcode-Bibliothek

© Kompilation durch diese Firma

[Weder Korrektheit noch Funktionsfähigkeit der Software werden zugesichert.]

Datei: Thermostat.vdmrt   Sprache: VDM

Original von: VDM©

-----------------------------------------------
-- Author: Sune Wolff - 20022462
-- Created: 21/4 - 2008
-- Updated:
-- Description:  Thermostat sub class
-----------------------------------------------

--
-- class definition
--
class Thermostat is subclass of Actuator

--
-- instance variables
--
instance variables

  finished : bool := false;

--
-- Operations definition section
--
operations

public Thermostat: nat * NetworkTypes`nodeType 
==> Thermostat
Thermostat (id, type) ==
 (ID := id;
  Type := type;
  Corr := <NONE>;
 );

public Step: () ==> ()
Step() ==
  --cycles(1E3)
 (dcl tempCorr: NetworkTypes`correction := GetCorrection();
  if (tempCorr = <INC>)
  then World`env.IncTemp()
  elseif (tempCorr = <DEC>)
  then World`env.DecTemp();
 );

async public SetCorrection: NetworkTypes`correction ==> ()
SetCorrection(cor) ==
  --cycles(1E3)
  Corr := cor
pre (cor = <INC>) or (cor = <DEC>) or (cor = <NONE>);

public GetCorrection: () ==> NetworkTypes`correction
GetCorrection() ==
  return Corr;

public IsFinished: () ==> ()
IsFinished() ==
  skip;

sync
  --mutex(PeriodicOp); -- ADDED
  per IsFinished => finished;
  mutex(SetCorrection, GetCorrection);

--
-- Thread definition section
--
thread

-- period of thread (period, jitter, delay, offset)
periodic(1000E6,0,0,0) (Step)

end Thermostat

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet)  ¤





Download des
Quellennavigators
Download des
sprechenden Kalenders

in der Quellcodebibliothek suchen




Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.


Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.


Bot Zugriff