Download presentation
Presentation is loading. Please wait.
Published bySamson Greer Modified over 9 years ago
1
Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072
2
Agenda Last time Updated classdiagram First draft of implementation Today Updated classdiagram Implementation of selected classes/ops. Testing with VDMUnit
3
Updated class diagram Class Clock represents global time
4
Classes of interest Class Clock Representation of global time i.e. Need to determine patient records last update Class MedicalDevice Class PMUSystem (main)
5
Class Clock class Clock instance variables static private time : nat := 0; operations static public GetTime : () ==> nat GetTime() == return time; static public IncrementClock : () ==> nat IncrementClock() == ( time := time + 1; return time ) end Clock
6
Class MedicalDevice class MedicalDevice... public RetrieveDeviceData : () ==> Data RetrieveDeviceData() == ( def deviceData = mk_Data(deviceId, dataLog) in ( PurgeData(); return deviceData ); ); public CreateDataEntry: seq of char * nat ==> () CreateDataEntry (data, t) == def newLogEntry = mk_LogEntry(t, data) in dataLog := [newLogEntry] ^ dataLog post entryExists(mk_LogEntry(t,data)); (continued->)
7
Class MedicalDevice (cont.) … public entryExists: LogEntry ==> bool entryExists(logEntry) == for entry in dataLog do if logEntry.timeStamp = entry.timeStamp then return true else return false; public GetLatestEntries: nat ==> seq of LogEntry GetLatestEntries(amount) == return dataLog(1,...,amount) pre amount <= len dataLog post len dataLog(1,...,amount) = amount end MedicalDevice
8
Class PMUSystem (main) Operation of interest: CollectDataFromDevices class PMUSystem … public CollectDataFromDevices: seq of char ==> () CollectDataFromDevices(patientId) == ( for all pmu in set pmus do ( def patientIdFromRecord = pmu.RetrievePatientRecord().GetPatientId() in ( if (patientIdFromRecord = patientId) then def deviceList = pmu.RetrieveDeviceList() in for all device in set deviceList do pmu.PollDevice(device.GetDeviceId()) ) pre exists pmu in set pmus & pmu.RetrievePatientRecord().GetPatientId() = patientId; end PMUSystem
9
Testing the PMU System Benefits of the testing process Discover required functionality Testing with VDMUnit / IO Testcases Example: MedicalDevice unittest
10
Test case: MedicalUnit (1) class MedicalDeviceTest is subclass of TestCase … -- Test constructor protected TestInit: () ==> () TestInit() == (dcl mUnit : MedicalDevice := new MedicalDevice(1); AssertTrue(mUnit.GetDeviceId()= 1)); -- Test data entries protected TestDataEntries: () ==> () TestDataEntries() == (dcl mUnit : MedicalDevice := new MedicalDevice(1); mUnit.CreateDataEntry("some medical device data", 1); def lastDataEntry = mUnit.GetLatestEntries(1) in AssertTrue(hd lastDataEntry = mk_MedicalDevice`LogEntry(1,"some data")); ); end MedicalDeviceTest Code from MedicalUnitTest.vpp
11
Test case: MedicalUnit (3) Code from CompletePMUTest class CompletePMUTest operations public Execute: () ==> () Execute() == ( dcl ts: TestSuite:=new TestSuite(); ts.AddTest(new MedicalDeviceTest("MedicalDeviceTest")); ts.Run() ) end CompletePMUTest
12
Test case: MedicalUnit (1) Result ok?
13
Summary Todays presentation Recap and introduction of new class Clock Implementation of selected classes/ops. Testing with VDMUnit What’s next? Finish polishing off the implementation Extend test to other units and components Write down what we’ve learned in a really good report!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.