personal medical unit lars sarbæk kristiansen20050013 kasper j. nielsen19980150 martin...

13
Personal Medical Unit Lars Sarbæk Kristiansen 20050013 Kasper J. Nielsen 19980150 Martin Kjeldsen 20002072

Upload: samson-greer

Post on 03-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

Personal Medical Unit

Lars Sarbæk Kristiansen 20050013

Kasper J. Nielsen 19980150

Martin Kjeldsen 20002072

Page 2: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

Agenda Last time

Updated classdiagramFirst draft of implementation

TodayUpdated classdiagram Implementation of selected classes/ops.Testing with VDMUnit

Page 3: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

Updated class diagram Class Clock represents global time

Page 4: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

Classes of interest

Class Clock Representation of global time

i.e. Need to determine patient records last update

Class MedicalDevice Class PMUSystem (main)

Page 5: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

Class Clockclass 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

Page 6: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

Class MedicalDeviceclass 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->)

Page 7: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

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

Page 8: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

Class PMUSystem (main) Operation of interest: CollectDataFromDevicesclass 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

Page 9: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

Testing the PMU System

Benefits of the testing processDiscover required functionality

Testing with VDMUnit / IOTestcases

Example: MedicalDevice unittest

Page 10: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

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

Page 11: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

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

Page 12: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

Test case: MedicalUnit (1) Result ok?

Page 13: Personal Medical Unit Lars Sarbæk Kristiansen20050013 Kasper J. Nielsen19980150 Martin Kjeldsen20002072

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!