Unsafe State用于解决如何识别缺陷的问题。
第一类对应的识别语法为(next(相关属性) = 相关值)。
next(flag_onestate):=
case
-- unsafe对应的相关属性
next(attribute1)=1 & next(change_attribute)=1: 1;
-- TRUE: 0
TRUE:0;
esac;
第二类对应的识别语法为(flag_open和flag_close,若当前状态满足trigger则相应置为1,如果flag_open=flag_close,说明下一状态存在A.1)。
next(window.switch):=
case
next(flag_open)=1 & next(flag_close)=1:uncertain;
esac;
next(flag_open):=
case
humidity > 60: 1;
TRUE:0;
esac;
next(flag_close):=
case
temperature < 20: 1;
TRUE:0;
esac;
第三类对应的识别语法为连续两个state出现属性变化且不同值(loop / 开了马上关)。
4.2.4 变化规则配置——只改变规则配置解决Trigger-Interference中的loop
规则1: when illuminance < 100 , turn on light
规则2: when illuminace > 500 , turn off light
只会在illuminace < 100时出现缺陷
正常的修复方式:
100 + turn on light(可能实际是500但误判为300,是错在这,这个要在原始信息里获取) + 400 - light预期值300
可能smv 581就算修复好了,如何获得600、700
1.将常量配置信息light > 500改为变量light > config_value,其初始值为配置值
2.往大于500的值变化,因为light > 500
3.config_value:
flag:变化
TRUE:不变
4.2.5 变化规则语义——只改变语义解决A.1
if 8:00 am while Temperature < 20℃ , close window
if 8:00 am while humidity > 60% , open window
正常的修复方式:
生成新规则 if 8:00 am while Temperature < 20℃ and humidity > 60% ,让用户选择open、close window
改变老规则,调整为 Temperature < 20℃ & humidity < 60%;humidity > 60% & Temperature > 20℃
可能的方式:
因为trigger在建模前要写入文件,且不能像配置随意变化,所以考虑提前准备语义模板
如该例中,温度和湿度的模板
temperature_copy在flag时生效,用于修复,原属性代表实际环境
实验一
attribute是自然属性
change_attribute 安全的情况下让其等于原属性,不安全的情况下让其变为其它值
MODULE main
VAR
attribute1:0..1;
change_attribute:0..1;
change_attribute_copy:0..1;
another_trigger:{on, off};
flag_onesate:0..1;
ASSIGN
init(attribute1):= 0;
-- 模拟不可变的自然现象
next(attribute1):= 1;
init(another_trigger):= on;
init(change_attribute):= 0;
next(change_attribute):=
case
another_trigger = off:1;
another_trigger = on:0;
TRUE:change_attribute;
esac;
init(change_attribute_copy):= 0;
next(change_attribute_copy):=
case
-- 变化为非
next(flag_onesate)=1:0;
-- 安全的情况下让其等于原属性
TRUE:next(change_attribute);
esac;
init(flag_onesate):= 0;
next(flag_onesate):=
case
-- unsafe对应的相关属性
next(attribute1)=1 & next(change_attribute)=1: 1;
-- TRUE: 0
TRUE:0;
esac;
实验二
MODULE main
VAR
window.switch:{open, close, uncertain};
window.switch_old:{open, close, uncertain};
temperature:0..10;
humidity:10..20;
flag_open:0..1;
flag_close:0..1;
ASSIGN
init(temperature) := 5;
init(humidity) := 10;
init(window.switch) := close;
next(window.switch):=
case
next(flag_open)=1 & next(flag_close)=1:uncertain;
temperature < 5: close;
TRUE:window.switch;
esac union
case
next(flag_open)=1 & next(flag_close)=1:uncertain;
humidity > 15: open;
TRUE:window.switch;
esac;
init(window.switch_old) := close;
next(window.switch_old) := window.switch;
init(flag_open) := 0;
next(flag_open):=
case
humidity > 15: 1;
TRUE:0;
esac;
init(flag_close) := 0;
next(flag_close):=
case
temperature < 5: 1;
TRUE:0;
esac;
Unsafe State用于解决如何识别缺陷的问题。
第一类对应的识别语法为(next(相关属性) = 相关值)。
next(flag_onestate):=
case
-- unsafe对应的相关属性
next(attribute1)=1 & next(change_attribute)=1: 1;
-- TRUE: 0
TRUE:0;
esac;
第二类对应的识别语法为(flag_open和flag_close,若当前状态满足trigger则相应置为1,如果flag_open=flag_close,说明下一状态存在A.1)。
next(window.switch):=
case
next(flag_open)=1 & next(flag_close)=1:uncertain;
esac;
next(flag_open):=
case
humidity > 60: 1;
TRUE:0;
esac;
next(flag_close):=
case
temperature < 20: 1;
TRUE:0;
esac;
第三类对应的识别语法为连续两个state出现属性变化且不同值(loop / 开了马上关)。
4.2.4 变化规则配置——只改变规则配置解决Trigger-Interference中的loop
规则1: when illuminance < 100 , turn on light
规则2: when illuminace > 500 , turn off light
只会在illuminace < 100时出现缺陷
正常的修复方式:
100 + turn on light(可能实际是500但误判为300,是错在这,这个要在原始信息里获取) + 400 - light预期值300
可能smv 581就算修复好了,如何获得600、700
1.将常量配置信息light > 500改为变量light > config_value,其初始值为配置值
2.往大于500的值变化,因为light > 500
3.config_value:
flag:变化
TRUE:不变
4.2.5 变化规则语义——只改变语义解决A.1
if 8:00 am while Temperature < 20℃ , close window
if 8:00 am while humidity > 60% , open window
正常的修复方式:
生成新规则 if 8:00 am while Temperature < 20℃ and humidity > 60% ,让用户选择open、close window
改变老规则,调整为 Temperature < 20℃ & humidity < 60%;humidity > 60% & Temperature > 20℃
可能的方式:
因为trigger在建模前要写入文件,且不能像配置随意变化,所以考虑提前准备语义模板
如该例中,温度和湿度的模板
temperature_copy在flag时生效,用于修复,原属性代表实际环境
实验一
attribute是自然属性
change_attribute 安全的情况下让其等于原属性,不安全的情况下让其变为其它值
MODULE main
VAR
attribute1:0..1;
change_attribute:0..1;
change_attribute_copy:0..1;
another_trigger:{on, off};
flag_onesate:0..1;
ASSIGN
init(attribute1):= 0;
-- 模拟不可变的自然现象
next(attribute1):= 1;
init(another_trigger):= on;
init(change_attribute):= 0;
next(change_attribute):=
case
another_trigger = off:1;
another_trigger = on:0;
TRUE:change_attribute;
esac;
init(change_attribute_copy):= 0;
next(change_attribute_copy):=
case
-- 变化为非
next(flag_onesate)=1:0;
-- 安全的情况下让其等于原属性
TRUE:next(change_attribute);
esac;
init(flag_onesate):= 0;
next(flag_onesate):=
case
-- unsafe对应的相关属性
next(attribute1)=1 & next(change_attribute)=1: 1;
-- TRUE: 0
TRUE:0;
esac;
实验二
MODULE main
VAR
window.switch:{open, close, uncertain};
window.switch_old:{open, close, uncertain};
temperature:0..10;
humidity:10..20;
flag_open:0..1;
flag_close:0..1;
ASSIGN
init(temperature) := 5;
init(humidity) := 10;
init(window.switch) := close;
next(window.switch):=
case
next(flag_open)=1 & next(flag_close)=1:uncertain;
temperature < 5: close;
TRUE:window.switch;
esac union
case
next(flag_open)=1 & next(flag_close)=1:uncertain;
humidity > 15: open;
TRUE:window.switch;
esac;
init(window.switch_old) := close;
next(window.switch_old) := window.switch;
init(flag_open) := 0;
next(flag_open):=
case
humidity > 15: 1;
TRUE:0;
esac;
init(flag_close) := 0;
next(flag_close):=
case
temperature < 5: 1;
TRUE:0;
esac;