2

I am new to Jspin and Promela. I tried to implement the following system:

A home alarm system can be activated and deactivated using a personal ID key or password, after  activation the system enters a waiting period of about 30 seconds, time that allows users to evacuate the  secured area after which the alarm is armed, also when an intrusion is detected the alarm has a built in waiting period or delay of 15 seconds to allow the intruder to enter the password or swipe the card key thus identifying himself, in case that the identification is not made within the allocated 15 seconds the alarm  will go off and will be on until an id card or password is used to deactivate it.

This is the code:

mtype = {sigact, sigdeact};
chan signal = [0] of {mtype};
/*chan syntax for declaring and initializing message passing channels*/



int count;
bool alarm_off = true; /*The initial state of the alarm is off*/

active proctype alarm()

{
off:
    if 
    :: count >= 30 -> atomic {signal!sigdeact; count = 0;alarm_off = false; goto on;}
    :: else -> atomic {count++; alarm_off = true; goto off;}
    fi;

on:
    if
    :: count >=15 -> atomic { signal!sigact; count = 0;
    alarm_off = false; goto off;}
    :: else -> atomic {signal!sigact; alarm_off = true; goto off;}
    fi;

pending:

     if
     :: count >= 30 -> atomic {count = 0; alarm_off = false; goto on;}
     :: count < 30 -> atomic {count++; alarm_off = false; goto pending;}
     fi;
}

When I run the code with Jspin I get this message:

Error: undeclared variable: sigact

But I declared this in the header.

How can I solve this?

Patrick Trentin
  • 7,126
  • 3
  • 23
  • 40
Cristina
  • 21
  • 1

1 Answers1

1

According to the documentation of Promela, you are using mtype correctly.

In fact, I cannot reproduce your error with spin version 6.4.3, so I suspect this is a specific issue of Jspin not being correctly updated.

Unless you want to use spin instead of Jspin, you can try the following work-around, which should work even with Jspin:

#define sigact   0
#define sigdeact 1
chan signal = [0] of {short};   // or bool for only 2 values

...

Since no one ever reads from signal, I assume the system model is incomplete and that more processes will be added later on.

  1. Be aware that, in the following instruction sequence:

    atomic { signal!sigdeact; count = 0; alarm_off = false; goto on; }
    

    the atomicity will be temporarily lost by alarm because signal is a synchronous channel (it has size 0) and so another process has to be immediately scheduled for reading the message being sent.

  2. In off state, when count >= 30 you reset count back to 0, set alarm_off = false and then go to state on. In on state, you immediately set alarm_off back to true. Is this intended? It looks like some mistake, perhaps you meant to go to state pending.

  3. By reading the description of your system, it looks like the alarm is missing some kind of input signal. I suspect you are using the signal channel differently from its intended purpose.

  4. Shouldn't the model have some transition from state pending to off, in case the proper personal ID/password is used?

Patrick Trentin
  • 7,126
  • 3
  • 23
  • 40
  • Thanks for your answer. I have two questions acccording to you answer: `How` can I pass the input to the given `proctype` function, called `alarm` ? (according to the OP question). Furthermore, suppose we have wrote the `proctype` function which pass the `key` or `passoword` to `alarm` device. How can we adapt the `alarm` function based on given `password` or `key`. – Mihai Alexandru-Ionut Nov 13 '17 at 19:39
  • @Alexandru-IonutMihai you should open your own question, including the necessary pseudo-code, as comments on stackoverflow may be deleted at any point in time for no reason and it's difficult to discuss certain issues in the limited space of a comment. – Patrick Trentin Nov 13 '17 at 19:42
  • At this answer I can start a bounty bonus for you if you can help me. That's the reason i wrote the comment here. Do you want to post the question to another answer ? – Mihai Alexandru-Ionut Nov 13 '17 at 19:43
  • @Alexandru-IonutMihai I will gladly help you, but in a new separate question which clearly illustrates your problem. Be sure to tag it with `promela` and `spin`, and I'll catch it. :-) – Patrick Trentin Nov 13 '17 at 19:45
  • I post a question here : https://stackoverflow.com/questions/47272662/how-can-i-bind-the-given-input-to-another-proctype – Mihai Alexandru-Ionut Nov 13 '17 at 20:06