Vzorky - vyčítání historických databank

Vyčtení historických databank (vzorky), seznam a popis obslužných kanálů:

Kanál č. | Typ a směr | Popis
60000 | shortcard output | číslo stanice, ze které se budou číst vzorky (dle pořadí sekcí [STATION] v .PAR souboru)
60001 | shortcard output | číslo banky (1 až 3)
60002 | cardinal output | číslo vzorku (1-528), které se objeví na kanálech 60004-60017 a 60100-60291
60003 | boolean output | změna způsobí vynulování vzorků v paměti PC a jejich načtení podle nastavení kanálu 60000-2
60004 | shortcard input | rok (poslední dvoučíslí)
60005 | shortcard input | měsíc
60006 | shortcard input | den
60007 | shortcard input | hodina
60008 | shortcard input | minuta
60009 | shortcard input | sekunda
60010-60017 | longreal input | hodnoty vzorků (8 real.průběhů)
60018 | boolean input | probíhající čtení vzorků
60021 | boolean output | změna provede zápis aktualních vzorků do souboru .CUC
60022 | boolean bidirectional | čtení: true = poslední zápis .CUC byl OK, zápis: false = pro shození příznaku zápisu
60100-60291 | boolean input | hodnoty vzorků (192 binárních průběhů, 24bi na 1ad)
60292 | boolean output | log.1=zapnutí / log.0=vypnutí přenosu vzorků z Promos-RT-40, kanálem je nutno určit, že stanice je typu RT40, neboť tyto mají vzorky umístěné v jiných bankách.

Zápisem do kanálu 60003 bude do fronty požadavků pro čtení vloženo celkem 88 zpráv, kterými bude postupně vyčtena příslušná oblast historické databanky. Vzhledem k většímu počtu těchto zpráv může celé vyčtení trvat i několik minut (dle způsobu připojení stanice a komunikační rychlosti).

Doporučuje se vytvoření programu v aplikaci CW, který způsobí zápis do ovladače pro vyčtení historie, pozastavení veškeré jiné komunikace s jinými datovými body všech stanic a následné monitorování kanálu 490, což je aktuální počet požadavků pro čtení. Hodnota tohoto kanálu se bude postupně zmenšovat do nuly. Pak je již celá banka vyčtena a je možné ji dále zpracovat (kanály 60004-60291).

CUC soubory (kompatibilní s programem WZORKY)

- 60021 boolean output = změna provede zápis aktualních vzorků do souboru .CUC
- 60022 boolean bidirectional = čtení: true = poslední zápis .CUC byl OK, zápis: false = pro shození příznaku zápisu

Cestu .CUC souboru lze zadat do proměnné v .PAR souboru, sekce [GLOBAL], proměnná CUC_PATH. Způsob zadávání je shodný, jako u všech textových proměnných.
např.

    [GLOBAL]
      CUC_PATH "C:\Control Web 2000\Application\Data\CUC" ""
    END

Název souboru bude vytvořen podle poslední vyčtené banky vzorků, ve tvaru AaBYMMDD.CUC, kde

        Aa = adresa stanice, 01-99, nebo
             pokud je vetší než 100,
             tak se použije nasledující vzorec:
                  od adresy se odečte 100.
                  A=písmeno od "A", určující po odečtení desítky
                  a=jednotky po odečtení
             např. adresa 137: 137-100=37, tedy 3 odpovídá C a zbyde 7, tedy C7.

        B = číslo banky (1-4)
        Y = poslední číslice roku
        MM = měsíc
        DD = den

Jednoduchá ukázka aplikace pro vyčítání historických bank

