Results 1 to 5 of 5
  1. #1
    d4fl0w is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default Implementation idea for set of rules

    Hallo,

    I am currently working on a project with my research group. We are 3 people working on the project where we have this specification:

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Definitions:
    Temperature sensor reads: invalid, cold, warm, too warm
    Short Time Window: 5s
    Long Time Window: 20s

    Initial values:
    Short Time Window: 5s
    Temperature: invalid (undefined)

    Event:
    Triggering a "quick-stop" shuts the engine down.

    Rules:
    1. If the temperature sensor is more than 5s (short delay) "too warm" a quick stop occurs and the engine is shut off.
    2. If the temperature sensor was invalid and switches to valid again and during the following 5s the temperature is not cold a long delay of 20s is activated. In this state a "too warm" triggers the quick-stop after 20s (long delay). (Long delay replaces the initial short delay).
    3. If the temperature is "cold" then the 5s (short delay) is valid again.
    4. If the valid temperature switches to invalid the 5s (short delay) is valid again.
    5. If during the delay the valid temperature is not "too warm" for more than 0.1s the delay timer is reset to start a new delay period.
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------

    We have generated 3 different test suites with abstract test cases from three different models in three different programs, each person has exactly one model it created. Now we must implement our SUT, which will happen in Java, to mutate and compare the test suites. Our problem is that this implementation should best be created by someone who had nothing more to do with the project and does not already have a certain way of seeing the rules. So we would really appreciate it if someone would want to share his implementation idea with us.

    Thanks in advance,

    d4fl0w

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default Re: Implementation idea for set of rules

    What you've posted is very vague. You'll get a lot more help here if you post your own attempt at solving the problem, and ask questions about specific things you're having trouble with.
    Get in the habit of using standard Java naming conventions!

  3. #3
    d4fl0w is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default Re: Implementation idea for set of rules

    Alright but as I said the problem is I can't use my attempt because I created one of the three models and already have a certain view on the rules. But let me try to clarify what I need assistance with:

    I want to write a program in JAVA which will be our system under test. Now I have the 5 rules and the knowledge about the timers and the shut down. What I need is a programm which would have inputs like isEnginestopped:bool getDelay:int getTimer1state():enum and outputs like setTemperature(int,temp,time) and than simulates the rules.

    Question 1: How would you implement one of the rules?
    Question 2: How would you implement getter and setter methods?
    Question 3: Which class is most useful for such a timer implementation?

  4. #4
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default Re: Implementation idea for set of rules

    That sounds suspiciously like a homework question. I doubt anyone is going to help you unless you post your own attempt first.
    Get in the habit of using standard Java naming conventions!

  5. #5
    d4fl0w is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default Re: Implementation idea for set of rules

    Ok this is of course homework cause it is my master thesis project and I am not a very good JAVA programmer but we need someone who is I did not want any code at all just the idea how this could work. I made an first implementation so you see I do not want you to do my work just to help me out.

    I have a package like this

    Java Code:
    package implementation;
    
    /**
     * A dummy ECU for testing generated test cases.
     * This implementation shall be substituted by 
     * a meaningful implementation.
     * @author lachar
     *
     */
    public class ECUDummy implements IECU{
    
    	private int temperature;
    	private int time;
    	private boolean isEngineOn;
    
    	public ECUDummy()
    	{
    		temperature = 0;
    		time = 0;
    		isEngineOn = true;
    	}
    	
    	public boolean isEngineOn(int timestamp)
    	{
    		return isEngineOn;
    	}
    	
    	/**
    	 * Sets the temperature and turns of the engine when 
    	 * time is greater than 30.
    	 */
    	public void setTemperature(int temp, int duration) {
    		temperature = temp;
    		time += duration;
    		if (duration >= 30) isEngineOn = false;
    	}
    
    	
    	
    }
    An Interface like this:
    Java Code:
    package implementation;
    
    
    /** 
     * The ECU interface provides methods for changing the sensor's temperature, passing time
     * and for querying the engines state. 
     * @author lachar
     *
     */
    public interface IECU {
    
    	/** 
    	 * Sets the temperature of the ECU at a specified point of time
    	 * @param temp : temperature to set
    	 * @param timestamp : specified point of time
    	 */
    	public void setTemperature(int temp, int timestamp);
    	
    	/**
    	 * Return the engine's status at a certain point in time, 
    	 * which may be true if the engine is on and false otherwise.
    	 * @param timestamp : specified point of time
    	 * @return : returns the engine's state
    	 */
    	public boolean isEngineOn(int timestamp);
    	
    }
    A factory like this:
    Java Code:
    package implementation;
    
    
    /**
     * A factory for creating different instances of ECUs 
     * @author lachar
     *
     */
    public class ECUFactory {
    	
    	/**
    	 * By default this methods creates a ECUDummy 
    	 * @return
    	 */
    	public static IECU createECU()
    	{
    		return new ECUDummy();
    	}
    }
    And generated test Cases like this:
    Java Code:
    /** GENERATED CODE - DO NOT ALTER **/
    package test;
    import implementation.ECUFactory;
    import implementation.IECU;
    import junit.framework.TestCase;
    public class ConformiqTestSuite extends TestCase{
    
    	private IECU ecu;
    
    	protected void setUp() throws Exception {
    		super.setUp();
    		ecu = ECUFactory.createECU();
    	}
    
    	protected void tearDown() throws Exception {
    		super.tearDown();
    	}
    
    	public void testcase1(){
    		ecu.setTemperature(1, 0); //#info: Test step: tester sends record temperature { t: 1 } to in at 0.0
    		assertEquals(ecu.isEngineOn(30), false); //#info: Test step: SUT sends record stop { } to out at 30.0
    	}
    .
    .
    .
    .
    My Model would look like this:

    Java Code:
    VS_UINT8 EngineTemperatureControlVSDeduct (SEM_EVENT_TYPE EventNo)
    {
    
      /* scoped for events */
      {
        SEM_STATE_TYPE WSV[VS_NOF_STATE_MACHINES] =
        {
          STATE_UNDEFINED,
          STATE_UNDEFINED,
          STATE_UNDEFINED,
          STATE_UNDEFINED
        };
    
        switch (EventNo)
        {
        case SE_RESET:
          {
            WSV[0] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule1_Rule1Idle;
            WSV[1] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_Rule2Idle;
            WSV[2] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Engine_EngineOn;
            WSV[3] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_Rule5Idle;
          }
          break;
    
        case cold:
          {
            if ((CSV[0] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule1_TemperatureTooWarm))
            {
              WSV[0] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule1_Rule1Idle;
            }
            if ((CSV[1] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_ValidTemperature))
            {
              WSV[1] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_Cold;
            }
            setDelayShort();
            if ((CSV[3] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_Rule5Idle))
            {
              Timer(resetTimerEvent, 100);
              WSV[3] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_TemperatureColdOrWarm;
            }
          }
          break;
    
        case invalid:
          {
            if ((CSV[0] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule1_TemperatureTooWarm))
            {
              WSV[0] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule1_Rule1Idle;
            }
            if ((CSV[1] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_Cold))
            {
              WSV[1] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_Rule2Idle;
            }
            if ((CSV[1] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_LongDelay))
            {
              WSV[1] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_Rule2Idle;
            }
            setDelayShort();
            if ((CSV[3] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_TemperatureColdOrWarm))
            {
              WSV[3] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_Rule5Idle;
            }
          }
          break;
    
        case quickStop:
          {
            if ((CSV[2] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Engine_EngineOn))
            {
              WSV[2] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Engine_EngineOff;
            }
          }
          break;
    
        case resetTimerEvent:
          {
            if ((CSV[3] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_TemperatureColdOrWarm))
            {
              resetTimer();
              Timer(resetTimerEvent, 100);
              WSV[3] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_TemperatureColdOrWarm;
            }
          }
          break;
    
        case setDelayLongEvent:
          {
            if ((CSV[1] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_ValidTemperature))
            {
              setDelayLong();
              WSV[1] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_LongDelay;
            }
          }
          break;
    
        case tooWarm:
          {
            if ((CSV[0] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule1_Rule1Idle))
            {
              resetTimer();
              Timer(quickStop, delay);
              WSV[0] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule1_TemperatureTooWarm;
            }
            if ((CSV[1] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_Rule2Idle))
            {
              Timer(setDelayLongEvent, 5000);
              WSV[1] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_ValidTemperature;
            }
            if ((CSV[3] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_TemperatureColdOrWarm))
            {
              WSV[3] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_Rule5Idle;
            }
          }
          break;
    
        case warm:
          {
            if ((CSV[0] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule1_TemperatureTooWarm))
            {
              WSV[0] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule1_Rule1Idle;
            }
            if ((CSV[1] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_Rule2Idle))
            {
              Timer(setDelayLongEvent, 5000);
              WSV[1] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule2_ValidTemperature;
            }
            if ((CSV[3] == EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_Rule5Idle))
            {
              Timer(resetTimerEvent, 100);
              WSV[3] = EngineTemperatureControlTopstate_EngineTemperatureControlRegion_EngineTemperatureControlState_Rule5_TemperatureColdOrWarm;
            }
          }
          break;
    
        default:
          return SES_RANGE_ERR;
        }
    
        /* Change the state vector */
        {
          VS_UINT i;
          for (i = 0u; i < VS_NOF_STATE_MACHINES; ++i)
          {
            if (WSV[i] != STATE_UNDEFINED)
            {
              CSV[i] = WSV[i];
            }
          }
        }
      }
    
      return SES_OKAY;
    }
    
    
    void EngineTemperatureControlVSInitAll (void)
    {
    }
    The last Code fragment is a generated Code from one of the models in ANSIC89 but the idea should be the same switch/case and a changing state vector.

    Now my Questions:

    How can these fragments be useful connected ?
    How should I implement the Timer functions? Is there a useful class I can use?
    Is there some part I should change? When yes how and why?

    I hope you can provide me with some help on my questions!

    d4fl0w

Similar Threads

  1. Architecture Rules 2.1.1
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 07-11-2008, 02:39 PM
  2. Architecture Rules 2.1.0
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 07-05-2008, 06:18 PM
  3. Replies: 1
    Last Post: 07-05-2008, 03:08 PM
  4. Architecture Rules 2.0.1
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 11-17-2007, 02:03 PM
  5. Architecture Rules 2.0-rc2
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 11-14-2007, 06:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •