package mci.checker;

import kr.ac.kaist.se.mc.CheckerInterface;
import kr.ac.kaist.se.simulator.DebugProperty;
import kr.ac.kaist.se.simulator.DebugTick;
import kr.ac.kaist.se.simulator.SIMResult;

import java.util.HashMap;
import java.util.Map;

/**
 * AbsenceChecker.java

 * Author: Junho Kim <jhim@se.kaist.ac.kr>

 * The MIT License (MIT)

 * Copyright (c) 2016 Junho Kim

 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions: TBD
 */

public class AbsenceChecker implements CheckerInterface{

    /**
     * evaluateSample Method
     *
     * @param res
     * @return
     */
    @Override
    public int evaluateSample(SIMResult res) {
        HashMap<Integer, DebugTick> traceMap = res.getDebugTraces();
        HashMap<String, String> patientStatusMap = new HashMap<>();

        for(Map.Entry <Integer,DebugTick> t: traceMap.entrySet()){
            for(Map.Entry<String, DebugProperty> debugTick: t.getValue().getDebugInfoMap().entrySet()){
                String name = debugTick.getKey();
                if(name.contains("Patient")){
                    String stat = (String) debugTick.getValue().getProperty("stat");
                    if(patientStatusMap.containsKey(name)){
                        String beforeStat = patientStatusMap.get(name);
                        if(beforeStat.equalsIgnoreCase("DEAD") && !stat.equalsIgnoreCase("DEAD"))
                            return 0;
                    }else{
                        patientStatusMap.put(name, stat);
                    }
                }
            }
        }
        return 1;
    }

    @Override
    public int getMinTick() {
        return 0;
    }

    @Override
    public int getMaxTick() {
        return 0;
    }
}

@@ -937,41 +937,322 @@
    *
-%0A     * @param res%0A     * @return
+ Evaluate a given property satisfies absence property%0A     * Check all time ticks whether there is a patient whose status changes%0A     * from DEAD to other status (Dangerous or Very_Dangerous)%0A     * @param res Simulation result class which contains debugTick Map%0A     * @return 1, there is an absence, otherwise 0
 %0A   
@@ -2068,25 +2068,25 @@
      return 
-0
+1
 ;%0A          
@@ -2235,25 +2235,25 @@
      return 
-1
+0
 ;%0A    %7D%0A%0A   

Add comment for AbsenceChecker