Soubor RT_KPS1.PAR

    [COM]
      DRIVER SYSTEM 1
      IRQ 4
      BASE $03F8
      BAUD 4800
      BITS 8
      PARITY NONE
      STOP 1
      OPTIONS 0 { RS232 }
      BUFFER_SIZE 1024
    END

    [GLOBAL]
      PREFIX $E1 $5C
      SUFFIX NONE
      PRESUFFIX NONE
      ADDRESS $00
      ANSWER_TIME 3.0
      SILENCE_WAIT 500
      RTS_TIME_ON 300
      RTS_TIME_OFF 200
      DEF_ANALOG_IN_ADDR $D61A
      IDLE_TIME 10
      STOP_SELF_READING ON
    END

    [STATION]
    ORIGINAL_CHANNELS
    ADDRESS 1
    RETRANSLATION 01
    NAME "KPS1" ""
    NUM_BINAR_IN 96
    NUM_BINAR_OUT 24
    NUM_ANALOG_IN 64
    NUM_COUNTER_IN 8
    NUM_MEMORY_IN 0
    NUM_MEMORY_OUT 48
    BINAR_IN_XOR NONE
    BINAR_OUT_XOR NONE
    DEF_ANALOG_IN_ADDR FROM_GLOBAL
    DEF_MEMORY_IN NONE
    DEF_MEMORY_OUT
    1   $3101   { tin1 - posun UT                                                       }
    2   $3102   { c971 - sklon UT                                                       }
    3   $3201   { tin2 (rezerva)                                                        }
    4   $3202   { c972 (rezerva)                                                        }
    5   $3301   { tin3 (rezerva)                                                        }
    6   $3302   { c973 (rezerva)                                                        }
    7   $0101   { tup1 - pozad. teplota TUV                                             }
    8   $0201   { tup2 - pozad. dP TV                                                   }
    9   $0021   { ad33 - cas limit doplnovani                                           }
    10  $0029   { ad41 - max. TAVE1 - cas otev. pohonu UT z 0 do 100 % [sec]            }
    11  $0023   { ad35 - min. TVPM1 - minimum hor. limitu teploty TV                    }
    12  $0025   { ad37 - max. TVPM1 - maximum hor. limitu teploty TV                    }
    13  $002B   { ad43 - max. TAUV1 - cas otev. pohonu TUV z 0 do 100 % [sec]           }
    14  $0000   { (rezerva)                                                             }
    15  $0000   { (rezerva)                                                             }
    16  $0000   { (rezerva)                                                             }
    17  $0000   { (rezerva)                                                             }
    18  $0000   { (rezerva)                                                             }
    19  $0000   { (rezerva)                                                             }
    20  $0000   { (rezerva)                                                             }
    21  $0020   { ad32 - prevod ctc4 (rezerva)                                          }
    22  $001E   { ad30 - prevod ctc3 (rezerva)                                          }
    23  $001C   { ad28 - prevod vodomeru TV (Litr/impulz)                               }
    24  $001A   { ad26 - prevod vodomeru SV (Litr/impulz)                               }
    25  $310A   { PRZD1 - zacatek denniho utlumu UT                                     }
    26  $310B   { PRKD1 - konec                                                         }
    27  $310C   { PRZT1 - zacatek tydenniho utlumu UT                                   }
    28  $310D   { PRKT1 - konec                                                         }
    29  $310E   { DTIN1 - hodnota utlumu UT (st.C)                                      }
    30  $3139   { TVPM1 - limit max. teploty UT                                         }
    31  $3106   { TAVE1 - cas pohonu - viz. MO10                                        }
    32  $3103   { TVP1 - pozad. teplota TV                                              }
    33  $010A   { PUZD1 - zacatek denniho utlumu TUV                                    }
    34  $010B   { PUKD1 - konec                                                         }
    35  $010C   { PUZT1 - zacatek tydenniho utlumu TUV                                  }
    36  $010D   { PUKT1 - konec                                                         }
    37  $010E   { DTUP1 - hodnota utlumu TUV (st.C)                                     }
    38  $0C03   { KTUV1 - signal otevreni pohonu TUV (0.0 / 1.0) -> cist pres MI ?      }
    39  $0C02   { TAUV1 - viz MO13                                                      }
    40  $E1B4   { TUPP1 - zadana teplota TUV                                            }
    41  $020A   { PUZD2 - zacatek denniho utlumu dP-TV                                  }
    42  $020B   { PUKD2 - konec                                                         }
    43  $020C   { PUZT2 - zacatek tydenniho utlumu dP-TV                                }
    44  $020D   { PUKT2 - konec                                                         }
    45  $020E   { DTUP2 - hodnota utlumu dP-TV (kPa)                                    }
    46  $0C06   { KTUV2 - signal max. poz. freq. FM/dP-TV (0.0 / 1.0) -> cist pres MI ? }
    47  $0C05   { TAUV2 - cas narustu freq. FM z 0 do 100 % (sec)                       }
    48  $E1B7   { TUPP2 - zadana hodnota dP-TV (kPa)                                    }
    DEF_MEMORY_END
    DEF_COUNTER_IN
      1 YEAR 1.0 0
      2 YEAR 1.0 0
      3 REAL 1.0 0
      4 REAL 1.0 0
      5 REAL 1.0 0
      6 REAL 1.0 0
      7 REAL 1.0 0
      8 REAL 1.0 0
    DEF_COUNTER_END
    END

