1 / 7

RT-EXPERT Artis Corp.

RT-EXPERT Artis Corp. RTSUB [rule set subroutine]. C calling program. DSL Decision Support Language [Ada like syntax]. RTSUB [rule set subroutine]. Cada RTSUB num ficheiro separado. RTSUB [rule set subroutine].

Télécharger la présentation

RT-EXPERT Artis Corp.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RT-EXPERT Artis Corp. RTSUB [rule set subroutine] C calling program DSL Decision Support Language [Ada like syntax] RTSUB [rule set subroutine] ... Cada RTSUB num ficheiro separado RTSUB [rule set subroutine] 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 !!! Módulos de raciocínio / tomada de decisão embebidos num programa tradicional if ... then ... else ... ; if ... then ... ; if temperatura > 70 then aquecedor := ON else aquecedor := OFF ;

  2. value -> pode ser undefined time -> tempo da última alteração Importance -> importância da informação contida na variável Variáveis DSL A parte <condição> 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 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; • O atributo “time” será usado para determinar se as regars devem ser (re-) avaliadas Iniciali- zação Se isto não fosse indicado era assumido que todos os parâmetros tinham mudado desde a última chamada a temp_ctl Regras Comentário Afecta não só o valor do atributo, mas também o “time”

  4. Chamada a partir dum programa C ... #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); ... } } • -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 • ... RTSUB temp_ctl (temperature: ATTRIB FLOAT; contrl: ATTRIB SYMBOLIC; heater: ATTRIB SYMBOLIC; lo_limit, hi_limit: IN FLOAT) IS ... INIT ... ... BEGIN ... ... END; Procedimentos C gerados pelo compilador RTX

  5. Data-driven vs. procedimental Data driven IF time_now – temperature’time > 1 THEN BEGIN temperature := get_input; PRINC “temperature is “, temperature, “ at “, time_now; END; 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. #include <rtx.h> #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 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; 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 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; 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;

  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

More Related