A apresentação está carregando. Por favor, espere

A apresentação está carregando. Por favor, espere

RT-EXPERT Artis Corp. C calling program RTSUB [rule set subroutine] RTSUB [rule set subroutine] RTSUB [rule set subroutine]... DSL Decision Support Language.

Apresentações semelhantes


Apresentação em tema: "RT-EXPERT Artis Corp. C calling program RTSUB [rule set subroutine] RTSUB [rule set subroutine] RTSUB [rule set subroutine]... DSL Decision Support Language."— Transcrição da apresentação:

1 RT-EXPERT Artis Corp. C calling program RTSUB [rule set subroutine] RTSUB [rule set subroutine] RTSUB [rule set subroutine]... DSL Decision Support Language [Ada like syntax] Cada conjunto de regras (ex. 10 a 30 regras) pode ser visto como um domínio de decisão – ex. Supervisão dum dispositivo Chamados repetidamente !!! if... then... else... ; if... then... ; if temperatura > 70 then aquecedor := ON else aquecedor := OFF ; Cada RTSUB num ficheiro separado Módulos de raciocínio / tomada de decisão embebidos num programa tradicional

2 Variáveis DSL value -> pode ser undefined time -> tempo da última alteração Importance -> importância da informação contida na variável A parte das regras é re-avaliada se e só se as variáveis que aí aparecem tiverem sido alteradas desde o último disparo das regras. Para determinar qual a regra a disparar primeiro quando várias regras podem ser disparadas. variavel’time variavel’importance

3  Apontador para um record  (variável DSL)  As únicas que podem levar ao disparo de regras  O atributo “time” será usado para determinar se as regars devem ser (re-) avaliadas Se isto não fosse indicado era assumido que todos os parâmetros tinham mudado desde a última chamada a temp_ctl RTSUB temp_ctl (temperature: ATTRIB FLOAT; contrl: ATTRIB SYMBOLIC; heater: ATTRIB SYMBOLIC; lo_limit, hi_limit: IN FLOAT) IS DECLARE RUN, STOP, ON, OFF ARE SYMBOLIC CONSTANT; INIT PRAGMA RULE_TRIGGER IS NEW_DATA; BEGIN – Start of RTSUB rules IF control =RUN AND heater =undefined THEN heater := ON; IF control = undefined OR control =STOP THEN heater := OFF; IF temperature > hi_limit AND heater =ON AND time_now – heater’time > 3 seconds AND control = RUN THEN heater := OFF; IF temperature < lo_limit AND heater = OFF AND time_now – heater’time > 3 seconds AND control = RUN THEN heater := ON; END; Comentári o Regras Iniciali- zação Afecta não só o valor do atributo, mas também o “time”

4 ... #include “temp_ctl.h”... main () { static dsl_FLOAT temperature: static dsl_SYMBOL control; static dsl_SYMBOL heater; float lo_limit, hi_limit; lo_limit = 90.0; hi_limit = 110.0;... init_temp_ctl(&temperature, &control, &heater, lo_limit, hi_limit);... while (1) {... temp_ctl(&temperature, &control, &heater, lo_limit, hi_limit);... } RTSUB temp_ctl (temperature: ATTRIB FLOAT; contrl: ATTRIB SYMBOLIC; heater: ATTRIB SYMBOLIC; lo_limit, hi_limit: IN FLOAT) IS... INIT... BEGIN... END; Chamada a partir dum programa C Procedimentos C gerados pelo compilador RTX -Determina um equivalente numérico para as constantes simbólicas -Inicializa o campo “value” das variáveis DSL -Inicializa o “time” com o valor do tempo actual -Executa a parte INIT do módulo RTSUB -...

5 Data-driven vs. procedimental IF time_now – temperature’time > 1 THEN BEGIN temperature := get_input; PRINC “temperature is “, temperature, “ at “, time_now; END; Data driven Procedimental (sequencial) Ordem de execução das regras LEXICAL – a importância é dada pela sequência da declaração (assumido em caso de omissão) DATA – a importância da regra é herdada da importância do seu mais recente item de dados RECENCY – Precedência dada à regras cujas variáveis (da parte condição) foram modificadas mais recentemente => PRAGMA ORDER