Soubor VZORKY.DMF

    begin
       1 -  96  boolean input
      97 - 192  boolean output
     193 - 256  real input
     257 - 304  real input
     305 - 404  real bidirectional
     405 - 434  real input
     450 - 459  real input
     460 - 463  boolean output
     464 - 465  boolean input
     466 - 470  boolean bidirectional
     471        boolean output
     472        boolean output
     473 - 499  real input
     60000 shortcard output
     60001 shortcard output
     60002 cardinal output
     60003 boolean output
     60004 - 60009 shortcard input
     60010 - 60017 real input
     60021 boolean output
     60022 boolean input
     60100 - 60291 boolean input
     65533 - 65534  real output
     65535  boolean output
    end.

Soubor VZORKY.CW

    const
      max_vz = 528;
    end_const;

    var
      vz_update = boolean, false;
      index = integer, 1;
    end_var;

    driver
      rt = CWDRT485.DLL, VZORKY.DMF, RT_KPS1.PAR;
    end_driver;

    channel
      ad1 = real, 193, rt, input;
      ad41 = real, 233, rt, input;
      ad41_write = real, 314, rt, bidirectional, 0;
      bo1 = boolean, 97, rt, output, false;
      bo2 = boolean, 98, rt, output, false;
      fronta = real, 490, rt, input;
      vz_ad =  array[ 60010..60017 ] of real, rt, input;
      vz_banka = shortcard, 60001, rt, output, 0;
      vz_bi =  array[ 60100..60291 ] of boolean, rt, input;
      vz_cuc = boolean, 60021, rt, output, false;
      vz_cuc_ok = boolean, 60022, rt, input;
      vz_day = shortcard, 60006, rt, input;
      vz_hour = shortcard, 60007, rt, input;
      vz_min = shortcard, 60008, rt, input;
      vz_month = shortcard, 60005, rt, input;
      vz_polozka = cardinal, 60002, rt, output, 0;
      vz_read = boolean, 60003, rt, output, false;
      vz_sec = shortcard, 60009, rt, input;
      vz_stanice = shortcard, 60000, rt, output, 0;
      vz_year = shortcard, 60004, rt, input;
    end_channel;

    timer

    end_timer;

    instrument

      window panel panel_1;
        timer = 1;
        owner = background;
        position = 14, 29, 713, 509;
      end_panel;

      label id_6;
        owner = panel_1;
        position = 631, 122;
        font = SYSTEM, 10, bold;
        text = 'CUC OK';
      end_label;

      indicator xx;
        timer = 1;
        owner = panel_1;
        position = 636, 138;
        expression = vz_cuc_ok;
      end_indicator;

      label id_6;
        owner = panel_1;
        position = 638, 35;
        font = SYSTEM, 10, bold;
        text = 'CUC';
      end_label;

      switch id_11;
        owner = panel_1;
        position = 630, 52, 48, 48;
        output = vz_cuc;
      end_switch;

      control set_index;
        owner = panel_1;
        position = 478, 91, 89, 22;
        output = ad41_write;
        mode = count_box;
        dec_places = 0;
        receivers = xx;
      end_control;

      meter id_1;
        timer = 1;
        owner = panel_1;
        position = 470, 11, 103, 73;
        expression = ad41;
        content = med;
        colors
          low_limit = lblue;
        end_colors;
      end_meter;

      switch id_11;
        owner = panel_1;
        position = 530, 130, 48, 48;
        output = bo2;
      end_switch;

      switch id_11;
        owner = panel_1;
        position = 475, 130, 48, 48;
        output = bo1;
      end_switch;

      indicator xx;
        timer = 1;
        owner = panel_1;
        position = 560, 257;
        expression = vz_bi[ 60107 ];
      end_indicator;

      indicator xx;
        timer = 1;
        owner = panel_1;
        position = 520, 257;
        expression = vz_bi[ 60106 ];
      end_indicator;

      indicator xx;
        timer = 1;
        owner = panel_1;
        position = 480, 257;
        expression = vz_bi[ 60105 ];
      end_indicator;

      indicator xx;
        timer = 1;
        owner = panel_1;
        position = 440, 257;
        expression = vz_bi[ 60104 ];
      end_indicator;

      indicator xx;
        timer = 1;
        owner = panel_1;
        position = 400, 257;
        expression = vz_bi[ 60103 ];
      end_indicator;

      indicator xx;
        timer = 1;
        owner = panel_1;
        position = 360, 257;
        expression = vz_bi[ 60102 ];
      end_indicator;

      indicator xx;
        timer = 1;
        owner = panel_1;
        position = 320, 257;
        expression = vz_bi[ 60101 ];
      end_indicator;

      indicator xx;
        timer = 1;
        owner = panel_1;
        position = 280, 257;
        expression = vz_bi[ 60100 ];
      end_indicator;

      switch id_2;
        owner = panel_1;
        position = 15, 268, 88, 25;
        output = vz_update;
        mode = text_button;
        true_text = 'UPDATE';
        false_text = 'UPDATE';
        receivers = prg_update;
        mono = 0.1, true;
      end_switch;

      chart zobr_vz;
        owner = panel_1;
        position = 15, 299, 579, 200;
        mode = flow_graph;
        low_limit = 0;
        high_limit = 100;
        history = 528;
        dec_places = 1;
        h_grid = 9;
        v_grid = 19;
        item
          expression = 10;
          color = white;
        end_item;
        item
          expression = 20;
          color = lyellow;
        end_item;
        item
          expression = 30;
          color = lmagenta;
        end_item;
        item
          expression = 40;
          color = lred;
        end_item;
        item
          expression = 50;
          color = lcyan;
        end_item;
        item
          expression = 60;
          color = lgreen;
        end_item;
        item
          expression = 70;
          color = lblue;
        end_item;
        item
          expression = 80;
          color = lgray;
        end_item;
      end_chart;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 540, 230, 54, 22;
        expression = vz_ad[ 60017 ];
        mode = text_display;
        dec_places = 1;
        font = FIXED, 12, normal;
        mask = '@@@.@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 480, 230, 54, 22;
        expression = vz_ad[ 60016 ];
        mode = text_display;
        dec_places = 1;
        font = FIXED, 12, normal;
        mask = '@@@.@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 420, 230, 54, 22;
        expression = vz_ad[ 60015 ];
        mode = text_display;
        dec_places = 1;
        font = FIXED, 12, normal;
        mask = '@@@.@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 360, 230, 54, 22;
        expression = vz_ad[ 60014 ];
        mode = text_display;
        dec_places = 1;
        font = FIXED, 12, normal;
        mask = '@@@.@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 511, 203, 54, 22;
        expression = vz_ad[ 60013 ];
        mode = text_display;
        dec_places = 1;
        font = FIXED, 12, normal;
        mask = '@@@.@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 451, 203, 54, 22;
        expression = vz_ad[ 60012 ];
        mode = text_display;
        dec_places = 1;
        font = FIXED, 12, normal;
        mask = '@@@.@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 391, 203, 54, 22;
        expression = vz_ad[ 60011 ];
        mode = text_display;
        dec_places = 1;
        font = FIXED, 12, normal;
        mask = '@@@.@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 331, 203, 54, 22;
        expression = vz_ad[ 60010 ];
        mode = text_display;
        dec_places = 1;
        font = FIXED, 12, normal;
        mask = '@@@.@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 296, 203, 29, 22;
        expression = vz_sec;
        mode = text_display;
        dec_places = 0;
        font = FIXED, 12, normal;
        mask = '@@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 261, 203, 29, 22;
        expression = vz_min;
        mode = text_display;
        dec_places = 0;
        font = FIXED, 12, normal;
        mask = '@@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 226, 203, 29, 22;
        expression = vz_hour;
        mode = text_display;
        dec_places = 0;
        font = FIXED, 12, normal;
        mask = '@@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 191, 203, 29, 22;
        expression = vz_day;
        mode = text_display;
        dec_places = 0;
        font = FIXED, 12, normal;
        mask = '@@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 156, 203, 29, 22;
        expression = vz_month;
        mode = text_display;
        dec_places = 0;
        font = FIXED, 12, normal;
        mask = '@@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      meter xx;
        timer = 1;
        owner = panel_1;
        position = 121, 203, 29, 22;
        expression = vz_year;
        mode = text_display;
        dec_places = 0;
        font = FIXED, 12, normal;
        mask = '@@';
        colors
          ink = black;
          paper = white;
          value = white;
          low_limit = white;
          high_limit = white;
        end_colors;
      end_meter;

      control set_index;
        owner = panel_1;
        position = 15, 203, 89, 22;
        output = vz_polozka;
        mode = count_box;
        range_from = 1;
        range_to = 528;
        init_value = 1;
        dec_places = 0;
        receivers = xx;
      end_control;

      label id_6;
        owner = panel_1;
        position = 14, 187;
        font = SYSTEM, 10, bold;
        text = 'zobrazit vzorek     rok    mes   den   hod   min    sec     data...';
      end_label;

      label id_6;
        owner = panel_1;
        position = 305, 132;
        font = SYSTEM, 10, bold;
        text = 'cislo banky';
      end_label;

      control id_5;
        owner = panel_1;
        position = 306, 148, 80, 22;
        output = vz_banka;
        mode = count_box;
        range_from = 1;
        range_to = 3;
        init_value = 3;
        dec_places = 0;
      end_control;

      label id_6;
        owner = panel_1;
        position = 305, 82;
        font = SYSTEM, 10, bold;
        text = 'cislo stanice';
      end_label;

      control id_5;
        owner = panel_1;
        position = 306, 98, 80, 22;
        output = vz_stanice;
        mode = count_box;
        range_from = 1;
        init_value = 1;
        dec_places = 0;
      end_control;

      indicator id_3;
        timer = 1;
        owner = panel_1;
        position = 424, 24;
        expression = fronta > 0;
      end_indicator;

      switch id_2;
        owner = panel_1;
        position = 303, 21, 108, 48;
        output = vz_read;
        mode = text_button;
        true_text = 'CTI VZORKY';
        false_text = 'CTI VZORKY';
      end_switch;

      meter id_1;
        timer = 1;
        owner = panel_1;
        position = 208, 16, 82, 152;
        expression = fronta;
        mode = vertical_bar;
        content = med;
        range_to = 200;
        dec_places = 0;
        colors
          low_limit = lblue;
        end_colors;
      end_meter;

      meter id_1;
        timer = 1;
        owner = panel_1;
        position = 15, 15, 180, 152;
        expression = ad1;
        content = med;
        colors
          low_limit = lblue;
        end_colors;
      end_meter;

      program prg_update;
        begin
          if vz_update then
            index = 1;
            while index <= max_vz do
              set_index.SetValue(index);
              pause 0;
              zobr_vz.SetLineIndexValue(0,index,vz_ad[60010]);
              zobr_vz.SetLineIndexValue(1,index,vz_ad[60011]);
              zobr_vz.SetLineIndexValue(2,index,vz_ad[60012]);
              zobr_vz.SetLineIndexValue(3,index,vz_ad[60013]);
              zobr_vz.SetLineIndexValue(4,index,vz_ad[60014]);
              zobr_vz.SetLineIndexValue(5,index,vz_ad[60015]);
              zobr_vz.SetLineIndexValue(6,index,vz_ad[60016]);
              zobr_vz.SetLineIndexValue(7,index,vz_ad[60017]);
              index = index + 1;
            end;
            zobr_vz.Paint();
            set_index.SetValue(1);
          end;
        end;
      end_program;

    end_instrument;