6 RTSUB get_temperature( temperature: ATTRIB FLOAT) IS DECLARE DYNAMIC FUNCTION get_input RETURN FLOAT; INIT temperature := get_input; BEGIN IF time_now – temperature’time > 1 second THEN BEGIN temperature := get_input; PRINC “temperatur is “, temperature, “ at “, time_now; END; RTSUB set_heater(heater: ATTRIB SYMBOL) IS DECLARE PROCEDURE set_output(val: SHORT); ON, OFF ARE SYMBOLIC CONSTANT; INIT PRAGMA RULE_TRIGGER IS NEW_DATA; BEGIN IF heater HAS CHANGED THEN PRINC “heater “, heater; IF heater = ON THEN set_output(1); IF heater = OFF THEN set_output(0); END; RTSUB get_ctl(control: ATTRIB SYMBOL) IS DECLARE RUN, STOP ARE SYMBOLIC CONSTANT; c IS CHAR; DYNAMIC TIME FUNCTION kbhit RETURN INT; DYNAMIC FUNCTION getch RETURN CHAR; PROCEDURE exit(errcode: IN INT); BEGIN IF kbhit /= 0 THEN c := getch; IF c = ESC THEN exit(0); IF c = ‘r’ OR c = ‘R’ THEN control := RUN; IF c = ‘s’ OR c = ‘S’ THEN control := STOP; IF c HAS CHANGED THEN PRINC “Control is “, control; END; #include #include “temp_ctl.h” #include “set_heat.h” #include “get_temp.h” #include “get_ctl.h” main () { static dsl_FLOAT temperature: static dsl_SYMBOL control; static dsl_SYMBOL heater; float lo_limit, hi_limit; lo_limit = 90.0; hi_limit = 110.0; init_temp_ctl(&temperature, &control, &heater, lo_limit, hi_limit); Init_set_heater(&heater); Init_get_temperature(&temperature); Init_get_ctl(&control); while (1) { get_ctl(&control); get_temperature(&temperature); temp_ctl(&temperature, &control, &heater, lo_limit, hi_limit); set_heater(&heater); } RTSUB temp_ctl (temperature: ATTRIB FLOAT; contrl: ATTRIB SYMBOLIC; heater: ATTRIB SYMBOLIC; lo_limit, hi_limit: IN FLOAT) IS DECLARE RUN, STOP, ON, OFF ARE SYMBOLIC CONSTANT; INIT PRAGMA RULE_TRIGGER IS NEW_DATA; BEGIN – Start of RTSUB rules IF control =RUN AND heater =undefined THEN heater := ON; IF control = undefined OR control =STOP THEN heater := OFF; IF temperature > hi_limit AND heater =ON AND time_now – heater’time > 3 seconds AND control = RUN THEN heater := OFF; IF temperature < lo_limit AND heater = OFF AND time_now – heater’time > 3 seconds AND control = RUN THEN heater := ON; END;

7 Diferenças em relação aos sistemas periciais tradicionais: -Orientado para a construção de sistemas de tempo-real -Regras são compiladas, não interpretadas -As regras são disparadas num modelo “data-flow” -As variáveis têm tipos, para permitir verificação pelo compilador -Orientadas para raciocinar sobre o tempo em que eventos ocorrem -Podem efectuar cálculos sobre variáveis que estão definidas apenas em períodos limitados de tempo -As regras podem ser automaticamente re-disparadas pela passagem do tempo -As regras podem incluir uma parte “else” A base de regras não é “monolítica”. A modularização é incentivada – cada RTSUB contém um pequeno número de regras


Carregar ppt "RT-EXPERT Artis Corp. C calling program RTSUB [rule set subroutine] RTSUB [rule set subroutine] RTSUB [rule set subroutine]... DSL Decision Support Language."

Apresentações semelhantes


Anúncios Google