Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public ›...

261
Disseny d’un programa amb C++ Builder per el control d’un sistema de generació de barreges gasoses TITULACIÓ: Enginyeria Tècnica de Telecomunicacions Especialitat en Telemàtica AUTOR: Heily Ferrer Urbaez DIRECTOR: Jesús Brezmes Llecha Data: Juny / 2007

Transcript of Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public ›...

Page 1: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Disseny d’un programa amb C++ Builder per el control d’un sistema de generació de barreges gasoses

TITULACIÓ: Enginyeria Tècnica de Telecomunicacions Especialitat en Telemàtica

AUTOR: Heily Ferrer Urbaez

DIRECTOR: Jesús Brezmes Llecha

Data: Juny / 2007

Page 2: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Índex

2

Índex

Agraïments .................................................................................................................4

1. Introducció ............................................................................................................5

1.1. Antecedents ....................................................................................................5

1.2. Objecte i justificació del projecte...................................................................5

2. Memòria descriptiva ..............................................................................................7

2.1. Anàlisi de requeriments .................................................................................7

2.2. Possibles solucions i solucions adoptades......................................................9

2.3. Descripció funcional.....................................................................................10

3. Memòria de càlcul ...............................................................................................13

3.1. Esquema general...........................................................................................13

3.1.1. Plantilla principal...............................................................................13

3.1.2. Plantilles secundaries actives.............................................................16

3.1.3. Plantilles secundaries passives ..........................................................21

3.2. Blocs funcionals ...........................................................................................24

3.2.1. Plantilla principal...............................................................................24

3.2.2. Plantilles secundaries.........................................................................39

3.3. Diagrames de flux ........................................................................................48

4. Manual d’usuari ...................................................................................................55

4.1. Instal·lació ....................................................................................................55

4.1.1. Requisits del sistema .........................................................................55

4.1.2. Recomanacions..................................................................................55

4.2. Introducció....................................................................................................56

4.3. Cas pràctic ....................................................................................................56

5. Conclusions .........................................................................................................66

5.1. Conclusions .................................................................................................66

5.2. Treball futur..................................................................................................66

6. Bibliografia .........................................................................................................67

Page 3: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Índex

3

7. Annexes ...............................................................................................................68

7.1. Annex 1: Codi font del programa.................................................................68

7.1.1. Project 2.cpp ......................................................................................68

7.1.2. FlowbusAPI.h ....................................................................................69

7.1.3. FlowbusAPI.cpp ..............................................................................100

7.1.4. GlobalVariables.h ............................................................................104

7.1.5. GlobalVariables.cpp ........................................................................105

7.1.6. Unit1.h .............................................................................................106

7.1.7. Unit1.cpp .........................................................................................108

7.1.8. Unit2.h .............................................................................................115

7.1.9. Unit2.cpp .........................................................................................119

7.1.10. Unit3.h .............................................................................................128

7.1.11. Unit3.cpp .........................................................................................132

7.1.12. Unit4.h .............................................................................................153

7.1.13. Unit4.cpp .........................................................................................155

7.1.14. PagesDlg.h.......................................................................................158

7.1.15. PagesDlg.cpp ...................................................................................160

7.2. Annex 2: Operation instructions digital Mass Flow / Pressure instruments

parameters and properties............................................................................165

7.3. Annex 3: RS232 interface With FLOW-BUS protocol for digital Mass Flow

/ Pressure instruments..................................................................................202

7.4. Annex 4: Interface Design Document Flow-Bus DLL

FOR WIN32 ................................................................................................241

Page 4: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Agraïments

4

Agraïments

Vull agrair a totes aquelles persones que han fet possible la realització d’aquest projecte.

En primer lloc vull dedicar aquest projecte als meus pares, qui m’han donat els ànims i el suport necessari per a tirar endavant els meus estudis i també per a tot el suport rebut durant la realització d’aquest. En segon lloc i especialment al Jesús, director del projecte, que ha dipositat la confiança en mi per a poder desenvolupar-lo, per els bons consells i el suport rebut durant tot aquest temps També vull donar les gràcies al tècnics del laboratori de recerca: al Raül, a la Roser, al Jordi, a l’Alex... per tots aquells moments difícils en que m’han donat ànims i han fet possible que el projecte seguis avançant.

També vull donar les gràcies a tots aquells programadors que, a través del correu electrònic i a través de foros, m’han animat per tirar endavant el projecte.

Page 5: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Introducció

5

1. Introducció

1.1. Antecedents

La Universitat Rovira i Virgili ha treballat i està actualment treballant, per diferents vies d’investigació, amb sensors utilitzats per la detecció de gasos. Aquests es troben dins una cambra hermètica construïda de metacrilat, en un entorn totalment aïllat de l’exterior, anomenada cambra de gasos. Entre aquests podrem trobar-ne de comercials, de silici, d’òxid d’estany i entre ells alguns, de propi disseny de la mateixa Universitat.

Donada la sensibilitat d’aquests sensors, és molt important saber en tot moment el flux de gas que entra a la cambra per fer la barreja de gasos i és per això que s’ha optat perquè unes vàlvules digitals, anomenades Mass Flow Controllers (MFC), siguin les encarregades de regular el cabal subministrat per unes bombones. Aquestes vàlvules, com el seu nom ens indica, són les encarregades d’operar un flux de massa, en aquest cas gasós. Les ordres de control són programades i enviades d’es d’un ordinador via port sèrie.

Dins els MFC hi trobem una base de silici la qual conté en el seu interior un filament conductor que actua com una resistència o heater i un sensor de temperatura. Aquesta base és escalfada degut a les càrregues elèctriques que circulen pel fil conductor, al mateix temps, és refredada per la fluctuació de gas depenen del seu pes atòmic. El sensor de temperatura és l’encarregat d’ajustar una precisa vàlvula d’agulla que acaba regulant el flux de gas.

El document descriu els objectius bàsics que el projecte vol assolir i quines premisses haurem de tenir en compte per aconseguir dur a terme el desenvolupament del sistema amb l’èxit i resultats esperats per al bon control de les vàlvules.

1.2. Objecte i justificació del projecte

L’objectiu del projecte és desenvolupar un software que permeti controlar el fluxes de gasos subministrats pels Mass Flows amb la finalitat de generar una barreja de gasos definida per l’usuari.

El projecte final de carrera s’atén a un requisit imposat per la universitat i és que la implementació del programa s’ha de desenvolupar en C++ Builder.

La mateixa URV disposa d’una llicència de Borland® C++Builder® Preview for Microsoft® Windows™ que és el software utilitzat per desenvolupar el programa.

Els següents punts resumeixen els objectius més importants del programa implementat en aquest projecte final de carrera:

- Controlar la comunicació entre l’usuari i els Mass Flows amb el port RS232.

- Assegurar la comunicació durant el temps de connexió.

- Controlar les vàlvules que formen part de la xarxa.

- Fixar un percentatge d’obertura de flux per a les vàlvules.

- Llegir els cabals de les vàlvules i representar-los en una gràfica.

Page 6: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Introducció

6

- Visualitzar i guardar en un fitxer un històric de comandes.

- Visualitzar els possibles errors l’execució del programa.

- Visualitzar un històric de mesures i guardar-lo en un fitxer de forma automàtica.

- Controlar el calibratge de les vàlvules per diferents tipus de fluids d’entrada.

- Calcular de forma automàtica l’obertura de les vàlvules segons un cabal màxim de sortida i la concentració desitjada pels diferents de gasos.

- Programar les vàlvules per a un procés automàtic de funcionament mitjançant un fitxer en format CSV per la introducció de paràmetres.

- Disseny d’una interfície gràfica que faciliti la interacció amb l’usuari final.

El present projecte s’acompanya d’un CD que conté l’instal·lador del programa, encarregat de generar els directoris i carregar les llibreries necessàries per al seu correcte funcionament. En aquesta també s’incorpora un manual d’usuari i altra informació relativa als MFC. El directori s’ubica a C:\FlowBusDDE.

Aquest programa serà obert per a modificacions i/o revisions futures amb la finalitat de poder afegir-hi noves funcions, noves configuracions de xarxa, etc.

Page 7: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria descriptiva

7

2. Memòria descriptiva

2.1. Anàlisis de requeriments

A continuació s’ofereix un llistat amb totes les funcionalitats oferirà el sistema. Aquest llistat no està tancat i evidentment pot ser que en les següents revisions s’hi produeixin canvis.

- L’usuari ha de ser capaç d’utilitzar completament l’aplicació amb l’ajuda del manual d’usuari.

El programa té dos modes principals de funcionament que els podem etiquetar com a Manual i Automàtic.

Mode Manual:

- És com un model de proves en el que l’usuari disposa gairebé del cent per cent de les funcions que pot executar el programa. Aquest model està pensat per a què l’usuari testegi el funcionament i la resposta dels MFC permetent doncs amb posterioritat un accés al mode automàtic amb els coneixements necessaris per a programar-lo e interpretar els resultats obtinguts.

Seguidament es mostra un llistat detallant les opcions accessibles per aquest mode:

- Escollir la configuració del COM (port i baud rate).*

- Establir comunicació amb el sistema. *

- Visualitzar i guardar un històric de comandes. *

- Visualitzar un històric de mesures (generat de forma automàtica i guardat en un

fitxer de text). *

- Controlar els errors mostrats en una finestra de text amb codi i descripció de l’error.

- Escriure un percentatge d’obertura (Set point) a qualsevol de les vàlvules i poder aturar el procés en qualsevol moment. Aquest percentatge ha d’estar entre 0 i 100; permet introduir decimals utilitzant una coma ( , ).

- Visualitzar el percentatge d’obertura i la mesura del flux en tant per cent (%) associat a cadascun dels MFC. *

- Visualitzar una representació gràfica de les mesures obtingudes. *

- Fer una lectura del fluid amb el qual estan calibrats els MFC. Actualment existeixen dos calibratges: N2 (aire) i CO2(diòxid de carboni).

- Modificar el mode de calibratge, és a dir, canviar per exemple de N2 a Co2.

- Definir nous fluids, amb una capacitat de fins a 9 models, com ara Ar (argó), etc.

* Funcions compartides en els modes manual i automàtic. No es repetiran en la descripció del mode automàtic.

Page 8: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria descriptiva

8

- Poder calcular la obertura de les vàlvules de forma automàtica partint d’un flux màxim desitjat a la sortida e introduint les concentracions de gas en ppm de l’ampolla i la desitjada en la barreja per als MFC que es desitgin.

- Generar un fitxer csv partint d’una plantilla, incorporada a la instal·lació, amb els paràmetres desitjats per a la seva reproducció en mode automàtic. Obrir altres fitxers csv.

- Testejar la comunicació en qualsevol moment de la sessió *.

- Tancar la comunicació. *

- Sortir del programa. *

Important: En el moment en que es carregui el fitxer CSV per a que s’executi, el programa passa a funcionar en mode automàtic.

Mode Automàtic:

Aquest mode està pensat per a una execució del programa ininterrompuda durant un període de temps definit per l’usuari.

Per accedir a aquest mode hem de tenir en compte dos factors previs: el primer és que hem de generar un fitxer en format csv. Aquest emmagatzemarà en forma de taula els MFC amb uns percentatges d’obertura i uns temps d’espera seqüencials per a l’execució d’instruccions.

El segon és que quant accedim a la opció de carrega el fitxer, totes les tasques que s’estiguin executant en aquells moment deixaran de fer-ho per canviar la configuració del programa. Totes les opcions del mode manual no compartides seran deshabilitades, principalment resumides a les funcions d’escriptura. El control d’escriptura deixa d’estar controlat per l’usuari i s’inicia un procés automàtic d’execució. Això fa que les opcions d’actuació per part de l’usuari es redueixin a funcions de lectura.

En qualsevol moment que ho desitgi l’usuari pot aturar el procés d’execució d’aquest mode, tornant doncs al mode de funcionament manual. Es recomana com a pas previ realitzar totes les proves pertinents en el mode manual per generar correctament el fitxer csv.

* Funcions compartides en mode manual i en mode automàtic. No es repetiran en la descripció del mode automàtic.

Page 9: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria descriptiva

9

2.2. Possibles solucions i solució adoptada

Per realitzar aquest projecte s’ha estudiat prèviament el procés actual que segueix el sistema per a cadascuna de les parts afins.

En primer lloc es varen analitzar els components físics implicats en el sistema de detecció: els sensors, les vàlvules d’interconnexió, Reguladors, Mass Flows, connectors, cablejat i connexionat d’aquests.

Per un altra costat es va estudiar el programa, propietari de la casa Bronkhorst High-

Tech, que actualment és encarregat de controlar les vàlvules. Aquestes són programades per la interfície RS232 hi utilitzen un protocol específic anomenat Flow-Bus Protocol (FBP).

Es poden definir diferents nivells de comunicació:

En el nivell més baix trobem una la interfície RS232 que connecta directament amb el sistema. Aquest ens permet establir una comunicació basada en cadenes específiques de bytes que són convertides a ASCII i enviades pel port RS232 a la interfície. Inicialment es va intentar utilitzar, però es varen fer varies proves amb les vàlvules sense èxit. Aquestes no van respondre com s’esperava.

En un segon nivell podem utilitzar una comunicació entre la interfície i l’ordinador mitjançant una DLL (Dynamic Linking Library) de Windows utilitzada per enllaçar la E/S del port RS232 de la màquina amb el sistema.

Hi ha un nivell més alt que consisteix en una DDE (Dynamic Data Exchange) de Windows la que ens permet a les diferents aplicacions obrir sessions entre elles, enviar i rebre comandes al servidor d’aplicacions i rebre respostes. Aquesta forma part del bus de comunicacions.

Figura 1: Flowbus DDE i estructura de comunicació.

S’ha optat per implementar una aplicació a nivell alt en la que intervenen les diferents parts abans esmentades i que mostra la Figura 1. Per a la comunicació amb la DLL s’utilitza una APi facilitada per Bronkhorst en la que hi ha definides les funcions que ens permeten interactuar amb els dispositius. Per facilitar la interacció amb l’usuari el programa es presenta amb una interfície gràfica la qual comentarem més endavant.

Page 10: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria descriptiva

10

2.3. Descripció funcional

Un cop descrits els dos modes de treball del programa conjuntament amb les seves funcionalitats, es matisarà cadascuna d’aquestes per conduir a l’usuari a un millor coneixement del sistema.

Configuració RS232

L’usuari ha de ser capaç d’establir una comunicació amb el sistema tenint la possibilitat d’escollir un COM-port i un baud rate segons la configuració desitjada. Els programa detectarà automàticament els ports disponibles que té la màquina.

Per defecte, l’aplicació està configurada per iniciar la comunicació amb un baud

rate de 38400 Baud. Aquest és un paràmetre molt important si estem utilitzant una comunicació RS232/FlowBus DDE ja que el convertidor que ens ofereix la interfície ens obliga a treballar amb aquesta velocitat.

Un exemple de configuració seria [ 38400, n, 8, 1 ] per al COM-port: 38k4 Baud, no

parity, 8 databits, 1 stopbit.

Les altres velocitats de transmissió poden ser utilitzades en altres tipus de comunicació, per exemple una comunicació sèrie simple utilitzant hyperterminal de Ms-Windows.

Històric de Comandes

L’usuari disposa d’una finestra de text on pot visualitzar la informació relativa a les operacions executades anomenada històric de comandes. En aquesta es podrà fer un seguiment d’execució dels diferents processos els quals imprimiran en pantalla un missatge verificant el resultat de la operació.

Pot guardar-se aquesta memòria a un fitxer de text en qualsevol moment de la sessió.

Històric de Mesures

De forma periòdica i automàtica, el programa fa una lectura del flux dels MFC i imprimeix els resultats en una finestra de text anomenada històric de mesures. En aquest es podrà visualitzar la data i hora de la lectura, el percentatge d’obertura (Setpoint) i la corresponent mesura associada per a cadascun dels MFC.

A diferència de l’anterior, aquesta és emmagatzemada en un fitxer de text automàticament ubicat al directori Files generat amb la instal·lació del programa.

Important: Si es vol conservar l’històric de mesures, en finalitzar la sessió és necessari copiar el fitxer en un altre directori, o re nombrar-lo, ja que sinó es reescriurà.

Page 11: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria descriptiva

11

Establir una percentatge d’obertura: “Set point”

El Set point és el percentatge d’obertura que es dóna a una vàlvula. Aquest punt conjuntament amb el calibratge que s’utilitzi seran els que indicaran al MFC quina acció mecànica interna ha de realitzar per obtenir el flux desitjat a la sortida.

El rang de valors està limitat entre 0 i 100 % i se li haurà d’indicar en tot moment a quina vàlvula va dirigit. Es poden utilitzar decimals utilitzant una coma com a separador i no serà necessari introduir el “%”.

Visualitzar els percentatges: “Set point i Mesura”

En el moment que establim un Set point, automàticament s’activa una nova plantilla en la que es poden visualitzar aquests paràmetres. Aquest nou entorn permet veure els valors numèrics (en tant per cent) i també en mode gràfic.

També és possible veure la mesura des del punt on establim el percentatge d’obertura. Els valors són actualitzats periòdicament.

La gràfica

La lectura periòdica de la mesura, permet la construcció d’una gràfica de línies amb les suficients mostres com per poder analitzar detalladament el comportament dels MFC.

Aquesta representa en dues dimensions, la mesura en tant per cent (eix

d’ordenades) i el temps en minuts (eix d’abscisses).

La gràfica té associades una sèrie d’opcions als botons del ratolí, per exemple permet fer zoom tipus finestra (botó esquerra) i desplaçaments en horitzontal i vertical (botó dret pressionat).

Calibratge dels MFC: Lectura i escriptura

S’entén per calibratge, el mode de funcionament en que està treballant el MFC, com s’ha comentat aquest poden treballar amb diferents tipus de gas.

S’han d’anomenar dos paràmetres importants: un és el Fluid Number i l’altre és el Fluid Name. El Name contindrà el nom del gas (o un altre d’acord amb el criteri de

l’usuari), tanmateix aquest estarà associat al Number que serà un nombre comprès entre 0 i 8 (per defecte és zero), que indica les posicions de memòria per als diferents calibratges.

Per fer una lectura del fluid, és necessari introduir la posició de memòria (0..8) i el node al qual es vol fer la consulta. Un cop executat el procés, s’imprimeix a l’històric de comandes el resultat obtingut.

En el cas de que es vulgui canviar el mode de calibratge, primerament s’ha d’activar el mode d’escriptura e introduir únicament el Fluid Number. Ressalto el únicament ja que si s’introdueix un valor en el Fluid Name es modificarà també el nom associat a la posició de memòria.

Per exemple, si volem canviar de la posició ‘0’ = “AIR” a la ‘1’ = “CO2” no serà necessari que introduïm el nom ja que el reescriuríem. Aquest paràmetre només serà necessari introduir-lo si desitgem modificar-lo.

Page 12: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria descriptiva

12

Calculadora de fluxos i Set points

El programa incorpora una plantilla dedicada exclusivament al càlcul automatitzat de fluxos i de Set points, introduint una sèrie de paràmetres d’entrada.

Actualment s’utilitza un gas portador (carrier) i un gas contaminant, els quals són barrejats per a obtenir un flux total a la sortida en sccm (standard cubic centimeters per

minute). Per a fer el càlcul és necessari introduir per a cada MFC la concentració de l’ampolla (target) a la que està connectat i també la concentració desitjada a la sortida, ambdós en ppm (parts per million). És possible utilitzar com a portador el MFC-1 (400 sccm) o el MFC-2 (100 sccm). A partir d’aquests paràmetres el programa calcula els percentatges d’obertura i els fluxos de sortida independents per a cadascuna de les vàlvules, respectant el flux màxim definit per a la sortida.

És possible carregar els Set points calculats des d’aquesta mateixa plantilla.

El fitxer CSV

Els fitxers CSV (comma-separated values) són un tipus de document per representar dades en forma de taula, en les que les columnes se separen per comes (o punt i coma on la coma és el separador decimal) i les files per salts de línea.

La finalitat d’utilitzar aquest format és que pot ser manipulat amb Ms-Excel i amb molta facilitat. Aquest fitxer contindrà els paràmetres introduïts per l’usuari per a l’execució del mode de funcionament automàtic.

Test de comunicació

L’usuari podrà testejar la comunicació en qualsevol moment de la sessió. La resposta amb l’estat d’aquesta serà imprès a l’historial de comandes.

La finalitat d’aquest test és verificar que la comunicació és activa si en algun moment es detecta algun comportament irregular del programa.

Opcions de sortida

És possible tancar la comunicació establerta amb el Flow Bus durant l’execució del programa. Quant es tanca la comunicació no es modifica la configuració dels MFC, tot i això, és molt important no hi hagi talls en la comunicació ja que pot provocar la pèrdua de informació processada fins al moment.

Abans de sortir del programa, com a pas previ, és necessari tancar la comunicació.

Page 13: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

13

3. Memòria de càlcul

3.1. Esquema general

Donada una visió general de quines són les funcionalitats del programa seguidament es descriuran, de forma general, les parts implicades amb les que haurà de treballar l’usuari. Per assolir els requeriments s’ha optat per dissenyar una interfície gràfica, fet que facilita també el seu ús. L’esquelet del programa està format per cinc plantilles relacionades entre elles, on se’n defineixen una de principal (conté l’estructura bàsica d’operacions) i quatre de secundaries. Les plantilles secundaries les podem dividir en dos grups: les actives que són aquelles que permeten l’execució d’operacions i els passives que són únicament de lectura.

3.1.1 Plantilla Principal

Form3, “User interface for FlowBus DDE”

És el primer en ser inicialitzat en el moment d’executar el programa. Inicialment només es visualitzen els elements necessaris per obrir la comunicació amb el sistema, un cop oberta, s’activen la resta de botons els quals permeten l’execució l’aplicació al cent per cent. La unitat es composa de varis objectes entre ells finestres de text, botons, etc. encarregats dur a terme les crides a funcions e informar a l’usuari dels successos més importants. Aquesta unitat no permet ser maximitzada. La figura 2 mostra la interfície d’usuari on s’identifiquen els principals components del Form:

Caixa de llista

Finestra de text

Editor de text

Botó

Casella de verificació

Barra d’estat

Figura 2. El Form3 i les seves parts.

Page 14: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

14

A continuació es detallen les parts de la plantilla principal, Form3:

Finestres de text “Memo”

Available COM ports: la primera finestra de text en ser utilitzada mostra els ports disponibles que té la màquina per establir la comunicació amb els sistema.

Commands History: informa a l’usuari dels resultats de processos i operacions més importants durant la sessió.

Errors: hi ha un tercer bloc on dues finestres informen dels errors del sistema. En el cas de que es produeixi un error, mostra el codi d’aquests associat a un missatge detallant l’error. Aquestes finestres són exclusivament de lectura.

Caselles de verificació “Check Box”

Les caselles de verificació permeten principalment modificar la funció d’un botó, activar-lo o desactivar-lo.

Change Default BaudRate: habilita una llista amb els diferents baud rates disponibles per a poder modificar el que inicialment està configurat per defecte (30k4

baud).

Writing mode: permet canviar el mode de treball de calibratge: lectura o escriptura modificant les funcions que executen dels botons.

LOAD CSV File: aquest és molt important ja que permet modificar el mode de funcionament del programa de manual a automàtic al modificar les propietats del botó Open/Load.

Caixes de llista “List Box”

Select Port: els mateixos ports testejats i impresos a la finestra de ports disponibles, són traslladats a aquesta caixa de llista. Ens permet seleccionar el port, paràmetre indispensable per poder establir la comunicació.

BaudRate: en aquesta llista l’usuari pot seleccionar una de les velocitats disponibles pel sistema en el cas que desitgi modificar la que ve configurada per defecte.

Select MFC: en iniciar el procés de calibratge, l’usuari ha definir un node (MFC) sobre el qual vol operar. Aquesta llista conté els nodes disponibles de la xarxa.

Editors de text “Edit”

Fluid Number: Aquests només estan en habilitats en el mode d’escriptura, ja que no són necessaris per a llegir el calibratge dels MFC. S’activa amb la casella de verificació al canviar el mode de calibratge i permet modificar el número de fluid amb que volem fer treballar les vàlvules.

Fluid Name: té les mateixes propietats que el número de fluid. Permet modificar el nom del fluid associat al número identificador.

Page 15: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

15

Botons

Check Port: és el botó encarregat d’executar la funció que detecta els ports disponibles a la màquina i imprimir-los a la finestra de text.

Open Communication: si prèviament s’ha seleccionat un port i una velocitat de transmissió correctes obre la comunicació amb el sistema. Imprimeix un missatge amb el resultat de l’operació a l’històric de comandes.

Write parameters: activa la plantilla PagesDlg per introduir paràmetres d’escriptura.

Read parameters: activa la plantilla Form2 on es pot veure el Set point i la mesura per a cadascuna de les vàlvules i també la representació gràfica.

Save commands: desa en un fitxer de text tots els missatges impresos durant la sessió en l’històric de comandes.

View History: mostra en una nova plantilla l’històric de mesures on l’usuari pot veure les mesures recollides durant tota la sessió.

Read/Write Calibration: mitjançant l’ajuda d’un Check box és possible modificar la funció d’aquest botó. Mostra a l’històric de comandes el fluid amb que està calibrat l’aparell. Aquest es pot modificar utilitzant el mètode d’escriptura.

Flux Calculator: obre una nova plantilla que permet calcular, segons el calibratge de les vàlvules, el Set point i el flux de sortida dels diferents MFC.

Reset: permet esborrar els missatges d’error que s’hagin pogut imprimir durant la sessió.

New/Stop: aquest botó modifica la seva funció al activar la casella de verificació LOAD CSV File. Obre una plantilla CSV creada amb la instal·lació del programa, la que permet crear un nou procés de control automàtic dels MFC. Un cop iniciat el mode automàtic, aquesta botó ens serveix per aturar-lo i tornar al mode manual.

Open/Load: aquest botó modifica la seva funció al activar la casella de verificació LOAD CSV File. Permet obrir un fitxer CSV en la configuració per defecte i carregar-lo per iniciar el procés automàtic si es selecciona la casella abans anomenada.

Check Comm: informa de l’estat de la comunicació mitjançant una finestra de text.

Close Comm: tanca la comunicació amb el sistema. Tant en cas d’èxit com d’error, retorna un missatge per pantalla informant del resultat de l’operació.

EXIT: surt del programa, tancant tots els processo i Forms que estiguin oberts. És necessari que la comunicació estigui tancada per poder sortir del programa.

Barra d’estat “Status Bar”

Aquesta es divideix en tres parts: una on hi apareixen missatges de text, i les altres dues que informen de la data i l’hora del sistema.

Page 16: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

16

3.1.2 Plantilles secundaries actives

PagesDlg, “Writing parameters”

Aquesta plantilla s’activa en el moment en que es volen escriure paràmetres amb el botó Write parameters. Aquest es composa de botons, etiquetes de lectura i editors de text amb els que podem modificar i visualitzar els paràmetres de les vàlvules. La seva funció principal és establir els Set points per a cadascun dels MFC disponibles a la xarxa. També disposa d’elements destinats a l’anàlisi dels resultats on és possible visualitzar la mesura refrescada periòdicament que retorna l’instrument i el percentatge d’obertura que té configurat. La peculiaritat d’aquesta plantilla que la diferencia amb la resta és que disposa de quatre pàgines, una per a cadascun dels MFC. Aquesta unitat no és disponible en el mode automàtic de funcionament. Cada pàgina té el mateix format i els mateixos objectes.

La figura 3 mostra la interfície d’usuari on s’identifiquen els principals components de la plantilla:

Pestanya per canviar

el MFC

Editor de text

Botó

Etiqueta de lectura

Figura 3. El Form PagesDlg i les seves parts.

A continuació es detallen les parts de la plantilla secundària, PagesDlg:

Pàgines “TabPages”

Com es pot veure a la figura 3 aquesta unitat disposa de quatre pestanyes les quals ens permeten introduir els paràmetres de configuració per les diferents vàlvules e imprimir els resultats en diferents sèries de la gràfica. Cada pàgina té exactament el mateix contingut i es permet configurar qualsevol MFC independentment de l’estat dels altres.

Editors de text “Edit”

Value: permet introduir el valor de Set point per configurar la vàlvula. És possible modificar aquest valor durant la sessió, és a dir que s’actualitzarà el paràmetre sense interrompre el funcionament del MFC.

Page 17: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

17

Botons

Load Write: dóna la ordre a la vàlvula per a modificar el seu funcionament amb els nous paràmetres introduïts. Un cop inicialitzat el procés, habilita l’etiqueta per a la lectura de la mesura. És possible carregar el Set point tantes vegades com desitgi l’usuari durant la sessió.

Reset Series: aquest botó atura els diferents processos de lectura que estan relacionats amb el node sobre que s’està manipulant. També elimina la sèrie encarregada de representar la mesura a la gràfica. El MFC no perd la seva configuració, és a dir que mantindrà el Set point. Es podrà tornar accedir a la mesura inicialitzant el procés de lectura. En el cas de que es desitgi tancar la vàlvula serà necessari introduir un Set point amb valor zero.

Etiqueta de lectura “Labels”

Measure %: aquest permet veure la lectura del MFC refrescada periòdicament. Si es fa un reset Series aquest paràmetre deixa de ser actualitzat.

Setpoint %: permet veure el Set point amb que està configurada la vàlvula.

Page 18: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

18

Form1, “Flow & Set point calculator”

El Form1 és una aplicació que permet calcular els fluxos de les vàlvules (en sccm) i els Set points (en tant per cent), tenint la opció d’escriure valors obtinguts a les vàlvules. L’usuari ha de seleccionar prèviament el tipus de calibratge amb que estan configurats els MFC que vulgui utilitzar i continuació introduir els fluxos i les concentracions per a cadascun d’ells. Aquesta és una unitat dissenyada per a realitzar proves, permetent a l’usuari executar càlculs amb diferents tipus de calibratge. Si els Set points són carregats es reiniciaran els processos, per als MFC concretament afectats, amb els nous valors. La plantilla es composa d’elements diversos, com ara, editors de text, etiquetes de lectura, etc. Els paràmetres d’entrada estan agrupats per MFC, per altra banda els resultats s’agrupen per paràmetre. Aquesta unitat no permet ser maximitzada. És important remarcar que aquesta unitat només és disponible en mode manual de funcionament.

La figura 4 mostra la interfície d’usuari on s’identifiquen els principals components de la plantilla:

Casella de verificació

Editor de text

Caixa de llista

Exemple agrupació

Etiqueta de lectura

Botó

Barra d’estat

Figura 4. El Form1 i les seves parts.

Page 19: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

19

A continuació es detallen les parts de la plantilla secundaria, Form1

Caselles de verificació “Check Box”

Enable MFC - 4: aquesta casella habilita els objectes associats al MFC número 4, sent aquests: l’editor de text en el seu immediat inferior i l’agrupació corresponent.

Load Set points: en activar aquesta opció es modifica el funcionament de la unitat, passant de mode calculadora a mode escriptura. Per això es modifiquen les funcions que executa el botó Calculate, que passa a anomenar-se Load.

Change Fluid: assigna el Flux Màxim depenent del tipus de calibratge i el MFC escollits. Aquesta es desactiva automàticament un cop s’ha associat el paràmetre.

Carrier Mode: aquesta casella permet configurar el MFC-2 com a portador, sempre que es deixi el flux màxim del MFC-1 configurat a zero sccm.

Caixes de llista “List Box”

Fluid Name: conté el nom dels fluids amb que estan configurades les diferents memòries de calibratge dels MFC. Per defecte conté els fluids “AIR” i “CO2” els quals tenen associats els fluxos màxims per a les diferents vàlvules.

Select MFC: permet seleccionar el MFC al qual se li assignaran els paràmetres de calibratge.

Editors de text “Edit”

Max Flow (sccm): aquest paràmetre està associat al MFC - 4 i permet introduir un flux màxim que anirà en funció de la capacitat de la vàlvula que se li assigni i del gas utilitzat. Per defecte es troba deshabilitat, per utilitzar-lo s’ha d’activar la casella de verificació que es troba sobre seu Enable MFC-4.

Total Output Flow (sccm): aquets és un valor molt important ja que indica el flux total desitjat a la sortida. La obertura de les vàlvules que s’utilitzin per al càlcul i el flux de cadascuna d’aquestes dependrà en gran mesura d’aquest paràmetre.

Conc. Target (ppm): concedeix a l’usuari la opció d’introduir la concentració de l’ampolla que es connectarà al MFC.

Conc. Required (ppm): permet introduir la concentració requerida del gas per fer la barreja amb portador.

Tant la concentració requerida com la desitjada, són paràmetres comuns per als MFC 2, 3 i 4.

Etiqueta de lectura “Label”

La unitat conté un número elevat d’etiquetes, la majoria d’aquestes passives, és a dir que la informació que contenen no es modifica durant l’execució del programa. Aquestes són de caràcter descriptiu per a objectes com poden ser Edits o fins i tot altres Labels.

Page 20: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

20

Es detallaran únicament les etiquetes que contenen informació susceptible a canvis (ressaltades amb negreta).

Max Flow (sccm): aquest paràmetre és comú per tots els MFC e informa a l’usuari del flux màxim en funció del calibratge de cada vàlvula. Per visualitzar aquesta dada és necessari escollir un fluid a la casella de llista Fluid Name i un node a la llista Select

MFC. Un cop seleccionats aquests paràmetres s’ha d’activar la casella Change Fluid.

MFC – [1..4] “agrupació Flux(sccm)”: aquest grup de Labels mostren el flux total calculat per cada MFC en funció de les concentracions introduïdes per l’usuari. Només apareixeran els totals dels nodes als quals se’ls introdueixin els paràmetres d’entrada.

MFC – [1..4] “agrupació Setpoint(%)”: dóna el percentatge d’obertura dels MFC en funció del flux total obtingut.

Botons

Calculate/Load: és qui executa la funció per calcular el flux total i el Set point abans esmentats. Aquest botó mitjançant la casella de verificació Load Setpoints modifica la funció del botó per a permetre l’escriptura dels paràmetres calculats. El text descriptiu del botó passa a ser Load.

Reset: aquest botó permet reiniciar l’aplicació i esborrar tots els paràmetres introduïts prèviament.

Barra d’estat “Status Bar”

Aquesta es divideix en dues parts: una on es mostres missatges de text depenent de si l’usuari està utilitzant el mode càlcul o bé si ja es disposa a escriure els paràmetres de Set point, i l’altra que informa de l’hora del sistema.

Page 21: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

21

3.1.3 Plantilles secundaries passives

Form2, “Reading parameters & graphic”

És una unitat destinada únicament a la lectura dels paràmetres retornats per les vàlvules, que són la mesura i el Set point. Permet visualitzar els paràmetres en format numèric i també impresos en una gràfica de línies. Els components de la plantilla Form es resumeixen a etiquetes de lectura (Labels) i a la finestra on es dibuixa la gràfica (DBChart). S’activa automàticament a l’escriure els paràmetres de configuració de les vàlvules a través del PagesDlg. També és possible visualitzar la unitat amb el botó Read

parm. de la plantilla principal. És possible ampliar el Form escalant-lo o maximitzant-lo a pantalla completa, la graella de la gràfica s’ajusta automàticament a la mida imposada per l’usuari. És disponible en els modes de funcionament, el manual i l’automàtic.

La figura 5 mostra la interfície d’usuari on s’identifiquen els principals components de la plantilla:

Etiqueta de lectura Gràfica

Exemple d’agrupació. Figura 5. El Form2 i les seves parts.

A continuació es detallen les parts del Form secundari, Form2

Etiquetes de lectura “Label”

Igualment com en el Form anterior es pot veure que hi ha Labels passius que són únicament de caràcter descriptiu per a altres objectes, en aquest cas Labels actius. Es detallaran únicament les etiquetes que contenen informació susceptible a canvis (ressaltades amb negreta).

Node: aquesta conté el número identificador de MFC amb que es reconeix en el protocol FlowBus. Com es pot veure es repeteix el valor per a cadascuna de les agrupacions.

Page 22: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

22

Setpoint %: aquest és el percentatge d’obertura que té configurat la vàlvula. Aquest és un valor fixat per l’usuari i no es modifica si no és a petició seva o per falta de subministrament de gas on el valor disminueix conjuntament amb la mesura per la falta de pressió.

Measure %: permet veure el flux de gas dels MFC. El valor capturat és el mateix que s’imprimeix a la gràfica i és refrescat cada segon. Si es produeix un error de lectura deu vegades consecutives s’imprimeix Error indicant un problema amb la lectura del paràmetre.

Gràfic “DBChart”

Percent (%): és l’eix d’ordenades i es mesura en tant per cent. Els valors estan compresos entre zero i cent. Indica la mesura en temps real del flux regulat per la vàlvula.

Time (m): és l’eix d’abscisses i es mesura en minuts. És inicialitzat a zero i mostra fins a 30 minuts, tot i que la seva llargada és infinita ja que permet a l’usuari desplaçar-se en el temps.

Utilitats

Zoom finestra: el gràfic té la propietat de poder ser ampliat mitjançant els botó esquerra del ratolí. S’ha deixar pressionat el botó i moure el ratolí creant una finestra. Si el desplaçament és cap a la dreta el zoom és positiu, o sigui amplia la gràfica, modificant també els valors dels eixos de coordenades automàticament. Permet fer varies ampliacions consecutives. Si el desplaçament és cap a l’esquerra, torna a l’estat inicial.

Desplaçament horitzontal i vertical: aquesta ens permet desplaçar la gràfica actualitzant també els eixos de coordenades. Per fer aquest moviment s’ha de deixar pressionat el botó dret del ratolí i seguidament realitzar el moviment.

Page 23: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

23

Form4, “Measurement History”

Aquesta unitat està destinada exclusivament a crear un registre on l’usuari pot veure en format de text els canvis que s’han produït durant una sessió. Aquest es guarda automàticament en un fitxer de text al finalitzar la sessió dins la carpeta Files creada amb la instal·lació del programa. Es composa principalment d’una finestra de text la que disposa d’una barra de desplaçament horitzontal permetent tenir accés a tots els paràmetres registrats. Aquesta unitat no permet ser maximitzada, però si escalada verticalment. És disponible en els dos modes de funcionament, el manual i l’automàtic.

La figura 6 mostra la interfície d’usuari on s’identifiquen els principals components de la plantilla:

Capçalera

.

Barra de desplaçament

Finestra de text

Barra d’estat

Figura 6. El Form4 i les seves parts

A continuació es detallen les parts de la plantilla secundaria, Form4

Capçalera

Conté etiquetes de text encarregades d’identificar els valors impresos en la finestra de text.

Finestra de text “List”

De forma periòdica, cada 30 segons, es llegeixen els paràmetres de Set point i la Mesura associats a un node (MFC) determinat. A finestra de text s’imprimeixen aquests valors conjuntament amb la data i l’hora del sistema.

Barra d’estat “Status Bar”

Aquesta es divideix en dues parts: una on es mostres missatges de text i l’altra que informa de l’hora del sistema.

Page 24: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

24

3.2. Blocs funcionals

Dins d’aquest apartat es defineixen les funcions per a cadascuna de les parts que composen el programa. Totes les plantilles anomenades en apartats anteriors s’estructuren per classes. Hi ha plantilles que només contenen una classe i altres que en contenen vàries.. Això és degut als fils d’execució encarregats de fer possible la multitasca, ja que no tots els Forms són capaços de suportar-la internament. Les classes disposen de les seves funcions pròpies, tot i que també poden fer una crida a altres d’externes. Per a cada funció es fa una descripció i es detallen els paràmetres d’entrada i sortida (In-Out) i el retorn en el cas de que n’hi hagi.

3.2.1 Plantilla principal

Form3, “User interface for FlowBus DDE”

Aquest conté dues classes, una és la class TForm3 : public TForm que és la interfície gràfica principal del programa i l’altra és la class AutomaticMode : public TThread que és un fil d’execució encarregat del funcionament del programa quant s’activa mode automàtic.

class TForm3 : public TForm

GetAnswer

Funció: Funció que agafa els missatges de la cua de la DLL. Només pot treure el primer missatge de la cua, és a dir que no pot començar al principi o al final de la cua.

Paràmetres:

(In)

(out) iMsgId: Identificador del missatges que ha trobat.

sAnswer: Valor del paràmetre extret del missatge de resposta

sErrVal: String que indica si hi ha hagut un error.

"", si no hi ha cap error (iErrVal i bytStatus són 0). Sinó conté la cadena d’error.

iErrVal: Valor que indica quin error ha ocorregut.

bytStatus: Codi del Status del missatge rebut.

Retorn: True si el missatge s’ha rebut, false en un altre cas.

void __fastcall TForm3::GetAnswer(short & iMsgId, char * sAnswer,

char * sErrVal, short & iErrVal, char & bytStatus);

Page 25: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

25

StartCommunication

Funció: Aquesta obre la comunicació amb FlowBus en un port determinat. També configura l’encadenament de processos i de paràmentres.

Paràmetres:

(In) sPort: Nom del port on ha de ser oberta la comunicació.

bProcChain: Booleà que indica si els processos s’encadenen o no.

bParmChain: Booleà que indica si els paràmetres s’encadenen o no.

uiBaudRate: El baudrate desitjat amb que el port ha de ser configurat. Els baudrate disponibles són 4800, 9600, 19200 i 38400.

(out) iErrVal: Valor que indica quin error ha ocorregut.

sErrVal: "", si no hi ha cap error. Sinó conté la cadena d’error.

Retorn:

void __fastcall TForm3::void StartCommunication(char * sPort, bool bProcChain,

bool bParmChain, short & iErrVal, unsigned short uiBaudRate, char * sErrVal);

CloseCommunication

Funció:

Funció que tanca la comunicació amb FlowBus en un port determinat. Si la comunicació no es pot tancar apareix un missatge d’error en una finestra de text.

Paràmetres:

(In) sPortName: Nom del port a tancar (“COM1” o “COM2” per exemple).

(out) sErrVal: "", si no hi ha cap error. Sinó conté la cadena d’error.

Retorn:

void __fastcall TForm3::CloseCommunication(char * sErrVal);

Page 26: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

26

WriteParameterDirect

Funció: Aquesta funció escriu directament un paràmetre a cert instrument en el FlowBus.

Aquesta funció espera una resposta abans de retornar.

Paràmetres:

(In) iNode: Node (instrument o vàlvula).

iProc: Procés.

iParm: Paràmetre.

iParmType: Tipus de paràmetre del paràmetre.

0 és String / Byte

1 és Float

2 és Integer

3 és Long

iParmTypeLength: Longitud del paràmetre. Només significatiu quant iParmType = 0

0 indica Byte

-2 indica zero terminació del string.

x fixa el String amb x caràcters.

lTimeOut: Temps (en milisegons) abans de que hi hagi un timeout.

sValue: El valor del paràmetre a escriure.

(out) iErrVal: Valor que indica quin error ha ocorregut.

bytStatus: Status code del missatge rebut.

sErrVal: "", si no hi ha cap error. Sinó conté la cadena d’error.

Retorn:

void __fastcall TForm3::WriteParameterDirect(short iNode, short iProc,

short iParm, short iParmType, short iParmTypeLength, long lTimeOut,

char * sValue, short & iErrVal, char & bytStatus, char * sErrVal);

Page 27: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

27

SendWriteRequest

Funció: Aquesta funció escriu un paràmetre a un instrument específic en el FlowBus.

Paràmetres:

(In) iNode: Node (instrument o vàlvula).

iProc: Procés.

iParm: Paràmetre.

iParmType: Tipus de paràmetre del paràmetre.

0 és String / Byte

1 és Float

2 és Integer

3 és Long

iParmTypeLength: Longitud del paràmetre. Només significatiu quant iParmType = 0

0 indica Byte

-2 indica zero terminació del string.

x fixa el String amb x caràcters.

lTimeOut: Temps (en milisegons) abans de que hi hagi un timeout.

sValue: El valor del paràmetre a escriure.

(out) iMsgId: El missatgeId que correspon al missatge que s’ha enviat. Aquest té valor ja que amb aquest identificador es pot determinar quin missatge (enviat per un instrument del FlowBus) conté el nostre valor.

iErrVal: Valor que indica quin error ha ocorregut.

sErrVal: "", si no hi ha cap error. Sinó conté la cadena d’error.

Retorn:

void __fastcall TForm3::SendWriteRequest(short iNode, short iProc, short iParm,

short iParmType, short iParmTypeLength, long lTimeOut,

char * sValue, short & iMsgId, short & iErrVal, char * sErrVal);

Page 28: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

28

ReadParameterDirect

Funció: Aquesta funció llegeix directament un paràmetre d’un instrument en el FlowBus.

Aquesta funció espera una resposta abans de retornar.

Paràmetres:

(In) iNode: Node (instrument o vàlvula).

iProc: Procés.

iParm: Paràmetre.

iParmType: Tipus de paràmetre del paràmetre.

0 és String / Byte

1 és Float

2 és Integer

3 és Long

iParmTypeLength: Longitud del paràmetre. Només significatiu quant iParmType = 0

0 indica Byte

-2 indica zero terminació del string.

x fixa el String amb x caràcters.

lTimeOut: Temps (en milisegons) abans de que hi hagi un timeout.

(out) sAnswer: El valor del paràmetre (el valor que ha rebut del node)

iErrVal: Valor que indica quin error ha ocorregut.

bytStatus: Status code del missatge rebut.

sErrVal: "", si no hi ha cap error. Sinó conté la cadena d’error.

Retorn:

void __fastcall TForm3::ReadParameterDirect(short iNode, short iProc,

short iParm, short iParmType, short iParmTypeLength, long lTimeOut,

char * sAnwer, short & iErrVal, char & bytStatus, char * sErrVal);

Page 29: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

29

SendReadRequest

Funció: Aquesta funció envia un Read-request a la DLL. un paràmetre a un instrument específic en el FlowBus. Aquesta petició li diu a la DLL que volem conèixer el valor del paràmetre especificat.

Paràmetres:

(In) iNode: Node (instrument o vàlvula).

iProc: Procés.

iParm: Paràmetre.

iParmType: Tipus de paràmetre del paràmetre.

0 és String / Byte

1 és Float

2 és Integer

3 és Long

iParmTypeLength: Longitud del paràmetre. Només significatiu quant iParmType = 0

0 indica Byte

-2 indica zero terminació del string.

x fixa el String amb x caràcters.

(out)

iMsgId: El missatgeId que correspon al missatge que s’ha enviat. Aquest té valor ja que amb aquest identificador es pot determinar quin missatge (enviat per un instrument del FlowBus) conté el nostre valor.

iErrVal: Valor que indica quin error ha ocorregut.

sErrVal: "", si no hi ha cap error. Sinó conté la cadena d’error.

Retorn:

void __fastcall TForm3::SendReadRequest(short iNode, short iProc, short iParm,

short iParmType, short iParmTypeLength, short & iMsgId,

short & iErrVal, char * sErrVal);

Page 30: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

30

GetInfoDirect

Funció: Amb aquesta funció s’aconsegueix la resposta continguda en el missatge de resposta rebuda de Read-request o Write-request. Primer mira a la cua local per el missatge. Si no el troba, demana a la DLL si té altres missatges. Aquesta funció només para si hi ha un timeout o si troba la resposta.

Després d’extreure la informació del missatge rebut, aquest és eliminat de la cua local.

Paràmetres:

(In) iMsgId: El missatgeId del missatge d’on es necessiten d’extreure els valors. Aquest té valor ja que amb aquest identificador es pot determinar quin missatge (enviat per un instrument del FlowBus) conté el nostre valor.

lTimeOut: Temps (en milisegons) abans de que hi hagi un timeout.

(out) bytStatus: Status code del missatge rebut (Answer message).

iErrVal: Valor que indica quin error ha ocorregut.

sErrVal: "", si no hi ha cap error. Sinó conté la cadena d’error.

sAnswer: Valor del paràmetre (Només significatiu amb Read-request) per tant és opcional. (assignar-li un punter nul si no interessa aquest valor.

Retorn: True si s’ha trobat el missatge, false en un altre cas.

bool __fastcall TForm3::GetInfoDirect(short iMsgId, long lTimeOut,

char & bytStatus, short & iErrVal, char * sErrVal, char * sAnswer);

StartTimeOutTimer();

Funció: Funció que inicia el Timer que controla els TimeOuts.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TForm3::StartTimeOutTimer(void);

Page 31: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

31

TimeUp

Funció: Funció que comprova si el temps ha expirat (si hi ha hagut un TimeOut). Aquesta mesura el temps des del moment en que s’ha iniciat el Timer fins ara i comprova que el temps no hagi expirat.

Paràmetres:

(In) lTimeOut: Temps en milisegons abans del TimeOut.

(out)

Retorn: True si ocorre un TimeOut, False si el temps és menor.

void __fastcall TForm3::TimeUp(long lTimeOut);

GetAvailablePorts

Funció: Funció que col·loca en un Array els COM ports disponibles. Aquesta per tant crida a les funcions GetPort() i GenNrOfPorts() de la API de Flowbus.

Paràmetres:

(In)

(out) sAvailComPorts: Referència al Array de noms de ports COM. Es crea un Array hi és assignat a aquesta variable. Tots els ports disponibles seran agregats al Array.

iAvailComPorts: Número de ports COM dins de sAvailComPorts.

Retorn:

void __fastcall TForm3::GetAvailablePorts(void);

ReadingCalibration

Funció: Funció que imprimeix per pantalla el nom del fluid amb el que està configurat un instrument. L’usuari ha de seleccionar el MFC al qual vol fer la petició. Crida a la funció ReadParameterDirect().

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TForm3::ReadingCalibration(void);

Page 32: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

32

WritingCalibration

Funció: Funció que configura les vàlvules a un tipus de calibratge determinat. L’usuari ha de seleccionar el MFC al qual vol fer la petició i introduir el número de memòria al qual vol canviar el calibratge. Crida la funció WriteParameterDirect().

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TForm3::WritingCalibration(void);

Initial

Funció: Funció que configura l’estat inicial de la plantilla principal en ser executada. Principalment s’encarrega de configurar les propietats dels objectes de la plantilla Form3.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TForm3::Initial(void);

FinalCloseComm

Funció: Funció que configura les propietats dels objectes de la plantilla Form3 en ser tancada la comunicació.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TForm3::FinalCloseComm(void);

Page 33: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

33

InitialOpenComm

Funció: Funció que configura les propietats dels objectes de la plantilla Form3 en ser oberta la comunicació. També fa la crida a la funció Initial() de la plantilla PagesDlg.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TForm3::InitialOpenComm(void);

AutomaticModeOn

Funció: Funció que configura les propietats dels objectes de la plantilla Form3

preparant-la per al funcionament en mode automàtic. També neteja la possible informació que pugui contenir la gràfica, és a dir la plantilla Form2.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TForm3::AutomaticModeOn(void);

AutomaticModeOff

Funció: Funció que configura les propietats dels objectes de la plantilla Form3

deixant-los en el seu estat inicial de treball en mode manual.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TForm3::AutomaticModeOff(void);

Page 34: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

34

TForm3

Funció: Aquesta s’executa automàticament al activar la plantilla. Configura l’estat inicial de la interfície gràfica fent una crida a la funció Initial() .

__fastcall TForm3::TForm3(TComponent * Owner) : TForm(AOwner)

Button1

Funció: Botó CheckPort: testeja els ports disponibles de la màquina. Crida a la funció GetAvailablePorts(). És l’encarregat de declarar la variable global *g.

void __fastcall TForm3::Button1Click(TObject * Sender)

Button2

Funció: Botó ClosComm: tanca la comunicació amb FlowBus. Crida a les funcions CloseCommunication() i FinalCloseComm().

void __fastcall TForm3::Button2Click(TObject * Sender)

Button3

Funció: Botó Exit: si s’ha obert la comunicació és necessari tancar-la prèviament per poder sortir del programa. Elimina la variable global *g i dóna la sortida del programa.

void __fastcall TForm3::Button3Click(TObject * Sender)

Button4

Funció: Botó Open Communication: obre la comunicació amb un COM port i un baud rate escollits per l’usuari. Crida a les funcions OpenCommunication() i InitialOpenComm(). Si la comunicació és oberta, crea una instància a la classe WriteHistory.

void __fastcall TForm3::Button4Click(TObject * Sender)

Page 35: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

35

Button5

Funció: Botó Check Comm: comprova si la comunicació està oberta mirant si la variable booleana global bCommOpened és verdadera o falsa.

void __fastcall TForm3::Button5Click(TObject * Sender)

Button6

Funció: Botó Reset Errors: elimina els possibles missatges d’error obtinguts.

void __fastcall TForm3::Button6Click(TObject * Sender)

Button7

Funció: Botó Read Parm: comprova que les variables booleanes globals iThread[1..4]Off siguin verdaderes o falses. En el primer cas, crea un fil d’execució que és l’encarregat de llegir la mesura dels MFC i representar els valors obtinguts gràficament. Si el fil ja existeix prèviament, o sigui si la condició és falsa, simplement visualitza la plantilla Form2.

void __fastcall TForm3::Button7Click(TObject * Sender)

Button8

Funció: Botó New/Stop: crea un nou fitxer CSV mitjançant una plantilla que es crea a l’instal·lar el programa. Si s’ha carregat un fitxer csv anteriorment, aquest canvia la seva funcionalitat i crida a la funció AutomaticModeOff().

void __fastcall TForm3::Button8Click(TObject * Sender)

Page 36: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

36

Button9

Funció: Botó Save Commands: guarda en un fitxer de text els resultats obtinguts en l’històric de comandes. Permet a l’usuari escollir el directori on vol guardar el fitxer.

void __fastcall TForm3::Button9Click(TObject * Sender)

Button10

Funció: Botó View History: activa la plantilla Form4 la que permet veure un històric de les mesures registrades periòdicament durant la sessió.

void __fastcall TForm3::Button10Click(TObject * Sender)

Button11

Funció: Botó Write Parm: activa la plantilla PagesDlg la que permet introduir paràmetres de configuració de les vàlvules en mode manual.

void __fastcall TForm3::Button11Click(TObject * Sender)

Button12

Funció: Botó Flow Calculator: activa la planilla Form1 la que permet fer un càlcul de mesures i de Set points automàtic.

void __fastcall TForm3::Button12Click(TObject * Sender)

Page 37: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

37

Button15

Funció: Botó Open/Load: carrega un fitxer CSV per al funcionament en mode automàtic. El botó canvia de funcionalitat si s’activa la casella de verificació LOAD CSV File i passa a cridar a les funcions Initial() i AutomaticModeOn(). A continuació crea una instància a la classe AutomaitMode creant un nou fil d’execució encarregat de controlar automàticament el procés de configuració de paràmetres dels MFC.

void __fastcall TForm3::Button15Click(TObject * Sender)

Button16

Funció: Botó Reading/Writing Calibration: llegeix el calibratge dels MFC. Crida la funció ReadingCalibration(). Canvia la seva funcionalitat si s’activa la casella writing mode cridant després a la funció WritingCalibration().

void __fastcall TForm3::Button16Click(TObject * Sender)

Timer1

Funció: Imprimeix la data i l’hora a la barra d’estat de la plantilla Form3.

void __fastcall TForm3::Timer1Timer(TObject * Sender)

CheckBox1

Funció: Casella Change Default BaudRate (38400): activa la caixa de llista que permet a l’usuari canviar el baud rate que ve configurat per defecte.

void __fastcall TForm3::CheckBox2Click(TObject * Sender)

CheckBox2

Funció: Casella LOAD CSV File: canvia la funcionalitat dels botons número 8 i 15 si es selecciona la casella de verificació.

void __fastcall TForm3::CheckBox2Click(TObject * Sender)

Page 38: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

38

CheckBox3

Funció: Casella Writing Mode: canvia la funcionalitat del botó 16 si es selecciona la casella de verificació.

void __fastcall TForm3::CheckBox3Click(TObject * Sender)

class AutomaticMode : public TThread

AutomaticMode

Funció: Aquest és el constructor del fil que conté com a variable un booleà. Crea un objecte concurrent en suspensió (CreateSuspend = true(default)) és per aquesta raó que en la crida al constructor s’ha d’informar que CreateSuspend = false, per tant el procés es reactiva i fa la crida al mètode Execute().

Paràmetres:

(In) CreateSuspended booleà que activa el fil d’execució. Per defecte el seu valor és true.

(out)

Retorn:

__fastcall AutomaticMode::AutomaticMode(bool CreateSuspend)

Execute

Funció: És molt important ja que quant es crea una instància a la classe AutomatiMode, executa el seu codi automàticament. Per controlar qualsevol element o component visual fa la crida a la funció UpdateLabel() mitjançant un mètode especial de Execute anomenat Synchronize(UpdateLabel). Aquesta funció és l’encarregada de sincronitzar en milisegons l’execució del fils, per això s’ha utilitzat la funció SYSTEMTIME.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall AutomaticMode::Execute(void)

Page 39: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

39

UpdateLabel

Funció: Aquesta conté el codi d’execució del fil. És encarregada de implementa el mode de funcionament automàtic. Crida a les funcions WriteParameterDirect() i AutomaticModeOff(). També s’encarrega de fer una instància a les classes WriteMeasure[1..4] de la plantilla Form2, o sigui als diferents fils d’execució que implementa aquesta.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall AutomaticMode::UpdateLabel(void)

3.2.2 Plantilles secundaries

Form1, “Flow & Set point calculator”

Aquest conté una única classe, és la class TForm1 : public TForm (descendent de

la classe TForm) que és la interfície gràfica d’aquesta plantilla.

class TForm1 : public TForm

Initial

Funció: Funció que configura l’estat inicial de la plantilla en ser activada. Principalment s’encarrega de configurar les propietats dels objectes de la plantilla Form1. També inicialitza a zero totes les variables de càlcul utilitzades.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TForm1::Initial(void);

Page 40: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

40

TForm1

Funció: Aquesta s’executa automàticament al activar la plantilla. Configura l’estat inicial de la interfície gràfica fent una crida a la funció Initial() .

__fastcall TForm1::TForm1(TComponent * Owner) : TForm(AOwner)

Button1

Funció: Botó Reset: configura la plantilla amb el seu estat inicial. Elimina tots els possibles valors calculats anteriorment inicialitzant totes les variables a zero. Crida a la funció Initial().

void __fastcall TForm1::Button1Click(TObject * Sender)

Button2

Funció: Botó Calculate/Load: Executa el càlcul de flux i de set point e imprimeix els resultats en les etiquetes de lectura corresponents. Si la casella Load

Setpoints és activada canvia la seva funcionalitat i carrega els percentatges calculats als MFC fent una crida a la funció WriteParameterDirect() i creant una instància a les classes de la plantilla Form2 per inicialitzar els fils d’execució.

void __fastcall TForm1::Button2Click(TObject * Sender)

Timer1

Funció: Imprimeix l’hora a la barra d’estat de la plantilla Form1.

void __fastcall TForm1::Timer1Timer(TObject * Sender)

CheckBox1

Funció: Casella Change Fluid: carrega el flux màxim en sccm escollits un Fluid

Name i un MFC. Aquesta es desactiva automàticament.

void __fastcall TForm1::CheckBox1Click(TObject * Sender)

Page 41: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

41

CheckBox2

Funció: Casella Load Setpoints: canvia la funcionalitat del botó número 2 si es selecciona la casella de verificació.

void __fastcall TForm1::CheckBox2Click(TObject * Sender)

CheckBox3

Funció: Casella Enable MFC-4: habilita els editors de text per introduir els paràmetres corresponents al MFC-4. Inicialment aquest està deshabilitat, per tant no es té en compte alhora de fer els càlculs.

void __fastcall TForm1::CheckBox3Click(TObject * Sender)

CheckBox4

Funció: Casella Carrier Mode: configura el MFC-2 com a Carrier. Si aquesta casella està activada el MFC-1 no ha de ser utilitzat.

void __fastcall TForm1::CheckBox4Click(TObject * Sender)

Page 42: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

42

Form2, “Reading parameters & graphic”

Aquest conté cinc classes, una és la class TForm2 : public TForm que és la interfície gràfica de la plantilla i les altres són les class WriteMeasure[1..4] : public TThread que són fils d’execució. Les classes WriteMeasure són derivades de la classe TThread i són exactament iguals, amb la diferència que cadascuna està associada a un MFC. Es definirà una classe tipus ja que totes tenen les mateixes funcions.

class TForm2 : public TForm

Initial

Funció: Funció que configura l’estat inicial de la plantilla en ser activada. Principalment s’encarrega de configurar les propietats dels objectes de la plantilla Form2. També fa un reset a les diferents sèries que conté la gràfica.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TForm2::Initial(void);

TForm2

Funció: Aquesta s’executa automàticament al activar la plantilla. Configura l’estat inicial de la interfície gràfica fent una crida a la funció Initial() .

__fastcall TForm2::TForm2(TComponent * Owner) : TForm(AOwner)

Page 43: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

43

class WriteMeasure[1..4] : public TThread

WriteMeasure[1..4]

Funció: Aquest és el constructor del fil que conté com a variable un booleà. Crea un objecte concurrent en suspensió (CreateSuspend = true(default)) és per aquesta raó que en la crida al constructor s’ha d’informar que CreateSuspend = false, per tant el procés es reactiva i fa la crida al mètode Execute().

Paràmetres:

(In) CreateSuspended booleà que activa el fil d’execució. Per defecte el seu valor és true.

(out)

Retorn:

__fastcall WriteMeasure[1..4]::WriteMeasure[1..4](bool CreateSuspend)

Execute

Funció: És molt important ja que quant es crea una instància a la classe WriteMeasure[1..4], executa el seu codi automàticament. Per controlar qualsevol element o component visual fa la crida a la funció UpdateLabel[1..4]() mitjançant un mètode especial de Execute()

anomenat Synchronize(UpdateLabel). Aquesta funció és l’encarregada de sincronitzar en milisegons l’execució del fils, per això s’ha utilitzat la funció SYSTEMTIME.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall WriteMeasure[1..4]::Execute(void)

Page 44: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

44

UpdateLabel[1..4]

Funció: Aquesta conté el codi d’execució del fil. És l’encarregada de llegir el flux i el Set point dels MFC. Aquesta lectura ha de ser sincronitzada, per això cada cop que s’executa la funció, aquesta agafa el temps del sistema. Crida a les funcions ReadParameterDirect() i GetSystemTime().Aquest és executat tant en mode de funcionament manual com automàtic.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall WriteMeasure[1..4]::UpdateLabel[1..4](void)

Form4, “Measurement History”

Aquest conté dues classes, una és la class TForm4 : public TForm que és la interfície gràfica de la plantilla i l’altre és la class WriteHistory : public TThread derivada de la classe TThread. Aquesta és un fil d’execució encarregat de fer un registre periòdicament que ens permet veure l’estat amb que estan configurats els MFC.

class TForm4 : public TForm

TForm4

Funció: Aquesta s’executa automàticament al activar la plantilla. Degut a que aquesta plantilla és resumeix amb una finestra de text que és activa durant tota la sessió, no és necessari introduir una crida a cap mètode de configuració d’objectes per aquesta funció.

__fastcall TForm4::TForm4(TComponent * Owner) : TForm(AOwner)

Timer1

Funció: Encarregat d’imprimir un missatge de text i l’hora a la barra d’estat de la plantilla Form4.

void __fastcall TForm1::Timer1Timer(TObject * Sender)

Page 45: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

45

class WriteHistory : public TThread

WriteHistory

Funció: Aquest és el constructor del fil que conté com a variable un booleà. Crea un objecte concurrent en suspensió (CreateSuspend = true(default)) és per aquesta raó que en la crida al constructor s’ha d’informar que CreateSuspend = false, per tant el procés es reactiva i fa la crida al mètode Execute().

Paràmetres:

(In) CreateSuspended booleà que activa el fil d’execució. Per defecte el seu valor és true.

(out)

Retorn:

__fastcall WriteHistory::WriteHistory(bool CreateSuspend)

Execute

Funció: És molt important ja que quant es crea una instància a la classe WriteHistory, executa el seu codi automàticament. Per controlar qualsevol element o component visual fa la crida a la funció UpdateList() mitjançant un mètode especial de Execute anomenat Synchronize(UpdateList).

Aquesta funció és l’encarregada de sincronitzar en segons l’execució del fils, per això s’ha utilitzat la funció SYSTEMTIME.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall WriteHistory::Execute(void)

Page 46: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

46

UpdateList

Funció: Aquesta conté el codi d’execució del fil. És l’encarregada d’imprimir un registre del flux i el Set point dels MFC i agafar la data i l’hora en que s’ha fet la lectura. Aquesta impressió ha de ser sincronitzada, per això cada cop que s’executa la funció aquesta agafa el temps del sistema per saber en quin moment s’ha fet la lectura de les variables que contenen els paràmetres. Crida a la funció GetSystemTime(). Aquest és executat tant en mode de funcionament manual com automàtic. Un cop es tanca la sessió, guarda en un fitxer de text els resultats obtinguts.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall WriteHistory::UpdateList(void)

PagesDlg, “Writing parameters”

Aquest conté una única classe, és la class TPagesDlg : public TForm (descendent

de la classe TForm) que és la interfície gràfica d’aquesta plantilla. Aquesta plantilla es diferencia de les altres perquè disposa de quatre pàgines. Aquestes són completament iguals, amb la diferència que cadascuna d’aquestes és destinada a un MFC. Es definirà una pàgina amb les seves funcions, sent les altres una rèplica d’aquesta.

class TPagesDlg : public TForm

Initial

Funció: Funció que configura l’estat inicial de la plantilla en ser activada. Principalment s’encarrega de configurar les propietats dels objectes de la plantilla PagesDlg.

Paràmetres:

(In)

(out)

Retorn:

void __fastcall TPagesDlg::Initial(void);

Page 47: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

47

TPagesDlg

Funció: Aquesta s’executa automàticament al activar la plantilla. Degut a que aquesta plantilla inicialitza els objectes desde una altra plantilla, no és necessari introduir una crida a cap mètode de configuració d’objectes en aquesta funció.

__fastcall TForm1::TForm1(TComponent * Owner) : TForm(AOwner)

Button[1..4]

Funció: Botó LOAD Write: configura les vàlvules amb els paràmetres introduïts per l’usuari mitjançant la funció WriteParameterDirect. Si l’escriptura es realitza correctament, crea una instància a la classe WriteMeasure que inicia un fil d’execució.

void __fastcall TPagesDlg::Button[1..4]Click(TObject * Sender)

Button[5..8]

Funció: Botó Reset: finalitza l’execució del fil de lectura. Assigna el valor false a la variable booleana global iThreadOff per a que sigui possible tornar a inicialitzar el fil. Elimina la sèrie de la gràfica corresponent al MFC sobre el qual s’està operant.

void __fastcall TPagesDlg::Button[5..8]Click(TObject * Sender)

Page 48: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

48

3.3. Diagrames de flux

A continuació es mostraran els diagrames de flux per a cadascuna de les plantilles que formen el programa. Aquests permeten veure la relació que hi ha entre els objectes de la interfície gràfica i les funcions que executen cadascuna d’elles. També permet veure com es creen els fils d’execució afins. L’objectiu d’aquests és veure quines funcions criden els diferents botons i el vincle que hi ha entre elles sense entrar en detall. Dins alguna de les funcions anomenades en els següents diagrames es realitza la crida a altres funcions de manera enllaçada les quals no seran representades. En cas que es vulgui arribar a un nivell més elevat de detall es recomana consultar el codi font del programa.

La figura 7 mostra el diagrama de flux del Form 3, plantilla principal de FlowBusDDE. Degut a l’extensió d’aquest, s’ha separat en tres blocs els quals són enllaçats mitjançant un identificador numèric.

Figura 7.1: Diagrama de Flux del Form 3 (primer bloc).

Page 49: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

49

Figura 7.2: Diagrama de flux del Form 3 (segon bloc)

Page 50: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

50

Figura 7.3: Diagrama de flux del Form 3 (tercer bloc)

Page 51: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

51

Seguidament la figura 8 mostra el diagrama de flux del Form 1, plantilla encarregada del càlcul de fluxos i de Set points.

Figura 8: Diagrama de flux del Form 1.

Page 52: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

52

A continuació la figura 9 mostra el diagrama de flux del PagesDlg, plantilla encarregada de l’escriptura dels paràmetres de Set point als MFC. Només es detalla una de les 4 pàgines que formen la plantilla, la que fa referència al MFC-1 ja que les altres pàgines són exactament iguals.

Figura 9: Diagrama de flux del PagesDlg.

Page 53: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

53

El següent diagrama fa referència al Form 2 que és una plantilla únicament de lectura. La crida a les funcions que executa aquest són fetes des d’altres plantilles. El diagrama representa les possibles opcions del programa que poden actuar sobre aquesta plantilla i també el seu comportament. Aquest és l’encarregat de generar diferents fils d’execució, un per a cada MFC, per això només es detallarà un fil tipus ja que els altres tenen la mateixa estructura.

La figura 10 mostra el diagrama de flux per aquesta plantilla:

Figura 10: Diagrama de flux del Form 2.

Page 54: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Memòria de càlcul

54

A continuació es mostra el diagrama de flux de l’històric de Mesures que conté el Form 4. Aquest és també únicament de lectura i la seva execució és més senzilla que la de les demés plantilles. A l’arrencada del programa s’inicialitza automàticament, imprimint un historial de les mesures de flux que circules pels diferents MFC, un cop finalitzada la sessió és guardat automàticament en un fitxer de text. El document s’ubica en la carpeta que genera el programa d’instal·lació C:\FlowBusDDE\Files. És important remarcar que si l’usuari vol conservar aquest històric l’haurà de recuperar d’aquest directori ja que sinó en una propera sessió serà reemplaçat.

Form 4

Communication Opened

Thread

GetSystemTime()

new WriteHistory

Stop WriteHistory

Save History Measure

Yes

No

Figura 11: Diagrama de flux del Form 4.

Page 55: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

55

4. Manual d’usuari

4.1. Instal·lació

4.1.1. Requisits del sistema

Windows 2000 / XP / NT

Pantalla amb una resolució mínima de 800 x 600 píxels

L’ordinador on s’instal·la el programa precisa d’un port COM.

4.1.2. Recomanacions

No és recomanable canviar el directori d’instal·lació que es crea per defecte alhora d’instal·lar el programa, ja que sinó podria deixar fora alguna funcionalitat.

El projecte ve acompanyat d’un CD el qual conté l’instal·lador del programa conjuntament amb el present manual d’usuari i altra informació relativa als MFC. Quant explorem el CD trobem un fitxer setup.exe el qual ens instal·la el programa compilat amb les llibreries necessàries per al seu correcte funcionament. A la figura 12 es pot veure el una imatge durant la instal·lació del programa.

Figura 12: InstallShield de FlowBus DDE

Al mateix temps ens crea un accés directe al menú de programes i a l’escriptori. El directori d’instal·lació que conté els fitxers es troba a l’arrel “C:\FlowBusDDE\”. Un cop instal·lat només serà necessari executar un d’aquests accessos directes per a posar en funcionament el programa.

Page 56: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

56

4.2. Introducció

Aquest manual ha estat preparat per facilitar l’aprenentatge de FlowBusDDE, al incloure el desenvolupament “pas a pas” per introduir a l’usuari a la seva correcta execució. Aquest ve a ser una guia en la que es descriuen els diferents conceptes i opcions generals que cal conèixer abans de començar a utilitzar el programa. S’ha preparat un exemple pràctic en l’usuari posarà en pràctica les opcions següents:

- Obrir la comunicació amb Flow Bus.

- Altres opcions de comunicació.

- Opcions de calibratge dels MFC ( lectura i escriptura ).

- Marcar un Set point.

- Opcions de lectura.

- Calculadora de fluxos i Set points.

- Històric de mesures

- Històric de comandes

- Mode de funcionament automàtic.

4.3. Cas pràctic

A continuació es presenta un cas pràctic típic de funcionament de FlowBusDDE on s’explicaran detalladament les diferents opcions del programa seguint l’ordre de l’índex descrit anteriorment en la introducció.

Obrir la comunicació

Una vegada inicialitzat el programa es pot veure que la pàgina principal únicament té habilitat el botó Check Port, algunes opcions de comunicació i les finestres de text que mostraran informació relativa a les comandes executades. Això fa que el test dels ports sigui us pas previ indispensable per a poder obrir la comunicació. Al pressionar el botó imprimeix en la finestra de text els ports disponibles, i al mateix temps també són copiats en una caixa de llista, la que permet seleccionar el port a utilitzar. La figura 13 ens mostra el resultat obtingut després de testejar els ports disponibles de la màquina.

Figura 13: Resultat del test inicial de ports.

Page 57: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

57

Un cop seleccionat un port COM s’obre la comunicació mitjançant el botó Open communication. A continuació apareix un missatge en l’històric de comandes indicant si aquesta s’ha obert amb èxit o no com es veu a la figura 14.

Figura 14: Històric de comandes

Si tot és correcte són habilitades totes les opcions del programa, permetent a l’usuari treballar amb plena llibertat. En cas contrari apareixerà un codi d’error amb un missatge associat informant del motiu pel qual no s’ha put establir la comunicació. La figura 15

mostra un exemple d’error en obrir la comunicació.

Figura 15: Finestra de text de control d’errors.

Opcions de comunicació

L’usuari disposa de dos botons els quals permeten: fer un test de la comunicació per saber si aquesta està oberta “Check Comm” i tancar la comunicació “Close Comm”. Aquests poden ser utilitzats en qualsevol moment durant la sessió.

Suposant que la comunicació està oberta, pressionar el botó Check Comm i visualitzar el missatge que apareix en l’històric de comandes. Seguidament tancar la comunicació amb el botó Close Comm i tornar a fer un test de la comunicació. La seqüència de missatges obtinguda en l’històric de comandes hauria de ser el que es mostra en la figura 16.

Figura 16: Resultats de les operacions de comunicació.

Page 58: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

58

És important recalcar que per a sortir del programa anteriorment s’ha d’haver tancat la comunicació amb FlowBus. Això no implicarà cap canvi amb la configuració dels MFC, és a dir que conservaran els paràmetres introduïts prèviament per l’usuari.

Opcions de calibratge

Lectura

Els MFC són capaços d’emmagatzemar fins a 9 tipus de calibratge diferents. Aquests disposen d’una memòria de tipus vectorial amb les posicions [0..8] on cadascuna d’aquestes té associada un nom per identificar el fluid. Per llegir el calibratge només cal identificar el instrument mitjançant la caixa de llista Select MFC i a continuació pressionar el botó Reading Calibration. Al pressionar el botó obtenim la resposta a la finestra de text Command History, on ens indica el node (MFC) i el nom del gas.

La configuració actual de la xarxa segueix una numeració diferent per identificar els instruments. El MFC-1 equival al Node 3, el MFC-2 al Node 4, etc...

A continuació ens disposem a llegir el tipus de calibratge del MFC-1. En primer lloc s’ha de seleccionar el MFC a la caixa de llista i a continuació pressionar el botó per a llegir el calibratge. El resultat obtingut apareix en forma de text l’historial de comandes tal i com es pot apreciar a la figura 17.

Figura 17: Resultats de la lectura de calibratge al MFC-1.

Per a llegir la configuració dels altres instruments només caldrà seguir el mateix procés però canviant el MFC sobre el que es vulgui operar.

En cas d’error de lectura del calibratge el programa mostra un codi identificador d’error amb un missatge associat detallant el motiu pel que no s’ha pogut realitzar la lectura.

Page 59: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

59

Escriptura

El programa també dóna la opció de canviar el mode de calibratge de les vàlvules. Per això és necessari activar la casella de verificació Writing Mode. En activar aquesta s’habiliten automàticament els editors de text Fluid Number i Fluid Name. El primer d’aquests ens permet canviar la posició de memòria amb la que està configurada la vàlvula. El segon ens permet modificar el nom que té associada aquesta posició de memòria.

Actualment existeixen dos tipus de calibratge per als MFC. La posició de memòria número 0 que equival a AIR i la posició de memòria número 1 que equival a CO2. El programa està preparat per a treballar amb nous calibratges que es puguin configurar conseqüència de futures proves amb diferents barreges de gasos.

Seguidament es modificarà la configuració del MFC-1, actualment configura a CO2 per a que treballi en mode AIR. Inicialment activarem la casella de verificació Writing

Mode. Un cop habilitats els editors de text introduïm en el Fluid Number el número de posició de memòria corresponent al nou mode de calibratge, en aquest cas el 0. Per acabar només cal pressionar el botó WriteCalibration. La figura 18 mostra els resultats obtinguts.

Figura 18: Resultats de les operacions de calibratge sobre el MFC-1.

Igualment com en el mode de lectura de calibratge, en cas d’error apareixerà un missatge detallant els motius pels quals no s’ha pogut realitzar la lectura.

Marcar un Set point

El Set point és el percentatge d’obertura amb que treballa un MFC. El programa permet introduir aquest paràmetre des de varies plantilles del programa. En aquest apartat es detallarà com introduir un set point marcat per l’usuari de forma manual. La plantilla encarregada de realitzar aquesta operació és el PagesDlg.

Page 60: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

60

Un cop oberta la comunicació podem accedir a aquesta plantilla mitjançant el botó Write Parm. Aquesta plantilla conté 4 pàgines i cadascuna correspon a un MFC. Per configurar el set point s’ha d’introduir un valor numèric entre 0 i 100 per cent. És possible introduir un valor que contingui decimals mitjançant una coma. Un cop teclejat el valor, només cal pressionar el botó Load Write.

La figura 19 mostra com establir un set point al MFC-1 mitjançant aquesta plantilla.

Figura 19: Plantilla PagesDlg.

Aquesta també ens permet veure, en el cas de que existeixi, el set point amb que està configurada la vàlvula mitjançant l’etiqueta de lectura Setpoint %. També ens permet veure el percentatge de flux actualitzat cada segon mitjançant l’etiqueta de lectura Measure (%).

Al finalitzar la operació apareix un missatge a l’històric de comandes informant si la operació s’ha completat correctament o no. En el cas d’error apareixerà un missatge detallant els motius pels quals no s’ha pogut realitzar la l’escriptura del Set point.

Page 61: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

61

Opcions de lectura

En establir un set point el programa permet veure els resultats directament en la mateixa plantilla PagesDlg com es comenta en l’apartat anterior. Al mateix temps el programa obre una nova plantilla on es representa gràficament la lectura del flux per a cadascun dels MFC que estiguin en funcionament. Per accedir a aquesta plantilla es fa mitjançant el botó Read Parm. La figura 20 mostra els resultats en configurar un set point del 45% al MFC-1 i del 50% al MFC-3 durant un procés de configuració en mode automàtic.

Figura 20: Plantilla de lectura gràfica.

Aquesta també es pot obrir de forma manual sense configurar un set point. En el cas de que ja existeixi un percentatge d’obertura configurat en alguna sessió anterior, automàticament executa la funció de lectura i comença a representar els resultats gràficament.

En el cas de que es provoqui un error continuat de lectura apareixerà un missatge d’error en l’etiqueta de lectura Measure %. Al mateix temps com en les opcions anteriors es mostrarà en la plantilla principal un missatge detallant els motius pels quals no s’ha pogut realitzar la lectura.

Page 62: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

62

Calculadora de fluxos i de Set points

Es pot accedir a aquesta plantilla mitjançant el botó Flow calculator. Aquesta ens permet calcular automàticament els fluxos de sortida de cadascun dels MFC en sccm i també el percentatge d’obertura per cada instrument. Els paràmetres que ha d’introduir l’usuari són Flux màxim total a la sortida, el calibratge amb que està treballant cada MFC i les concentracions de l’ampolla i la desitjada en la barreja en ppm.

A continuació configurarem els MFC-1 i el MFC-3 en mode AIR amb un Flux màxima a la sortida de 200 sccm. Inicialment seleccionarem en la caixa de llista AIR i a continuació el MFC, també en la caixa de llista, com mostra la figura 21. Un cop fet això s’ha de pressionar la casella de verificació Change fluid. El Flux Màxim per a aquest calibratge es carrega automàticament per al MFC seleccionat. Seguir el mateix procés per l’altre instrument.

Suposant que la concentració de l’ampolla del MFC-3 és de 100 ppm i que es desitja 4 ppm en la barreja. Introduir els paràmetres com mostra la figura 21. Un cop teclejats els valors procedim a calcular els resultats amb el botó calculate. Automàticament apareixen els Fluxos i els Set points calculats

Aquests resultats els podem traspassar directament a les vàlvules activant la casella de verificació Load Setpoints ja que aquesta modifica les propietats del botó calculate

que canvia el seu nom per Load. Només cal pressionar el botó i els Set points són configurats en els vàlvules.

Figura 21: Calculadora de fluxos i set points.

Inicialment el càlcul està pensat per a què el MFC-1 treballi com a portador. Podem modificar aquest paràmetre de configuració per defecte mitjançant la casella de verificació carrier mode ubicada en l’agrupació del MFC-2 Target que activa a aquest com a portador. En el cas que s’hagi d’adoptar aquesta opció, és important deixar en blanc el Flux Max del MFC-1.

Page 63: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

63

Aquesta també està preparada per a fer càlculs amb un quart MFC. Per habilitar aquest s’ha de seleccionar la casella de verificació Enable MFC-4. Automàticament s’habiliten els editors de text per a aquest instrument. El procés a seguir serà exactament el mateix però amb una petit detall a modificar i és que com no està definit el cabal màxim que tindrà el instrument, ja que és una previsió futura, s’haurà de teclejar manualment el flux màxim en funció dels diferents tipus de calibratge.

El botó de reset elimina tots els possibles valors introduïts i calculats amb anterioritat.

Històric de mesures

La plantilla ens permet visualitzar els canvis que es produeixen durant una sessió i és exclusivament de caràcter informatiu. En aquesta s’hi imprimeix la data, l’hora, el MFC (node), el set point i la mesura. És inicialitzada automàticament i la impressió es fa per a tots els MFC cada 30 segons. Per accedir a aquesta s’ha de pressionar el botó View History. Quant sortim del programa els resultats es guarden en un fitxer de text en el directori C:\FlosBusDDE\Files. En cas que interessi recuperar el fitxer serà necessari canviar-lo de lloc o renombrar-lo abans de tornar a iniciar FlowBusDDE.

Històric de comandes

El programa permet emmagatzemar el Commands History a un fitxer de text. Per guardar-lo cal pressionar el botó Save Commands. En polsar el botó s’obre un quadre de diàleg de Windows que permet seleccionar la ubicació i el nom del fitxer. Quant es desa el fitxer apareix un missatge indicant l’hora a la que s’ha realitzat la operació com es pot veure en la figura 22.

Figura 22: Resultat en guardar l’històric de comandes.

Page 64: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

64

Mode de funcionament automàtic

Primer de tot cal fer una petita introducció què és i com es pot crear un fitxer CSV. El format d’arxiu CSV(*.csv) guarda únicament el text i els valors como apareixen en les cel·les d’una fulla de càlcul de Excel activa. Les columnes de dades es separen mitjançant comes i cada fila acaba un retorn de carro. Si una cel·la conté una coma, el contingut de la cel·la s’escriurà entre cometes dobles.

Si les cel·les presenten formules enlloc de valors, aquestes es convertiran a text. Tot el format, gràfics, objectes i qualsevol altre contingut de la fulla de càlcul es perdrà.

El programa disposa d’una plantilla CSV que s’obre automàticament al pressionar el botó New ubicat en l’agrupació File *.csv (veure figura 25). La figura 23 mostra la plantilla de Excel que s’obre en polsar el botó.

Figura 23: Plantilla CSV per al mode automàtic.

Com es pot veure en la figura 23 la plantilla disposa de tres columnes. El NODE correspon al MFC, és a dir el Node 3 equival al MFC-1, el Node 4 equival al MFC-2, etc... El SETPOINT(%) és el percentatge d’obertura que es configurarà a el instrument segons el node seleccionat en al mateixa fila. El TIME(s) és el temps en segons que tardarà el programa en configurar la instrucció que conté la línea següent, és a dir que és un temps seqüencial.

A continuació es configurarà una taula de valors per a l’execució en mode de funcionament automàtic com es pot veure en la figura 24.

Figura 24: Exemple de configuració fitxer CSV.

Page 65: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Manual d’usuari

65

Un cop omplert el fitxer cal escollir-lo per a què el programa comenci a realitzar el procés d’execució. Per seleccionar-lo s’ha de pressionar el botó Open el qual obre un diàleg de Windows el que permet seleccionar un fitxer. Un cop localitzat, si polsem el botó Open del diàleg de text, la ruta del fitxer s’imprimeix sota les opcions de l’agrupació File *.csv com mostra la figura 25.

Figura 25: Opcions inicials del mode automàtic.

Seguidament s’ha de seleccionar la casella de verificació LOAD CSV File, encarregada de canviar la funcionalitat dels botons tal i com mostra la figura 26.

Figura 26: Opcions de càrrega del mode automàtic.

Es pot veure com canvien la funcionalitat dels botons New i Open que passen a dir-se Stop i Load, conjuntament amb la casella de verificació que ens indica que està a punt de carregar-se un fitxer per activar el mode de funcionament automàtic.

Important: En pressionar el botó Load arribat aquest punt, es deshabilitaran totes les opcions d’escriptura vistes anteriorment en el mode de funcionament manual. També cal dir que si existeix alguna configuració en algun MFC serà modificada amb els valors que l’usuari hagi introduït en el fitxer CSV.

El botó STOP permet aturar el procés automàtic i torna el control a l’usuari de les funcions que estaven deshabilitades, sent la configuració del programa la inicial.

Page 66: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Conclusions

66

5. Conclusions

5.1. Conclusions

El plantejament inicial d’aquest projecte ha estat desenvolupar un programa amb C++ Builder per al control dels Mass Flows encarregats de controlar un sistema de barreges de gasos. Per a poder fer possible aquest projecte ha estat un requisit imprescindible el bon coneixement de la API de FlowBus facilitada per Bronkhorst. Gràcies a aquesta i a la DLL de FlowBusDDE ha estat possible establir comunicació i portar el control d’aquests instruments.

El programa actualment controla 3 MFC tot i que ha estat implementat amb la possibilitat d’introduir un nou MFC. Aquest està obert a modificacions i ampliacions futures ja que s’adjunta la documentació necessària per a que una tercera persona pugui programar noves implementacions.

El present projecte ha assolit els requeriments inicialment plantejats per al control dels MFC i s’han complert els objectius per facilitar l’execució del programa per als tècnics encarregats del funcionament del sistema de barreja de gasos solucionant algunes mancances del programa que utilitzen actualment.

5.2. Treball futur

Com a treball futur el FlowBusDDE pot incorporar una aplicació per controlar l’adquisició de dades dels sensors. El programa està totalment obert a modificacions i preparat per introduir noves plantilles sense que aquestes modifiquin programa actual. També està obert a l’ampliació del sistema de control del MFC per a futures incorporacions de nous instruments.

Page 67: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Bibliografia

67

6. Bibliografia [1] Pàgina Web http://www.bronkhorst.com [Fitxa tècnica MFC] Gener

[2] Pàgina Web http://www.winapi.conclase.net [Api Win32] Gener - febrer

[3] Pàgina Web http://www.null-modem.com [Connexió] Febrer

[4] Pàgina Web http://www.codeguru.com [codi font] Febrer

[5] Llibre: Ian Marteens, La cara oculta de C++ Builder, 1999

[6] Pàgina Web http://www.wikipedia.org [varis] Gener - Juny

[7] Pàgina Web http://www.latindevelopers.com [codi font] Març

[8] Pàgina Web http://foros.solocodigo.com [codi font] Gener - Juny

[9] Pàgina Web http://www.functionx.com [Threads] Març

[10] Pàgina Web http://bcb-tutorial.c-plusplus.de [Threads] Març

[11] Pàgines Web http://elvex.ugr.es/decsai/builder/ [Threads] Maig

[12] Pàgines Web http://www.codersource.net/win32_waitforsingleobject.html [semàfors] Maig

[13] Pàgines Web http://www.codeproject.com/file/cdatafile.asp [fitxers csv] Maig

[14] Pàgina Web http://msdn2.microsoft.com/en-us/library/ms644901.aspx [timers] Maig

[15] Pàgines Web http://www.zator.com/Cpp/E5_5_2.htm [fitxer csv] Maig

[16] Pàgines Web http://www.cplusplus.com [timers] Juny

[17] Manual: Operation instructions digital Mass Flow [adjunt als annexes]

[18] Manual: RS232 interface With FLOW-BUS protocol for digital Mass Flow [adjunt als annexes]

[19] Manual: Interface Design Document Flow-Bus DLL FOR WIN32 [adjunt als annexes]

Page 68: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Annexes

68

7. Annexes

7.1. Annex 1: Codi font del programa

7.1.1. Project2.cpp

//$$---- EXE CPP ----

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

//---------------------------------------------------------------------------

USEFORM("Unit1.cpp", Form1);

USEFORM("Unit2.cpp", Form2);

USEFORM("Unit3.cpp", Form3);

USEFORM("Unit4.cpp", Form4);

USEFORM("TABPGDLG.cpp", PagesDlg);

//---------------------------------------------------------------------------

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

{

try

{

Application->Initialize();

Application->CreateForm(__classid(TForm3), &Form3);

Application->CreateForm(__classid(TForm2), &Form2);

Application->CreateForm(__classid(TForm4), &Form4);

Application->CreateForm(__classid(TPagesDlg), &PagesDlg);

Application->CreateForm(__classid(TForm1), &Form1);

Application->Run();

}

catch (Exception &exception)

{

Application->ShowException(&exception);

}

catch (...)

{

try

{

throw Exception("");

}

catch (Exception &exception)

{

Application->ShowException(&exception);

}

}

return 0;

}

//---------------------------------------------------------------------------

Page 69: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

69

7.1.2. FlowbusAPI.h

#ifndef FLOWBUSAPI_H

#define FLOWBUSAPI_H

#include <windows.h>

/*

Type which contains information about available communication ports

and cards

prefix: udt_PortInfo_

*/

struct PortInfoType

{

bool bInUse; /*Tells wheter or not the port / card is currently in

use*/

char sPortName[25]; /*Name of the port / card, maximum of 25 characters*/

};

class clsFlowbusAPI

{

private:

HMODULE hLibModule;

void InitializeFunctionPointers(HMODULE hLibModule);

public:

clsFlowbusAPI();

~clsFlowbusAPI();

bool FlowbusDllLoaded();

/*

FLOWB32.DLL function description for use in Microsoft Visual C++ and

Borland C++.

NOTE:

These functions can also be called from other environments, such as C or

Pascal. In this case only the calling syntax will be different,

not the functionality of these routines.

Following functions can be called by WINDOWS application programs

The FLOWB32.DLL provides a mechanism to transport parameter values to a

specific module connected to the Bronkhorst High-Tech FLOW-BUS.

Each module has its specific list with parameters

Each parameter is of type integer/float/long/char/string and mostly has min

and max values

Some parameters are read-only or write-only

On FLOW-BUS modules a parameter is located on a 'process'

Each FLOW-BUS module has its own 'node-address' in the system (systems can

have up to 120 nodes (addresses)

So, when locating a parameter for changing/reading its value,

you need to know: node-, process- and parameter number

For more convenience in addressing parameters there are virtual channel

numbers linked to node-processes.

This means that you can work with parameters on a certain channel.

When communication is openened, the actual FLOW-BUS system configuration

is read and stored in a large structure in memory.

You can determine the amount of nodes, amount of channels and the link

of a channel to a certain node-process with help of following functions

Bronkhorst High-Tech also offers a WINDOWS DDE-server which makes use of

Page 70: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

70

all functions below and actually behaves as a software layer between your

application and FLOW-BUS. For communication, just select an interface in

the DDE-server and start-up. When the program is running you can

read/write parameters on a DDE-channel

Advantage: much easier for the user

Disadvantage: slower than communicating directly through C or Pascal

*/

k/*

FBE_NO_ERROR 0 No error

FBE_PROCESS_CLAIM 1 This process cannot be operated by this

module

FBE_COMMAND 2 No such command possible for this module

FBE_PROCESS 3 No such process at this module

FBE_PARM_NUMBER 4 No such parameter at this process

FBE_PARM_TYPE 5 Type of parameter sent differs from type on

module

FBE_PARM_VALUE 6 Wrong value for this parameter or not

accepted

FBE_NETWORK_NOT_ACTIVE 7 No communication activity on FLOW-BUS

detected

FBE_TIME_OUT_START_CHAR 8 Start character serial communication failed

FBE_TIME_OUT_SERIAL_LINE 9 Serial communication failed

FBE_MODULE_HARDWARE_MEM 10 Memory on FLOW-BUS module failed

FBE_NODE_ADDRESS 11 Wrong node number

FBE_COMMUNICATION 12 General communication error

FBE_READ_ONLY_PARM 13 This parameter value can only be read

FBE_PC_COMMUNICATION 14 There is no communication between PC and

FLOW -BUS

FBE_RS232_CONNECTION 15 HOST_ERROR, no/bad connection between PC

and a RS232-module

FBE_PC_MEMORY 16 DLL ERROR, not enough memory in your PC

for communication structure

FBE_WRITE_ONLY_PARM 17 this parameter value can only be send

FBE_SYS_CONFIG_UNKNOWN 18 FLOW-BUS system configuration is unknown

FBE_NO_FREE_NODE_ADDR 19 FLOW-BUS system reached maximum size

(32 nodes)

FBE_WRONG_INTERFACE_TYPE 20 need other type of interface for this

option

FBE_BUILD_DCB 21 DLL_ERROR, error building device control

block serial port

FBE_OPEN_COMM 22 DLL ERROR, open communication went wrong

FBE_COMM_STATE 23 DLL ERROR, communication status error

FBE_INTERFACE_BUSMASTER 24 interface tries to start communication

(alone in system)

FBE_TIMEOUT_ON_RX_ANSWER 25 time out on rx answer

FBE_NO_START_CHAR 26 HOST ERROR, no //:// on start of message

FBE_FIRST_DIGIT 27 HOST ERROR, error in first digit

FBE_HOST_OVERFLOW 28 HOST ERROR, buffer overflow in host

FBE_BUFFER_OVERFLOW 29 DLL ERROR, buffer overflow in DLL

FBE_NO_ANSWER_FOUND 30 DLL ERROR, requested answer not found

FBE_CLOSE_COMM 31 DLL ERROR, closing communication error

FBE_SYNCHRON_ERROR 32 DLL ERROR, other application performs

action

FBE_SEND_ERROR 33 DLL ERROR, requested msg. not send

FBE_PROTOCOL_ERROR 34 DLL ERROR, error in received data

FBE_NO_EVENT 35 DLL ERROR, no event present on

realtimechannel

*/

/*-----------END OF ERROR LIST SECTION------------------------------------*/

Page 71: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

71

/*-----------FUNCTIONS TO OPEN / CLOSE THE DLL----------------------------*/

/***************************************************************************

OpenDLL

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which opens the DLL for a certain application.

In theory it should be possible to attach different

applications to the same DLL. In practice, however it will

not work. Therefore you should call this function

ONLY ONCE in your code (at initialization), to avoid

problems.

Parameters:

(In) lHwnd: Always supply value 0 for this parameter

(Out)

Returned : 0, if the function failed, otherwise an ApplicationId.

Don't throw this ApplicationId away, because you must

use it in almost every other DLL-function..

Remarks :

*/

typedef short (__stdcall * _OpenDLL)(long lHwnd);

_OpenDLL OpenDLL;

/***************************************************************************

CloseDLL

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which closes the DLL for a certain application.

In theory it should be possible to attach different

applications to the same DLL. In practice, however it

will not work. Therefore you should call this function

ONLY ONCE in your code (when closing the application),

to avoid problems.

Parameters:

(In) iAppId: The ApplicationId of your application

(retrieved from function OpenDLL())

(Out)

Returned :

Remarks :

*/

typedef void (__stdcall * _CloseDLL)(short iAppId);

_CloseDLL CloseDLL;

/*------END OF FUNCTIONS TO OPEN / CLOSE THE DLL--------------------------*/

/*------FUNCTIONS TO OPEN / CLOSE THE COMMUNICATION WITH THE FLOWBUS------*/

/***************************************************************************

OpenCommunication

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which opens the communication with the flowbus on

a specified COM-port.

Parameters:

(In) sPortName: Name of the port to open ("COM1" or "COM2"

for example)

(Out)

Returned : 0 on succes, an error from the "ERROR LIST SECTION"

Page 72: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

72

(see beginning of this module) on failure

Remarks :

*/

typedef short (__stdcall * _OpenCommunication)(char * sPortName);

_OpenCommunication OpenCommunication;

/***************************************************************************

CloseCommunication

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which closes the communication with the flowbus on

a specified port.

Parameters:

(In) sPortName: Name of the port to close ("COM1" or "COM2"

for example)

(Out)

Returned : 0 on succes, an error from the "ERROR LIST SECTION"

(see beginning of this module) on failure

Remarks :

*/

typedef short (__stdcall * _CloseCommunication)();

_CloseCommunication CloseCommunication;

/*--END OF FUNCTIONS TO OPEN / CLOSE THE COMMUNICATION WITH THE FLOWBUS---*/

/*--------------FUNCTIONS TO GET / SET THE BAUDRATE OF YOUR COM-PORT------*/

/***************************************************************************

ConfigureRS232

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function to configure the baudrate of a certain COM-port.

This function should be called before calling

OpenCommunication().

The baudrate of your pc//s COM-port (the one you use to

communicate with flowbus), must of course be the same as

the baudrate of your "RS232/Flowbus interface"-box

Parameters:

(In) sPortName: Name of the port to configure ("COM1" or "COM2"

for example)

uiBaudRate: New baudrate for the port

(Out)

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _ConfigureRS232)(char * sPortName,unsigned short

uiBaudRate);

_ConfigureRS232 ConfigureRS232;

/***************************************************************************

GetRS232Config

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function to read / get the baudrate of a certain COM-port.

Parameters:

(In)

(Out) sPortName: Name of the current communication port

Page 73: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

73

("COM1" or "COM2" for example)

uiBaudRate: Baudrate of the port

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef void (__stdcall * _GetRS232Config)(char * sPortName,unsigned short *

iBaudRate);

_GetRS232Config GetRS232Config;

/*-------END OF FUNCTIONS TO GET / SET THE BAUDRATE OF YOUR COM-PORT------*/

/*-FUNCTIONS TO GET / SET PC(ISA)-CARD CONFIGURATION AND NETWORK SETTINGS-*/

/***************************************************************************

ConfigureTNet

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which configures the PC(ISA)/FLOW-BUS interface

card or the FLOW-BUS network settings of your "RS232/flowbus

interface"-box which is directly connected to your pc..

In case the application wants to use an ISA card it

configures the specified card with: device name, node number,

secondary node, next node and arbitration mode.

Only device name and arbitrage are used internally.

Parameters:

(In) bytNode: Primary node adress of the "RS232/flowbus

interface"-box.

bytSecNode: Second node adress of the "RS232/flowbus

interface"-box.

bytNextNode: Next node adress of the "RS232/flowbus

interface"-box.

bytLastNode: Last node adress of the "RS232/flowbus

interface"-box.

bytArbiterMode: Arbiter mode of the "RS232/flowbus

interface"-box.

bytTxRetries: Number of attempts to write a parameter,

before an error occurs

bytRxRetries: Number of attempts to read a parameter,

before an error occurs

sPort: COM-port on which to start communication

with flowbus

(Out)

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _ConfigureTNet)(char bytNode,

char bytSecNode, char bytNextNode,

char bytLastNode, char bytArbiterMode,

char bytTxRetries, char bytRxRetries,

char * sPort);

_ConfigureTNet ConfigureTNet;

/***************************************************************************

GetTNetConfig

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function to get the current configuration of the

PC(ISA)/FLOW-BUS interface card or the FLOW-BUS network

settings of your "RS232/flowbus interface"-box which is

directly connected to your pc..

Page 74: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

74

Parameters:

(In)

(Out) bytNode: Primary node adress of the "RS232/flowbus

interface"-box.

bytSecNode: Second node adress of the "RS232/flowbus

interface"-box.

bytNextNode: Next node adress of the "RS232/flowbus

interface"-box.

bytLastNode: Last node adress of the "RS232/flowbus

interface"-box.

bytArbiterMode: Arbiter mode of the "RS232/flowbus

interface"-box.

bytTxRetries: Number of attempts to write a parameter,

before an error occurs

bytRxRetries: Number of attempts to read a parameter,

before an error occurs

sPort: COM-port on which the communication with

flowbus is currenly handled.

Returned :

Remarks :

*/

typedef void (__stdcall * _GetTNetConfig)(char * bytNode,

char * bytSecNode, char * bytNextNode,

char * bytLastNode, char * bytArbiterMode,

char * bytTxRetries, char * bytRxRetries,

char * sPort);

_GetTNetConfig GetTNetConfig;

/*-END OF FUNCTIONS TO GET / SET PC(ISA)-CARD CONFIGURATION AND NETWORK-- */

/*------------FUNCTIONS TO CONFIGURE CHAINING-----------------------------*/

/***************************************************************************

ConfigureChaining

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function with which you can configure the settings for

process and parameter chaining. Process chaining is not

supported on older FlowBus modules. Therefore the advise is

to disable process-chaining, unless you know that all flowbus

modules in the network support process chaining (in which case

enabling process chaining is better). Parameter chaining

should be enabled to decrease the number of messages send over

the network (decrease network traffic)

Parameters:

(In) bProcChain: Boolean which indicates if process chaining should

be enabled

bParChain: Boolean which indicates if parameter chaining

should be enabled

(Out)

Returned :

Remarks :

*/

typedef void (__stdcall * _ConfigureChaining)(bool bProcChain, bool bParChain);

_ConfigureChaining ConfigureChaining;

/*-----------END FUNCTIONS TO CONFIGURE CHAINING--------------------------*/

Page 75: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

75

/*-----------FUNCTIONS TO CHECK THE NETWORK FOR ERRORS--------------------*/

/***************************************************************************

GetError

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which checks if a network error occurred and clears

the possible error. This function can be called any time.

Especially when a function returns no error,

you can call this method after executing the function.

Parameters:

(In)

(Out)

Returned : 0 No error occured

-1 Device identifier invalid, unsupported or lack of

memory

-2 Device is already open.

-3 Device is NOT open.

-4 The function cannot allocate enough memory for the

queues.

-5 Default parameters are in error.

-10 The hardware is not available

(locked by another device).

-11 Specified byte size is invalid.

-12 Baudrate of the device is unsupported.

22 Com port not opened (for PC-ISA card)

28 Too many messages sent to host (for PC-ISA card)

31 Network not opened (for PC-ISA card)

33 Error sending data

34 Error in received data

Remarks :

*/

typedef short (__stdcall * _GetError)();

_GetError GetError;

/*-------END OF FUNCTIONS TO CHECK THE NETWORK FOR ERRORS-----------------*/

/*-------FUNCTIONS TO SEND A READ-REQUEST FOR A CERTAIN PARAMETER---------*/

/***************************************************************************

ReadChar

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function sends a request / message to a certain node, that it

wants to know the value of a certain parameter. The parameter

type is Byte (1 character). The value of the parameter is send

by the node in another messsage. You have to call

CheckReceivedMsg() to check if you have received an answer on

your request-message. If so, you can call GetChar() to get

the value of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

iMsgId: MessageId of the message.

You may choose any value for it with restriction to

the following:

- No 2 messages can have the same MessageId. Only if

Page 76: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

76

a message is removed

the MessageId can be used again.

Keep the MessageId, you will need it later to check

if you received an answer-message on your

request

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : There can be no 2 messages at the same time with the same

(Node, Proces, Parameter) combination. Only if the message

has been removed, another message can be send to

this (Node, Process, Parameter) combination

*/

typedef short (__stdcall * _ReadChar)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytParm, short iMsgId);

_ReadChar ReadChar;

/***************************************************************************

ReadInt

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function sends a request / message to a certain node, that it

wants to know the value of a certain parameter. The parameter

type is integer. The value of the parameter is send by the

node in another messsage. You have to call CheckReceivedMsg()

to check if you have received an answer on your

request-message. If so, you can call Getint() to get the value

of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

iMsgId: MessageId of the message.

You may choose any value for it

with restriction to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the MessageId

can be used again.

Keep the MessageId, you will need it later to check

if you received an answer-message on your

request

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : There can be no 2 messages at the same time with the same

(Node, Proces, Parameter) combination. Only if the message

has been removed, another message can be send to

this (Node, Process, Parameter) combination

*/

typedef short (__stdcall * _ReadInt)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytParm, short iMsgId);

_ReadInt ReadInt;

/***************************************************************************

ReadFloat

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Page 77: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

77

Function : Function sends a request / message to a certain node, that it

wants to know the value of a certain parameter. The parameter

type is Float. The value of the parameter is send by the node

in another messsage. You have to call CheckReceivedMsg() to

check if you have received an answer on your request-message.

If so, you can call GetFloat() to get the value of the

parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

iMsgId: MessageId of the message.

You may choose any value for it with

restriction to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the MessageId

can be used again.

Keep the MessageId, you will need it later to check

if you received an answer-message on your

request

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : There can be no 2 messages at the same time with the same

(Node, Proces, Parameter) combination. Only if the message

has been removed, another message can be send to

this (Node, Process, Parameter) combination

*/

typedef short (__stdcall * _ReadFloat)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytParm, short iMsgId);

_ReadFloat ReadFloat;

/***************************************************************************

ReadLong

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function sends a request / message to a certain node, that it

wants to know the value of a certain parameter. The parameter

type is Long. The value of the parameter is send by the node

in another messsage. You have to call CheckReceivedMsg() to

check if you have received an answer on your request-message.

If so, you can call GetLong() to get the value of the

parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

iMsgId: MessageId of the message.

You may choose any value for it with

restriction to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the MessageId

can be used again.

Keep the MessageId, you will need it later to

Page 78: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

78

check if you received an answer-message on

your request

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : There can be no 2 messages at the same time with the same

(Node, Proces, Parameter) combination. Only if the message

has been removed, another message can be send to

this (Node, Process, Parameter) combination

*/

typedef short (__stdcall * _ReadLong)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytParm, short iMsgId);

_ReadLong ReadLong;

/***************************************************************************

ReadString

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function sends a request / message to a certain node, that

it wants to know the value of a certain parameter.

The parameter type is String (1 or more characters).

The value of the parameter is send by the node in another

messsage. You have to call CheckReceivedMsg() to check if

you have received an answer on your request-message.

If so, you can call GetString() to get the value of the

parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

bytExpLen: Expected length of the string.

If you supply 0, a zero-terminated string is

expected.

iMsgId: MessageId of the message.

You may choose any value for it with

restriction to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the MessageId

can be used again.

Keep the MessageId, you will need it later

to check if you received an answer-message

on your request

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : There can be no 2 messages at the same time with the

same (Node, Proces, Parameter) combination. Only if

the message has been removed, another message can be send

to this (Node, Process, Parameter) combination

*/

typedef short (__stdcall * _ReadString)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytParm, char bytExpLen,

short iMsgId);

_ReadString ReadString;

/*-----END OF FUNCTIONS TO SEND A READ-REQUEST FOR A CERTAIN PARAMETER----*/

Page 79: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

79

/*--------------FUNCTIONS TO WRITE A PARAMETER----------------------------*/

/***************************************************************************

WriteChar

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which gives a certain parameter a new value

(writes a parameter value).

The parameter type is Byte (1 character).

You have to call CheckReceivedMsg() to check if you have

received an answer on your message. The answer-message

contains a statuscode which indicates if the value was

succesfully written, or an error occured. Call GetStatus()

to determine if the parameter was succesfully written.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

bytNewValue: New value for the parameter

iMsgId: MessageId of the message.

You may choose any value for it with

restriction to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the

MessageId

can be used again.

Keep the MessageId, you will need it later

to check if you received an answer-

message

on your request

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : There can be no 2 messages at the same time with the same

(Node, Proces, Parameter) combination. Only if the message

has been removed, another message can be send to

this (Node, Process, Parameter) combination

*/

typedef short (__stdcall * _WriteChar)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytParm, char bytNewValue,

short iMsgId);

_WriteChar WriteChar;

/***************************************************************************

WriteInt

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which gives a certain parameter a new value

(writes a parameter value).

The parameter type is integer.

You have to call CheckReceivedMsg() to check if you have

received an answer on your message. The answer-message

contains a statuscode which indicates if the

value was succesfully written, or an error occured.

Call GetStatus() to determine if the parameter was

succesfully written.

Page 80: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

80

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

iNewValue: New value for the parameter

iMsgId: MessageId of the message.

You may choose any value for it with

restriction to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the

MessageId

can be used again.

Keep the MessageId, you will need it later

to check if you received an answer-

message

on your request

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : There can be no 2 messages at the same time with the same

(Node, Proces, Parameter) combination. Only if the message

has been removed, another message can be send to

this (Node, Process, Parameter) combination

*/

typedef short (__stdcall * _WriteInt)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytParm, short iNewValue,

short iMsgId);

_WriteInt WriteInt;

/***************************************************************************

WriteFloat

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which gives a certain parameter a new value

(writes a parameter value).

The parameter type is Float.

You have to call CheckReceivedMsg() to check if you have

received an answer on your message. The answer-message

contains a statuscode which indicates if the value was

succesfully written, or an error occured. Call GetStatus()

to determine if the parameter was succesfully written.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

fNewValue: New value for the parameter

iMsgId: MessageId of the message.

You may choose any value for it with

restriction to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the

MessageId

can be used again.

Keep the MessageId, you will need it later

to check if you received an answer-

message

Page 81: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

81

on your request

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : There can be no 2 messages at the same time with the same

(Node, Proces, Parameter) combination. Only if the message

has been removed, another message can be send to

this (Node, Process, Parameter) combination

*/

typedef short (__stdcall * _WriteFloat)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytParm, float fNewValue,

short iMsgId);

_WriteFloat WriteFloat;

/***************************************************************************

WriteLong

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which gives a certain parameter a new value

(writes a parameter value).

The parameter type is Long.

You have to call CheckReceivedMsg() to check if you have

received an answer on your message. The answer-message

contains a statuscode which indicates if the value was

succesfully written, or an error occured. Call GetStatus()

to determine if the parameter was succesfully written.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

lNewValue: New value for the parameter

iMsgId: MessageId of the message.

You may choose any value for it with

restriction to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the

MessageId

can be used again.

Keep the MessageId, you will need it later

to check if you received an answer-

message

on your request

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : There can be no 2 messages at the same time with the same

(Node, Proces, Parameter) combination. Only if the message

has been removed, another message can be send to

this (Node, Process, Parameter) combination

*/

typedef short (__stdcall * _WriteLong)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytParm, long lNewValue,

short iMsgId);

_WriteLong WriteLong;

Page 82: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

82

/***************************************************************************

WriteString

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which gives a certain parameter a new value

(writes a parameter value).

The parameter type is String.

You have to call CheckReceivedMsg() to check if you have

received an answer on your message. The answer-message

contains a statuscode which indicates if the value was

succesfully written, or an error occured. Call GetStatus() to,

determine if the parameter was succesfully written.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

bytExpLen: Expected length of the string.

If you supply 0, a zero-terminated string is

expected.

sNewValue: New value for the parameter

iMsgId: MessageId of the message.

You may choose any value for it with restriction

to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the

MessageId

can be used again.

Keep the MessageId, you will need it later to

check if you received an answer-message

on

your request

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : There can be no 2 messages at the same time with the same

(Node, Proces, Parameter) combination. Only if the message

has been removed, another message can be send to

this (Node, Process, Parameter) combination

*/

typedef short (__stdcall * _WriteString)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytParm, char bytExpLen,

char * sNewValue,

short iMsgId);

_WriteString WriteString;

/*--------------END OF FUNCTIONS TO WRITE A PARAMETER---------------------*/

/*--------------FUNCTIONS TO READ A PARAMETER VALUE-----------------------*/

/***************************************************************************

GetChar

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which reads the value of a certain parameter.

The parameter type is Byte (1 character).

Before you can read a parameter value you have to:

- Call ReadChar() to send a read-request.

Page 83: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

83

- Call CheckReceivedMsg() to check if you have received an

answer on your read-request message.

- Call GetError() to check if no errors occured

- Check the status of the received message by calling

GetStatus(). After you have done all this and everything

was OK, you can read the value of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

bytParm: Parameter

(Out) bytValue: Value of the parameter

iMsgId: MessageId of the message.

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _GetChar)(short iAppId, char bytNode,

char bytProc, char bytParm,

char * bytValue, short * iMsgId);

_GetChar GetChar;

/***************************************************************************

GetInt

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which reads the value of a certain parameter.

The parameter type is integer.

Before you can read a parameter value you have to:

- Call Readint() to send a read-request.

- Call CheckReceivedMsg() to check if you have received an

answer on your read-request message.

- Call GetError() to check if no errors occured

- Check the status of the received message by calling

GetStatus(). After you have done all this and everything

was OK, you can read the value of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

bytParm: Parameter

(Out) iValue: Value of the parameter

iMsgId: MessageId of the message.

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _GetInt)(short iAppId, char bytNode,

char bytProc, char bytParm,

short * iValue, short * iMsgId);

_GetInt GetInt;

/***************************************************************************

GetFloat

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which reads the value of a certain parameter.

The parameter type is Float.

Before you can read a parameter value you have to:

Page 84: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

84

- Call ReadFloat() to send a read-request.

- Call CheckReceivedMsg() to check if you have received an

answer on your read-request message.

- Call GetError() to check if no errors occured

- Check the status of the received message by calling

GetStatus(). After you have done all this and everything

was OK, you can read the value of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

bytParm: Parameter

(Out) fValue: Value of the parameter

iMsgId: MessageId of the message.

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _GetFloat)(short iAppId, char bytNode,

char bytProc, char bytParm,

float * fValue, short * iMsgId);

_GetFloat GetFloat;

/***************************************************************************

GetLong

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which reads the value of a certain parameter.

The parameter type is Long.

Before you can read a parameter value you have to:

- Call ReadLong() to send a read-request.

- Call CheckReceivedMsg() to check if you have received an

answer on your read-request message.

- Call GetError() to check if no errors occured

- Check the status of the received message by calling

GetStatus(). After you have done all this and everything

was OK, you can read the value of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

bytParm: Parameter

(Out) lValue: Value of the parameter

iMsgId: MessageId of the message.

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _GetLong)(short iAppId, char bytNode,

char bytProc, char bytParm,

long * lValue, short * iMsgId);

_GetLong GetLong;

/***************************************************************************

GetString

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which reads the value of a certain parameter.

Page 85: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

85

The parameter type is String (1 or more characters).

Before you can read a parameter value you have to:

- Call ReadString() to send a read-request.

- Call CheckReceivedMsg() to check if you have received an

answer on your read-request message.

- Call GetError() to check if no errors occured

- Check the status of the received message by calling

GetStatus(). After you have done all this and everything

was OK, you can read the value of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

bytParm: Parameter

(Out) iMsgId: MessageId of the message.

sValue: Value of the parameter

bytActLen: Actual length of the value

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _GetString)(short iAppId, char bytNode,

char bytProc, char bytParm,

short * iMsgId, char * sValue,

char * bytActLen);

_GetString GetString;

/*--------------END OF FUNCTIONS TO READ A PARAMETER VALUE----------------*/

/*------------FUNCTIONS TO READ A PARAMETER VALUE (REALTIME)--------------*/

/***************************************************************************

GetRealTimeChar

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which reads the value of a certain parameter.

The parameter type is Byte (1 character).

Before you can read a parameter value you have to:

- Call ReadChar() to send a read-request.

- Call CheckReceivedMsg() to check if you have received an

answer on your read-request message.

- Call GetError() to check if no errors occured

- Check the status of the received message by calling

GetStatus(). After you have done all this and everything

was OK, you can read the value of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

bytParm: Parameter

(Out) bytValue: Value of the parameter

lRealTime: Timestamp which indicates at which moment the

value was read in the instrument. Time

is in

milliseconds..

iMsgId: MessageId of the message.

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _GetRealTimeChar)(short iAppId, char bytNode,

char bytProc, char bytParm,

char * bytValue,

Page 86: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

86

long * lRealTime,

short * iMsgId);

_GetRealTimeChar GetRealTimeChar;

/***************************************************************************

GetRealTimeInt

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which reads the value of a certain parameter.

The parameter type is integer.

Before you can read a parameter value you have to:

- Call Readint() to send a read-request.

- Call CheckReceivedMsg() to check if you have received an

answer on your read-request message.

- Call GetError() to check if no errors occured

- Check the status of the received message by calling

GetStatus(). After you have done all this and everything

was OK, you can read the value of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

bytParm: Parameter

(Out) iValue: Value of the parameter

lRealTime: Timestamp which indicates at which moment

the value was read in the instrument.

Time is in milliseconds..

iMsgId: MessageId of the message.

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _GetRealTimeInt)(short iAppId, char bytNode,

char bytProc, char bytParm,

short * iValue,

long * lRealTime,

short * iMsgId);

_GetRealTimeInt GetRealTimeInt;

/***************************************************************************

GetRealTimeFloat

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which reads the value of a certain parameter.

The parameter type is Float.

Before you can read a parameter value you have to:

- Call ReadFloat() to send a read-request.

- Call CheckReceivedMsg() to check if you have received an

answer on your read-request message.

- Call GetError() to check if no errors occured

- Check the status of the received message by calling

GetStatus(). After you have done all this and everything

was OK, you can read the value of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

Page 87: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

87

bytParm: Parameter

(Out) fValue: Value of the parameter

lRealTime: Timestamp which indicates at which moment the

value was read in the instrument. Time

is in

milliseconds..

iMsgId: MessageId of the message.

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _GetRealTimeFloat)(short iAppId, char bytNode,

char bytProc, char bytParm,

float * fValue,

long * lRealTime,

short * iMsgId);

_GetRealTimeFloat GetRealTimeFloat;

/***************************************************************************

GetRealTimeLong

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which reads the value of a certain parameter.

The parameter type is Long.

Before you can read a parameter value you have to:

- Call ReadLong() to send a read-request.

- Call CheckReceivedMsg() to check if you have received an

answer on your read-request message.

- Call GetError() to check if no errors occured

- Check the status of the received message by calling

GetStatus(). After you have done all this and everything

was OK, you can read the value of the parameter.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

bytParm: Parameter

(Out) lValue: Value of the parameter

lRealTime: Timestamp which indicates at which moment the

value was read

in the instrument. Time is in milliseconds..

iMsgId: MessageId of the message.

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _GetRealTimeLong)(short iAppId, char bytNode,

char bytProc, char bytParm,

long * lValue,

long * lRealTime,

short * iMsgId);

_GetRealTimeLong GetRealTimeLong;

/*----------END OF FUNCTIONS TO READ A PARAMETER VALUE (REALTIME)---------*/

Page 88: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

88

/*--------------FUNCTIONS TO CLAIM / UNCLAIM PROCESSES--------------------*/

/***************************************************************************

ClaimCommand

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which claims a certain process of a node.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process to claim

iMsgId: MessageId of the message.

You may choose any value for it with restriction

to the following:

- No 2 messages can have the same MessageId.

Only if a message is

removed the MessageId can be used again.

Keep the MessageId, you will need it later to

check if you received an answer-message

with the

status code in it (to determine if an

error occured)

(Out)

Returned : 0 on succes, non-zero on failure

Remarks : ClaimCommand() and UnClaimCommand() should not be called

until an answer-message is received and removed

(by calling RemoveMsg()). This is because of the

(Node, Process, Parameter) combination which must be unique.

*/

typedef short (__stdcall * _ClaimCommand)(short iAppId, short lHwnd,

char bytNode, char bytProc,

short iMsgId);

_ClaimCommand ClaimCommand;

/***************************************************************************

UnClaimCommand

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which unclaims a certain process of a node.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process to unclaim

iMsgId: MessageId of the message.

You may choose any value for it with restriction

to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the

MessageId

can be used again.

Keep the MessageId, you will need it later to

check if you received an answer-message

with the

status code in it (to determine if an

error occured)

(Out)

Page 89: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

89

Returned : 0 on succes, non-zero on failure

Remarks : ClaimCommand() and UnClaimCommand() should not be called

until an answer-message is received and removed

(by calling RemoveMsg()). This is because of the

(Node, Process, Parameter) combination which must

be unique.

*/

typedef short (__stdcall * _UnClaimCommand)(short iAppId, short lHwnd,

char bytNode, char bytProc,

short iMsgId);

_UnClaimCommand UnClaimCommand;

/***************************************************************************

GetClaimStatus

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which if a certain process of a certain node is

claimed or not.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process to check

(Out) bytStatus: Claim status of the node (0 = not claimed)

iMsgId: MessageId of the message.

Returned : 0 on succes, non-zero on failure

Remarks : ClaimCommand() and UnClaimCommand() should not be called

until an answer-message is received and removed (by calling

RemoveMsg()). This is because of the

(Node, Process, Parameter) combination which must be unique.

*/

typedef short (__stdcall * _GetClaimStatus)(short iAppId, char bytNode,

char bytProc, char * bytStatus,

short * iMsgId);

_GetClaimStatus GetClaimStatus;

/*---------END OF FUNCTIONS TO CLAIM / UNCLAIM PROCESSES------------------*/

/*--FUNCTIONS TO INSTRUCT A CERTAIN PROCESS TO BROADCAST IT'S PARAMETERS--*/

/***************************************************************************

StartBroadcast

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which instructs a certain process of a certain node

to broadcast it's parameters on the flowbus. Depending on

amount of channels connected to FLOWBUS bytRepTime

(Time between 2 broadcast messages) may have to be decreased

in order to keep amount of broadcastmessages limited.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytRepTime: interval (in 10 msec) between 2 broadcast

messages

iMsgId: MessageId of the message.

You may choose any value for it with restriction

Page 90: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

90

to the following:

- No 2 messages can have the same MessageId.

Only if a message is removed the

MessageId

can be used again.

Keep the MessageId, you will need it later to

check if you received an answer-message

with

the status code in it (to determine if

an

error occured)

(Out)

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _StartBroadcast)(short iAppId, long lHwnd,

char bytNode, char bytProc,

char bytRepTime, short iMsgId);

_StartBroadcast StartBroadcast;

/***************************************************************************

GetStartBroadcastStatus

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which checks the answer on the broadcast-request

message (send when StartBroadcast() was called).

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

(Out) bytStatus: Status of the broadcast-request

(0 = no error, everything OK)

iMsgId: MessageId of the message.

Returned : 0 on succes, non-zero on failure

Remarks :

*/

typedef short (__stdcall * _GetStartBroadcastStatus)(short iAppId,

char bytNode,

char bytProc,

char * bytStatus,

short * iMsgId);

_GetStartBroadcastStatus GetStartBroadcastStatus;

/*-END OF FUNCTIONS TO INSTRUCT A CERTAIN PROCESS TO BROADCAST PARAMETERS-*/

/***************************************************************************

GetStatus

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which determines the status of a received message.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

lHwnd: Supply always 0 for this parameter

bytNode: Node

bytProc: Process

bytParm: Parameter

(Out) bytStatus: Status of the received message (0 = no error,

Page 91: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

91

see "ERROR LIST SECTION"

at the top of this class for other possible

codes..)

iMsgId: MessageId of the message.

Returned : 0, on succes. See "ERROR LIST SECTION" at the top of this

class for other possible codes

Remarks :

*/

typedef short (__stdcall * _GetStatus)(short iAppId, char bytNode,

char bytProc, char bytParm,

char * bytStatus, short * iMsgId);

_GetStatus GetStatus;

/***************************************************************************

RemoveMsg

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which removes a message from the message buffer.

The message is identified by the unique combination of

(Node, Process, Parameter)

After calling this function the messageId you assigned to

the message with combination (Node, Process, Parameter) is

available again.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

bytNode: Node

bytProc: Process

bytParm: Parameter

(Out)

Returned :

Remarks :

*/

typedef void (__stdcall * _RemoveMsg)(short iAppId, char bytNode,

char bytProc, char bytParm);

_RemoveMsg RemoveMsg;

/***************************************************************************

CheckReceivedMsg

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which checks if a message has been received. If so

it fills the parameters you supplied with the parameters of

the received message. This function does not remove a message,

so if you call this function multiple times without calling

RemoveMsg() between 2 calls, you will always get the same

message!!!

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

(Out) bytNode: Node

bytProc: Process

bytParm: Parameter

bytMsgType: Byte which indicates if the answer is on a

read-request (1) or on a write-request

(0).

bytParmType: Parameter type (0 = Byte\Char, 1=Int, 2=Float,

3=Long, 4=String)

Page 92: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

92

iMsgId: MessageId of the message

Returned : 0 if no error occured, otherwise an error value

Remarks :

*/

typedef short (__stdcall * _CheckReceivedMsg)(short iAppId,

char * bytNode,

char * bytProc,

char * bytParm,

char * bytMsgType,

char * bytParmType,

short * iMsgId);

_CheckReceivedMsg CheckReceivedMsg;

/***************************************************************************

GetInterfaceType

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which indicates which port is currently used for

communication with flowbus.

Parameters:

(In)

(Out) sPort: Name of the port which is currently used for

flowbus-communication.

Returned :

Remarks :

*/

typedef void (__stdcall * _GetInterfaceType)(char * sPort);

_GetInterfaceType GetInterfaceType;

/***************************************************************************

GetCommunication

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which checks if the communication with flowbus is

open or closed.

Parameters:

(In)

(Out)

Returned : 1 if communication is open, 0 if communication is closed

Remarks :

*/

typedef short (__stdcall * _GetCommunication)();

_GetCommunication GetCommunication;

/***************************************************************************

CheckPCISA

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which checks if the PC(ISA)/FLOW-BUS interface is

present in then PC.

WARNING:

There have been some troubles using this function

(the function returned a 1, while we didn't have a PCISA card

installed), so do our advise is not to use this function.

Parameters:

Page 93: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

93

(In)

(Out)

Returned : 1 if a PCISA-card is present, 0 if no PCISA-card is present

Remarks :

*/

typedef short (__stdcall * _CheckPCISA)();

_CheckPCISA CheckPCISA;

/***************************************************************************

GetNrPorts

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which returns the number of available ports for

communication.

Parameters:

(In)

(Out)

Returned : Number of available ports for communication

Remarks :

*/

typedef char (__stdcall * _GetNrPorts)();

_GetNrPorts GetNrPorts;

/***************************************************************************

GetPort

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which gets information about a certain communication

port

Parameters:

(In) bytPortIndex: Index of the communication port in the array of

available communication ports. The first

available port has index 0.

iMemSize: Amount of memory reserved to store all information.

Formula to calculate this value:

2 + ExpectedLengthPortName * 2

(Out) bInUse: Boolean which indicates if the port is currently in

use

sPort: Name of the port

Returned : Number of available ports for communication

Remarks : 0, if iMemSize is sufficient to return data

> 0, (iMemSize to small), the returnvalue indicates how much

memory is needed

-1, index out of range

*/

typedef short (__stdcall * _GetPort)(char bytPortIndex, short iMemSize,

bool * bInUse, char * sPort);

_GetPort GetPort;

/***************************************************************************

GetAvailableInterfaces

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which returns info about the physical ports

(interfaces) in the pc. These ports can be COM-ports

and PC-ISA cards.

Page 94: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

94

You should make 2 calls to this function:

- The first time you supply iMemSize = 0

Furthermore declare variable udt_PortInfo_Ports as

follows:

PortInfoType * udt_PortInfo_Ports

- The second time you supply iMemSize =

return value first call

Furthermore recalcultate the size of variable

udt_PortInfo_Ports as follows:

udt_PortInfo_Ports =

New PortInfoType[bytNrOfElem from first call]

Parameters:

(In) iMemSize: Amount of memory allocated by your application

to store info

bytNrOfElem: Number of ports in the PC

udt_PortInfo_Ports: Array in which the information of

all ports can be stored.

(Out)

Returned : 0 if no error occured, otherwise an error value

Remarks :

*/

typedef short (__stdcall * _GetAvailableInterfaces) (short iMemSize,

char * bytNrOfElem,

PortInfoType * udt_PortInfo_Ports);

_GetAvailableInterfaces GetAvailableInterfaces;

/***************************************************************************

ReadSystemConfig

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which reads the flowbus configuration and builds

the channels database.

Parameters:

(In) iNode: Last node to scan (0 means stop scan in progress)

(Out)

Returned : 0, no error

1, communication not open

2, scan already in progress

3, busy with open/close or change communication action

Remarks :

*/

typedef short (__stdcall * _ReadSystemConfig) (short iNode);

_ReadSystemConfig ReadSystemConfig;

/***************************************************************************

FindFirstFreeNode

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which scans the flowbus network for the first node

address which is NOT in use (free).

Parameters:

(In) iStartNode: Node address of the node at which the search

should start (0 means cancel previous search)

(Out)

Returned : 0, if an error occured (communication was closed, busy with

other action, already searching node),

otherwise the node address of the first free node

Page 95: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

95

Remarks :

*/

typedef short (__stdcall * _FindFirstFreeNode) (short iStartNode);

_FindFirstFreeNode FindFirstFreeNode;

/***************************************************************************

GetProgress

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which determines the progress after a call to

ReadSystemConfig() or FindFirstFreeNode().

These function take a long time to complete.

Parameters:

(In)

(Out)

Returned : The progress of action as a percentage (0 - 100%)

Remarks :

*/

typedef char (__stdcall * _GetProgress) ();

_GetProgress GetProgress;

/***************************************************************************

GetDLLVersion

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which gets the version number of FLOWB32.DLL

Parameters:

(In)

(Out)

Returned : The highest address of all nodes connected to the FLOW-BUS

Remarks : ATTENTION

Flowb32.dll is made in C++.

The datatypes for character strings in C++ and Visual Basic

are not the same. If you don't know how to get character

strings, see function modFlowbusAdvanced.GetAnswer().

Search for the "case 4" statement. Here you will find

an example of how to retrieve character strings.

*/

typedef void (__stdcall * _GetDLLVersion) (char * sDllVersion);

_GetDLLVersion GetDLLVersion;

/***************************************************************************

GetChannel

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which returns the (virtual) channel number for a

certain (node, process)-combination.

Parameters:

(In) iNode: Node number

iProc: Process number

(Out)

Returned : The channel number of the (node, process)-combination

Remarks :

*/

typedef short (__stdcall * _GetChannel) (short iNode, short iProc);

Page 96: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

96

_GetChannel GetChannel;

/***************************************************************************

GetModuleType

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which returns the type of a node / module.

It tells you what kind of instrument the node / module is.

Parameters:

(In) iNode: Node number

(Out)

Returned : The type of the module

The list below provides some information about the returned

numbers. This is an old list, so the newer instruments are

NOT listed.

0 = None - No device found with this node number

1 = RS232 - RS232 interface to FLOW-BUS

2 = PC/ISA - PC(ISA) interface to FLOW-BUS

3 = ADDA4 - 4 Channel 0..5Vdc/0..10Vdc/0..20mA/4..20mA

interface to FLOW-BUS

4 = R/C - Readout and control module for up to 32

channels

5 = T/A - Totalizer and alarm module with 8 alarms and

8 counters

6 = ADDA1 - 1 Channel 0..5Vdc/0..10Vdc/0..20mA/4..20mA

interface to FLOW-BUS

7 = DMFC - Digital Mass Flow Controller

8 = DMFM - Digital Mass Flow Meter

9 = DEPC - Digital Electronic Pressure Controller

10 = DEPM - Digital Electronic Pressure Meter

11 = ACT - single actuator

12 = DLFC - Digital Liquid Flow Controller

13 = DLFM - Digital Liquid FLow Meter

14 = DSCM-A - Digital Single Channel Module for analog

instruments

15 = DSCM-D - Digital Single Channel Module for digital

instruments

16 = FRM - FLOW-BUS Rotor Meter (calibration instrument)

17 = FTM - FLOW-BUS Turbine Meter (calibration instrument)

18 = FPP - FLOW-BUS Piston Prover (calibration instrument)

19 = F/A - Flow/Alarm module (special T/A-module)

20 = DSCM-F - Single channel fuzzy controller module

21 = DSCM-C - Single channel operation module for calibrators

22 = DDCM-D - Dual channel module for analog instruments

Remarks :

*/

typedef short (__stdcall * _GetModuleType) (short iNode);

_GetModuleType GetModuleType;

/***************************************************************************

GetModuleDevType

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which gets the device type associated with a

certain node / module. The device type tells you something

about the functionality / capabillities of the module.

You could see it as the group of instruments to which

Page 97: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

97

the node / module belongs.

Parameters:

(In) iNode: Node number

(Out)

Returned : The device type of the module.

Possible types:

0 = Unknown

1 = TYPE_INTERFACE

2 = TYPE_MODULE / TYPE_ADDA

3 = TYPE_OPERATOR

4 = TYPE_SUPERVISE

5 = TYPE_CONTROLLER

6 = TYPE_METER

7 = TYPE_SPECIAL

8 = TYPE_CONVERTER

Remarks :

*/

typedef short (__stdcall * _GetModuleDevType) (short iNode);

_GetModuleDevType GetModuleDevType;

/***************************************************************************

GetModuleNumber

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which gets the identification string of a

module / node connected to the FLOW-BUS.

This identification tells some information about

version and module type

Parameters:

(In) iNode: Node number

(Out) sIdent: Identification string of the module

Returned :

Remarks : ATTENTION

Flowb32.dll is made in C++.

The datatypes for character strings in C++ and Visual Basic

are not the same. If you don't know how to get character

strings, see function modFlowbusAdvanced.GetAnswer().

Search for the "case 4" statement. Here you will find

an example of how to retrieve character strings.

*/

typedef void (__stdcall * _GetModuleNumber) (short iNode, char * sIdent);

_GetModuleNumber GetModuleNumber;

/***************************************************************************

GetMaxChannel

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which gets the node and process number of a

(virtual) channel.

Parameters:

(In) iChannel: Channel number. You must supply an existing

channel number.

(Out) iNode: Node number

iProc: Process number

Returned : True if node and process number could be found,

otherwise false

Page 98: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

98

Remarks :

*/

typedef bool (__stdcall * _GetNodeProc) (short iChannel, short * iNode,

short * iProc);

_GetNodeProc GetNodeProc;

/***************************************************************************

GetMaxChannel

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which returns the maximum (virtual) channel number

in the flowbus network.

Parameters:

(In)

(Out)

Returned : The maximum (virtual) channel number in the flowbus network

Remarks :

*/

typedef short (__stdcall * _GetMaxChannel) ();

_GetMaxChannel GetMaxChannel;

/***************************************************************************

GetMaxNode

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which returns the highest address of all nodes

connected to the FLOW-BUS

Parameters:

(In)

(Out)

Returned : The highest address of all nodes connected to the FLOW-BUS

Remarks :

*/

typedef short (__stdcall * _GetMaxNode) ();

_GetMaxNode GetMaxNode;

/***************************************************************************

SetSystemLNA

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which alters the last node address of FLOW-BUS

system. The LNA is a parameter used for communciation speed

efficiency. Flowbus is a token ring network.

After a node has finished his tasks, it passes the token

to the next node on the network. To determine when the token

should be passed to the first node again, LNA is used.

If you are not familiar with parameter LNA, leave it as it is!

A wrong value for this parameter could result in your

network not finding certain nodes anymore.

Parameters:

(In) iLNA: New value for parameter LNA (Last Node Address)

(Out)

Returned :

Remarks :

*/

typedef void (__stdcall * _SetSystemLNA) (short iLNA);

_SetSystemLNA SetSystemLNA;

Page 99: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.h

99

/***************************************************************************

GetSystemLNA

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which returns the last node address of FLOW-BUS

system. The LNA is a parameter used for communciation speed

efficiency. Flowbus is a token ring network.

After a node has finished his tasks, it passes the token

to the next node on the network. To determine when the token

should be passed to the first node again, LNA is used.

Parameters:

(In)

(Out)

Returned : The value of parameter LNA (Last Node Address)

Remarks :

*/

typedef short (__stdcall * _GetSystemLNA) ();

_GetSystemLNA GetSystemLNA;

/***************************************************************************

GetNrPendingMessages

Author : Bronkhorst High-Tech B.V.

Date : 15-Jan-2004

Function : Function which returns the amount of outstanding messages.

Each read or write action consists of 2 parts:

- Sending a request for a parameter / Writing a parameter.

This message is called a request-message.

- Waiting for an answer (waiting for a message containing a

statuscode, which tells you wheter or not the operation has

succeeded). In case of a read request, this message also

contains the value of your parameter.

This message is called an answer-message.

The term "outstanding messages" can now be defined as follows:

The number of request-messages of which the corresponding

answer-message is not yet removed from the dll's message

buffer.

This means that request-messages which are not already sent

are included (no answer-message are received on these

messages, so the answer-message on these request-messages

could not have been removed from the dll's message buffer)

This also includes request-messages on which an

answer-message was received which was not yet removed from

the dll's message buffer.

Parameters:

(In) iAppId: ApplicationId (which you received by calling

OpenDLL())

(Out)

Returned : The number of outstanding messages

Remarks :

*/

typedef short (__stdcall * _GetNrPendingMessages) (short iAppId);

_GetNrPendingMessages GetNrPendingMessages;

};

#endif

Page 100: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.cpp

100

7.1.3. FlowbusAPI.cpp

#include "FlowbusAPI.h"

/*Constructor*/

clsFlowbusAPI::clsFlowbusAPI()

{

/*

Load the flowbus dll into memory

If you supply only the filename (like I did), the dll is

expected to be in your windows system (or system32) directory.

You can also supply the full path, if the dll is located

anywhere else..

*/

hLibModule = LoadLibrary("Flowb32.dll");

/*

Check if a valid handle was returned from LoadLibrary()

*/

if(FlowbusDllLoaded())

{

/*

If so, initialize the function pointers (get the addresses

of the Api functions of the dll

*/

InitializeFunctionPointers(hLibModule);

}

}

/*Destructor*/

clsFlowbusAPI::~clsFlowbusAPI()

{

/*

Check if the dll is currently loaded into memory

*/

if(FlowbusDllLoaded())

{

/*

If so, remove the dll from memory

*/

FreeLibrary(hLibModule);

}

}

/***************************************************************************

FlowbusDllLoaded

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which checks if the dll is currently loaded into

memory

Parameters:

(In)

(Out)

Returned : true if the dll is currently loaded into memory,

otherwise false.

Remarks :

*/

Page 101: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.cpp

101

bool clsFlowbusAPI::FlowbusDllLoaded()

{

return hLibModule != 0;

}

/***************************************************************************

InitializeFunctionPointers

Author : Bronkhorst High-Tech B.V.

Date : 16-Dec-2003

Function : Function which initializes the function pointers. It

retrieves the addresses of the API functions found in the

flowbus dll. If you have the adress of the function in

memory, you can call the function.

The procedure is quite easy:

- Create a typedef for the function pointer (where

the syntax of the function is stored).

I will call the name of the typedef T.

- Create a variable of type T.

I will call this variable V.

- Get the address of the function by calling

the windows API function GetProcAddress().

You must supply the dll's handle (retrieved from

the call to LoadLibrary()) and the name of the

dll function from which you want to know the address

- Cast the address retrieved from GetProcAddress to

type T.

- Assign the casted value to variable V.

Parameters:

(In) hLibModule: Handle to the dll (retrieved from a call to

LoadLibrary())

(Out)

Returned :

Remarks :

*/

void clsFlowbusAPI::InitializeFunctionPointers(HMODULE hLibModule)

{

OpenDLL = (_OpenDLL)

GetProcAddress(hLibModule, "OpenDLL");

CloseDLL = (_CloseDLL)

GetProcAddress(hLibModule, "CloseDLL");

OpenCommunication = (_OpenCommunication)

GetProcAddress(hLibModule, "OpenCommunication");

CloseCommunication = (_CloseCommunication)

GetProcAddress(hLibModule, "CloseCommunication");

ConfigureRS232 = (_ConfigureRS232)

GetProcAddress(hLibModule, "ConfigureRS232");

GetRS232Config = (_GetRS232Config)

GetProcAddress(hLibModule, "GetRS232Config");

ConfigureTNet = (_ConfigureTNet)

GetProcAddress(hLibModule, "ConfigureTNet");

GetTNetConfig = (_GetTNetConfig)

GetProcAddress(hLibModule, "GetTNetConfig");

ConfigureChaining = (_ConfigureChaining)

GetProcAddress(hLibModule, "ConfigureChaining");

GetError = (_GetError)

GetProcAddress(hLibModule, "GetError");

ReadChar = (_ReadChar)

GetProcAddress(hLibModule, "ReadChar");

Page 102: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.cpp

102

ReadInt = (_ReadInt)

GetProcAddress(hLibModule, "ReadInt");

ReadFloat = (_ReadFloat)

GetProcAddress(hLibModule, "ReadFloat");

ReadLong = (_ReadLong)

GetProcAddress(hLibModule, "ReadLong");

ReadString = (_ReadString)

GetProcAddress(hLibModule, "ReadString");

WriteChar = (_WriteChar)

GetProcAddress(hLibModule, "WriteChar");

WriteInt = (_WriteInt)

GetProcAddress(hLibModule, "WriteInt");

WriteFloat = (_WriteFloat)

GetProcAddress(hLibModule, "WriteFloat");

WriteLong = (_WriteLong)

GetProcAddress(hLibModule, "WriteLong");

WriteString = (_WriteString)

GetProcAddress(hLibModule, "WriteString");

GetChar = (_GetChar)

GetProcAddress(hLibModule, "GetChar");

GetInt = (_GetInt)

GetProcAddress(hLibModule, "GetInt");

GetFloat = (_GetFloat)

GetProcAddress(hLibModule, "GetFloat");

GetLong = (_GetLong)

GetProcAddress(hLibModule, "GetLong");

GetString = (_GetString)

GetProcAddress(hLibModule, "GetString");

GetRealTimeChar = (_GetRealTimeChar)

GetProcAddress(hLibModule, "GetRealTimeChar");

GetRealTimeInt = (_GetRealTimeInt)

GetProcAddress(hLibModule, "GetRealTimeInt");

GetRealTimeFloat = (_GetRealTimeFloat)

GetProcAddress(hLibModule, "GetRealTimeFloat");

GetRealTimeLong = (_GetRealTimeLong)

GetProcAddress(hLibModule, "GetRealTimeLong");

ClaimCommand =

(_ClaimCommand) GetProcAddress(hLibModule, "ClaimCommand");

UnClaimCommand = (_UnClaimCommand)

GetProcAddress(hLibModule, "UnClaimCommand");

GetClaimStatus = (_GetClaimStatus)

GetProcAddress(hLibModule, "GetClaimStatus");

StartBroadcast = (_StartBroadcast)

GetProcAddress(hLibModule, "StartBroadcast");

GetStartBroadcastStatus = (_GetStartBroadcastStatus)

GetProcAddress(hLibModule, "GetStartBroadcastStatus");

GetStatus = (_GetStatus)

GetProcAddress(hLibModule, "GetStatus");

RemoveMsg = (_RemoveMsg)

GetProcAddress(hLibModule, "RemoveMsg");

CheckReceivedMsg = (_CheckReceivedMsg)

GetProcAddress(hLibModule, "CheckReceivedMsg");

GetInterfaceType = (_GetInterfaceType)

GetProcAddress(hLibModule, "GetInterfaceType");

GetCommunication = (_GetCommunication)

GetProcAddress(hLibModule, "GetCommunication");

CheckPCISA = (_CheckPCISA)

GetProcAddress(hLibModule, "CheckPCISA");

GetNrPorts = (_GetNrPorts)

GetProcAddress(hLibModule, "GetNrPorts");

GetPort = (_GetPort)

Page 103: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

FlowBusApi FlowBusApi.cpp

103

GetProcAddress(hLibModule, "GetPort");

GetAvailableInterfaces = (_GetAvailableInterfaces)

GetProcAddress(hLibModule, "GetAvailableInterfaces");

ReadSystemConfig = (_ReadSystemConfig)

GetProcAddress(hLibModule, "ReadSystemConfig");

FindFirstFreeNode = (_FindFirstFreeNode)

GetProcAddress(hLibModule, "FindFirstFreeNode");

GetProgress = (_GetProgress)

GetProcAddress(hLibModule, "GetProgress");

GetDLLVersion = (_GetDLLVersion)

GetProcAddress(hLibModule, "GetDLLVersion");

GetChannel = (_GetChannel)

GetProcAddress(hLibModule, "GetChannel");

GetModuleType = (_GetModuleType)

GetProcAddress(hLibModule, "GetModuleType");

GetModuleDevType = (_GetModuleDevType)

GetProcAddress(hLibModule, "GetModuleDevType");

GetModuleNumber = (_GetModuleNumber)

GetProcAddress(hLibModule, "GetModuleNumber");

GetNodeProc = (_GetNodeProc)

GetProcAddress(hLibModule, "GetNodeProc");

GetMaxChannel = (_GetMaxChannel)

GetProcAddress(hLibModule, "GetMaxChannel");

GetMaxNode = (_GetMaxNode)

GetProcAddress(hLibModule, "GetMaxNode");

SetSystemLNA = (_SetSystemLNA)

GetProcAddress(hLibModule, "SetSystemLNA");

GetSystemLNA = (_GetSystemLNA)

GetProcAddress(hLibModule, "GetSystemLNA");

GetNrPendingMessages = (_GetNrPendingMessages)

GetProcAddress(hLibModule, "GetNrPendingMessages");

}

Page 104: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Global Variables GlobalVariables.h

104

7.1.4. GlobalVariables.h

#ifndef GLOBALVARIABLES_H

#define GLOBALVARIABLES_H

//---------------------------------------------------------------------------

#include "FlowbusAPI.h"

#include "Unit3.h"

#include "Unit2.h"

#include "Unit4.h"

/*

This class contains a list of all global variables used in the program.

In main.cpp a variable of this class is created.

If you want to use some global variables, include this header-file.

The reason all variables are grouped is:

- If you type g->, the C++ environment will popup a list with all

available global variables, so you don't have to remember

them any more!! You just pick a variable from the list.

..*/

class GlobalVariables

{

public:

GlobalVariables(); /*Constructor*/

~GlobalVariables(); /*Destructor*/

short iAppId; /*Application id*/

clsFlowbusAPI * oFlowbusAPI; /*All flowbus API calls*/

/*

Advanced flowbus functions which use API calls to

perform their duty

*/

bool bComOpened;

bool iThread1Off;

bool iThread2Off;

bool iThread3Off;

bool iThread4Off;

char ThrMeas1[10];

char ThrMeas2[10];

char ThrMeas3[10];

char ThrMeas4[10];

char ThrSetp1[10];

char ThrSetp2[10];

char ThrSetp3[10];

char ThrSetp4[10];

};

extern GlobalVariables * g; /*g is declared in Unit3.cpp*/

#endif

Page 105: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Global Variables GlobalVariables.cpp

105

7.1.5. GlobalVariables.cpp

#include "GlobalVariables.h"

//---------------------------------------------------------------------------

/*Constructor*/

GlobalVariables::GlobalVariables()

{

/*Initialize the global variables*/

oFlowbusAPI = new clsFlowbusAPI();

iAppId = oFlowbusAPI->OpenDLL(0);

bComOpened = false;

iThread1Off = true;

iThread2Off = true;

iThread3Off = true;

iThread4Off = true;

}

/*Destructor*/

GlobalVariables::~GlobalVariables()

{

/*Release the resources allocated for the global variables*/

delete oFlowbusAPI;

}

Page 106: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form1) Unit1.h

106

7.1.6. Unit1.h

//$$---- Form HDR ----

//---------------------------------------------------------------------------

#ifndef Unit1H

#define Unit1H

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

#include <ComCtrls.hpp>

#include <ExtCtrls.hpp>

//---------------------------------------------------------------------------

class TForm1 : public TForm

{

__published: // IDE-managed Components

TGroupBox *GroupBox1;

TComboBox *ComboBox1;

TGroupBox *GroupBox3;

TGroupBox *GroupBox4;

TLabel *Label3;

TLabel *Label5;

TGroupBox *GroupBox5;

TGroupBox *GroupBox6;

TGroupBox *GroupBox7;

TLabel *Label4;

TLabel *Label7;

TLabel *Label8;

TEdit *Edit3;

TLabel *Label9;

TLabel *Label10;

TEdit *Edit4;

TLabel *Label11;

TLabel *Label12;

TEdit *Edit5;

TLabel *Label13;

TLabel *Label14;

TEdit *Edit6;

TLabel *Label15;

TLabel *Label16;

TEdit *Edit7;

TLabel *Label17;

TLabel *Label18;

TEdit *Edit8;

TGroupBox *GroupBox8;

TLabel *Label19;

TLabel *Label20;

TLabel *Label21;

TLabel *Label22;

TLabel *Label25;

TLabel *Label24;

TLabel *Label23;

TLabel *Label26;

TGroupBox *GroupBox9;

TLabel *Label27;

TLabel *Label28;

TLabel *Label29;

TLabel *Label30;

TGroupBox *GroupBox2;

TButton *Button2;

TLabel *Label1;

TLabel *Label31;

Page 107: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form1) Unit1.h

107

TLabel *Label32;

TLabel *Label33;

TLabel *Label34;

TStatusBar *StatusBar1;

TTimer *Timer1;

TCheckBox *CheckBox1;

TEdit *Edit9;

TCheckBox *CheckBox2;

TButton *Button1;

TCheckBox *CheckBox3;

TLabel *Label2;

TLabel *Label6;

TComboBox *ComboBox2;

TEdit *Edit1;

TLabel *Label35;

TCheckBox *CheckBox4;

void __fastcall Timer1Timer(TObject *Sender);

void __fastcall Button2Click(TObject *Sender);

void __fastcall CheckBox2Click(TObject *Sender);

void __fastcall CheckBox3Click(TObject *Sender);

void __fastcall CheckBox1Click(TObject *Sender);

void __fastcall Button1Click(TObject *Sender);

void __fastcall CheckBox4Click(TObject *Sender);

private:

public:

float ConDes2, ConDes3, ConDes4;

float ConBot2, ConBot3, ConBot4;

float Flow1, Flow2, Flow3, Flow4, FlowMax4, FlowTotal;

float aSetp1, aSetp2, aSetp3, aSetp4;

char cFM1[80];

char cFM2[80];

char cFM3[80];

char cFM4[80];

char cSP1[8];

char cSP2[8];

char cSP3[8];

char cSP4[8];

short iNode;

short iErrVal;

char sErrVal[100];

char sAnswer[256];

char bytStatus;

short iSetpoint1,iSetpoint2,iSetpoint3,iSetpoint4;

char sSetpoint1[8],sSetpoint2[8],sSetpoint3[8],sSetpoint4[8];

__fastcall TForm1(TComponent* Owner);

void __fastcall TForm1::Initial(void);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm1 *Form1;

//---------------------------------------------------------------------------

#endif

Page 108: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form1) Unit1.cpp

108

7.1.7. Unit1.cpp

//$$---- Form CPP ----

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include <stdlib.h>

//---------------------------------------------------------------------------

#include "Unit1.h"

#include "GlobalVariables.h"

#include "TabPgDlg.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

Initial();

}

//---------------------------------------------------------------------------

protected __fastcall TForm1::Button1Click(TObject *Sender)

{

Initial();

}

//---------------------------------------------------------------------------

protected __fastcall TForm1::Button2Click(TObject *Sender)

{

if(CheckBox2->Checked == false)

{

ConDes2, ConDes3, ConDes4 = 0;

ConBot2, ConBot3, ConBot4 = 0;

Flow1, Flow2, Flow3, Flow4, FlowMax4, FlowTotal = 0;

aSetp1, aSetp2, aSetp3, aSetp4 = 0;

cFM1[80], cFM2[80], cFM3[80], cFM4[80]=0;

cSP1[8], cSP2[8], cSP3[8], cSP4[8]=0;

FlowTotal = Edit9->Text.ToDouble();

if(Edit3->Text != "" && Edit4->Text != "")

{

ConBot2 = Edit3->Text.ToDouble();

ConDes2 = Edit4->Text.ToDouble();

Flow2 = (float)((((ConDes2*FlowTotal)/1000000)*100)/

((ConBot2*100)/1000000));

aSetp2 = (float)(Flow2*100)/Label8->Caption.ToDouble();

sprintf(cFM2, "%.3f", Flow2);

sprintf(cSP2, "%.2f", aSetp2);

sprintf(g->ThrSetp2, "%.2f", aSetp2);

}

if(Edit5->Text != "" && Edit6->Text != "")

{

ConBot3 = Edit5->Text.ToDouble();

ConDes3 = Edit6->Text.ToDouble();

Flow3 = (float)((((ConDes3*FlowTotal)/1000000)*100)/

((ConBot3*100)/1000000));

aSetp3 = (float)(Flow3*100)/Label12->Caption.ToDouble();

sprintf(cFM3, "%.3f", Flow3);

sprintf(cSP3, "%.2f", aSetp3);

Page 109: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form1) Unit1.cpp

109

sprintf(g->ThrSetp3, "%.2f", aSetp3);

}

if(CheckBox3->Checked == true)

{

if(Edit1->Text != "" && Edit7->Text != "" && Edit8->Text != "")

{

FlowMax4 = Edit1->Text.ToDouble();

Label16->Caption = FlowMax4;

ConBot4 = Edit7->Text.ToDouble();

ConDes4 = Edit8->Text.ToDouble();

Flow4 = (float)((((ConDes4*FlowTotal)/1000000)*100)/

((ConBot4*100)/1000000));

aSetp4 = (float)(Flow4*100)/FlowMax4;

sprintf(cFM4, "%.3f", Flow4);

sprintf(cSP4, "%.2f", aSetp4);

sprintf(g->ThrSetp4, "%.2f", aSetp4);

}

}

if(CheckBox4->Checked == true)

{

Flow2 = (float)FlowTotal-(Flow3+Flow4);

aSetp2= (float)(Flow2*100)/Label8->Caption.ToDouble();

sprintf(cFM2, "%.3f", Flow2);

sprintf(cSP2, "%.2f", aSetp2);

sprintf(g->ThrSetp2, "%.2f", aSetp2);

}

else

{

Flow1 = (float)(FlowTotal-(Flow2+Flow3+Flow4));

aSetp1 = (float)(Flow1*100)/Label4->Caption.ToDouble();

sprintf(cFM1, "%.3f", Flow1);

sprintf(cSP1, "%.2f", aSetp1);

sprintf(g->ThrSetp1, "%.2f", aSetp1);

Label23->Caption = cFM1;

}

Label24->Caption = cFM2;

Label25->Caption = cFM3;

Label26->Caption = cFM4;

Label31->Caption = cSP1;

Label32->Caption = cSP2;

Label33->Caption = cSP3;

Label34->Caption = cSP4;

}

else

{

Form2->Series1->Active = false;

Form2->Series2->Active = false;

Form2->Series3->Active = false;

Form2->Series4->Active = false;

if(Label31->Caption != "" && 0 <= cSP1 <= 100)

{

iSetpoint1=((aSetp1*32000)/100);

itoa(iSetpoint1, sSetpoint1, 10);

Form3->WriteParameterDirect(3, 1, 1, 2, 0,

500, sSetpoint1, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

Form3->Memo1->Lines->Add("Setpoint correctly"

"written at MFC1..");

Form3->Memo1->Lines->Add("-------------------"

"----------------");

Page 110: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form1) Unit1.cpp

110

Sleep(100);

if(g->iThread1Off == true)

{

WriteMeasure1 *Thread = new WriteMeasure1 (false);

Thread->Resume();

g->iThread1Off = false;

}

}

else

{

Form3->Memo1->Lines->Add("Setpoint not correctly"

"written at MFC1..");

Form3->Memo1->Lines->Add("------------------"

"-----------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if(Label32->Caption != "" && 0 <= cSP2 <= 100)

{

iSetpoint2=((aSetp2*32000)/100);

itoa(iSetpoint2, sSetpoint2, 10);

Form3->WriteParameterDirect(4, 1, 1, 2, 0,

500, sSetpoint2, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

Form3->Memo1->Lines->Add("Setpoint correctly written"

"at MFC2..");

Form3->Memo1->Lines->Add("---------------"

"--------------------");

Sleep(100);

if(g->iThread2Off == true)

{

WriteMeasure2 *Thread = new WriteMeasure2 (false);

Thread->Resume();

g->iThread2Off = false;

}

}

else

{

Form3->Memo1->Lines->Add("Setpoint not correctly "

"written at MFC2..");

Form3->Memo1->Lines->Add("---------------"

"--------------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if(Label33->Caption != "" && 0 <= cSP3 <= 100)

{

iSetpoint3=((aSetp3*32000)/100);

itoa(iSetpoint3, sSetpoint3, 10);

Form3->WriteParameterDirect(5, 1, 1, 2, 0,

500, sSetpoint3, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

Form3->Memo1->Lines->Add("Setpoint correctly written"

"at MFC3..");

Page 111: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form1) Unit1.cpp

111

Form3->Memo1->Lines->Add("-------------"

"----------------------");

Sleep(100);

if(g->iThread3Off == true)

{

WriteMeasure3 *Thread = new WriteMeasure3 (false);

Thread->Resume();

g->iThread3Off = false;

}

}

else

{

Form3->Memo1->Lines->Add("Setpoint not correctly "

"written at MFC3..");

Form3->Memo1->Lines->Add("---------------"

"--------------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if(Label34->Caption != "" && 0 <= cSP4 <= 100)

{

iSetpoint4=((aSetp4*32000)/100);

itoa(iSetpoint4, sSetpoint4, 10);

Form3->WriteParameterDirect(6, 1, 1, 2, 0,

500, sSetpoint4, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

Form3->Memo1->Lines->Add("Setpoint correctly written"

"at MFC4..");

Form3->Memo1->Lines->Add("----------------"

"-------------------");

Sleep(100);

if(g->iThread4Off == true)

{

WriteMeasure4 *Thread = new WriteMeasure4 (false);

Thread->Resume();

g->iThread4Off = false;

}

}

else

{

Form3->Memo1->Lines->Add("Setpoint not correctly "

"written at MFC4..");

Form3->Memo1->Lines->Add("----------------"

"-------------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

}

}

Page 112: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form1) Unit1.cpp

112

//---------------------------------------------------------------------------

protected __fastcall TForm1::CheckBox1Click(TObject *Sender)

{

switch((unsigned short)ComboBox1->ItemIndex)

{

case 0:

switch((unsigned short)ComboBox2->ItemIndex)

{

case 0: Label4->Caption = "400"; break;

case 1: Label8->Caption = "100"; break;

case 2: Label12->Caption = "15"; break;

case 3:

if(CheckBox3->Checked == true)

{

Label16->Caption = Edit1->

Text.ToDouble();

}

Label16->Caption = " ---"; break;

default: NULL;

}

break;

case 1:

switch((unsigned short)ComboBox2->ItemIndex)

{

case 0: Label4->Caption = "295,6"; break;

case 1: Label8->Caption = "73,85"; break;

case 2: Label12->Caption = "11,085"; break;

case 3:

if(CheckBox3->Checked == true)

{

Label16->Caption = Edit1->Text.ToDouble();

}

Label16->Caption = " ---"; break;

default: NULL;

}

break;

default: NULL;

}

Sleep(100);

CheckBox1->Checked = false;

}

//---------------------------------------------------------------------------

protected __fastcall TForm1::CheckBox2Click(TObject *Sender)

{

if(CheckBox2->Checked == true)

{

Button2->Caption = "Load";

CheckBox2->Font->Color = clBlue;

StatusBar1->Panels->Items[0]->Text = "Writing Set point mode";

}

else

{

Button2->Caption = "Calculate";

CheckBox2->Font->Color = clBlack;

StatusBar1->Panels->Items[0]->Text = "Runnig calculator mode";

}

}

Page 113: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form1) Unit1.cpp

113

//---------------------------------------------------------------------------

protected __fastcall TForm1::CheckBox3Click(TObject *Sender)

{

if(CheckBox3->Checked == true)

{

Edit1->Enabled = true;

Edit7->Enabled = true;

Edit8->Enabled = true;

}

else

{

Edit1->Enabled = false;

Edit7->Enabled = false;

Edit8->Enabled = false;

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm1::Initial(protected)

{

Edit1->Clear();

Edit3->Clear();

Edit4->Clear();

Edit5->Clear();

Edit6->Clear();

Edit7->Clear();

Edit8->Clear();

Edit9->Clear();

Label4->Caption = " ---";

Label8->Caption = " ---";

Label12->Caption = " ---";

Label16->Caption = " ---";

Label23->Caption = " ---";

Label24->Caption = " ---";

Label25->Caption = " ---";

Label26->Caption = " ---";

Label31->Caption = " ---";

Label32->Caption = " ---";

Label33->Caption = " ---";

Label34->Caption = " ---";

Edit1->Enabled = false;

Edit7->Enabled = false;

Edit8->Enabled = false;

StatusBar1->Panels->Items[0]->Text = " Flow & Set point calculator";

ConDes2=0; ConDes3=0; ConDes4=0;

ConBot2=0; ConBot3=0; ConBot4=0;

Flow1=0; Flow2=0; Flow3=0; Flow4=0; FlowMax4=0; FlowTotal=0;

aSetp1=0; aSetp2=0; aSetp3=0; aSetp4=0;

cFM1[80]=0;

cFM2[80]=0;

cFM3[80]=0;

cFM4[80]=0;

cSP1[8]=0;

cSP2[8]=0;

cSP3[8]=0;

cSP4[8]=0;

}

//---------------------------------------------------------------------------

protected __fastcall TForm1::Timer1Timer(TObject *Sender)

{

StatusBar1->Panels->Items[1]->Text = Now().TimeString();

}

Page 114: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form1) Unit1.cpp

114

//--------------------------------------------------------------------------

protected __fastcall TForm1::CheckBox4Click(TObject *Sender)

{

if(CheckBox4->Checked == true)

{

Edit3->Enabled = false;

Edit4->Enabled = false;

CheckBox4->Font->Color = clBlue;

}

else

{

Edit3->Enabled = true;

Edit4->Enabled = true;

CheckBox4->Font->Color = clBlack;

}

}

Page 115: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.h

115

7.1.8. Unit2.h

//$$---- Form HDR ----

//---------------------------------------------------------------------------

#ifndef Unit2H

#define Unit2H

//---------------------------------------------------------------------------

#include "GlobalVariables.h"

#include "FlowbusAPI.h"

//---------------------------------------------------------------------------

#include <Chart.hpp>

#include <Classes.hpp>

#include <Controls.hpp>

#include <DbChart.hpp>

#include <Dialogs.hpp>

#include <ExtCtrls.hpp>

#include <Series.hpp>

#include <StdCtrls.hpp>

//---------------------------------------------------------------------------

#include <stdio.h>

#include <time.h>

#include <TeEngine.hpp>

#include <TeeProcs.hpp>

//---------------------------------------------------------------------------

class WriteMeasure1 : public TThread

{

private:

SYSTEMTIME systime_Now;

SYSTEMTIME systime_Start;

protected:

protected __fastcall Execute(protected);

protected __fastcall UpdateLabel1(protected);

public:

bool Cond1;

int CountError;

short iNode;

short iErrVal;

char sErrVal[100];

char sAnswer[256];

char bytStatus;

float x1;

float y1;

float iAnswer;

char sm1[80];

long lStart, lNow;

long lDif;

bool FirstLoop;

__fastcall WriteMeasure1(bool CreateSuspended);

};

//---------------------------------------------------------------------------

Page 116: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.h

116

class WriteMeasure2 : public TThread

{

private:

SYSTEMTIME systime_Now;

SYSTEMTIME systime_Start;

protected:

protected __fastcall Execute(protected);

protected __fastcall UpdateLabel2(protected);

public:

bool Cond2;

int CountError;

short iNode;

short iErrVal;

char sErrVal[100];

char sAnswer[256];

char bytStatus;

float x2;

float y2;

float iAnswer;

char sm2[80];

long lStart, lNow;

long lDif;

bool FirstLoop;

__fastcall WriteMeasure2(bool CreateSuspended);

};

//---------------------------------------------------------------------------

class WriteMeasure3 : public TThread

{

private:

SYSTEMTIME systime_Now;

SYSTEMTIME systime_Start;

protected:

protected __fastcall Execute(protected);

protected __fastcall UpdateLabel3(protected);

public:

bool Cond3;

int CountError;

short iNode;

short iErrVal;

char sErrVal[100];

char sAnswer[256];

char bytStatus;

float x3;

float y3;

float iAnswer;

char sm3[80];

long lStart, lNow;

long lDif;

bool FirstLoop;

Page 117: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.h

117

__fastcall WriteMeasure3(bool CreateSuspended);

};

//---------------------------------------------------------------------------

class WriteMeasure4 : public TThread

{

private:

SYSTEMTIME systime_Now;

SYSTEMTIME systime_Start;

protected:

protected __fastcall Execute(protected);

protected __fastcall UpdateLabel4(protected);

public:

bool Cond4;

int CountError;

short iNode;

short iErrVal;

char sErrVal[100];

char sAnswer[256];

char bytStatus;

float x4;

float y4;

float iAnswer;

char sm4[80];

long lStart, lNow;

long lDif;

bool FirstLoop;

__fastcall WriteMeasure4(bool CreateSuspended);

};

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------

class TForm2 : public TForm

{

__published: // IDE-managed Components

TGroupBox *GroupBox1;

TDBChart *DBChart1;

TGroupBox *GroupBox2;

TFastLineSeries *Series1;

TFastLineSeries *Series2;

TFastLineSeries *Series3;

TGroupBox *GroupBox3;

TLabel *Label1;

TLabel *Label3;

TLabel *Label4;

TLabel *Label5;

TLabel *Label2;

TFastLineSeries *Series4;

TLabel *Label6;

TGroupBox *GroupBox4;

TLabel *Label7;

TLabel *Label9;

TLabel *Label10;

TLabel *Label11;

TLabel *Label8;

Page 118: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.h

118

TLabel *Label12;

TGroupBox *GroupBox5;

TLabel *Label13;

TLabel *Label15;

TLabel *Label16;

TLabel *Label17;

TLabel *Label14;

TLabel *Label18;

TGroupBox *GroupBox6;

TLabel *Label19;

TLabel *Label21;

TLabel *Label22;

TLabel *Label23;

TLabel *Label20;

TLabel *Label24;

//---------------------------------------------------------------------------

private: // User declarations

SYSTEMTIME systime_Start;

SYSTEMTIME systime_Now;

//---------------------------------------------------------------------------

public: // User declarations

__fastcall TForm2(TComponent* Owner);

protected __fastcall TForm2::Initial(protected);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm2 *Form2;

//---------------------------------------------------------------------------

#endif

Page 119: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.cpp

119

7.1.9. Unit2.cpp

//$$---- Form CPP ----

//---------------------------------------------------------------------------

#include <time.h>

#include <vcl.h>

#pragma hdrstop

//---------------------------------------------------------------------------

#include "Unit2.h"

#include "Unit3.h"

#include "Unit4.h"

#include "GlobalVariables.h"

#include "TabPgDlg.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

//---------------------------------------------------------------------------

TForm2 *Form2;

//---------------------------------------------------------------------------

__fastcall TForm2::TForm2(TComponent* Owner)

: TForm(Owner)

{

Initial();

}

//***************************************************************************

//---------------------------------------------------------------------------

__fastcall WriteMeasure1::WriteMeasure1(bool CreateSuspended)

: TThread(CreateSuspended)

{

Cond1 = true;

CountError = 0;

Form2->Visible = true;

FirstLoop = true;

if(Form2->Series1->Active == false)

{

Form2->Series1->Active = true;

Form2->Series1->Clear();

Form2->Series1->AddXY(0, 0, "", clGreen);

}

if(Form2->Label4->Caption != " ---")

iNode = Form2->Label4->Caption.ToInt();

else

{

iNode = 3;

Form2->Label4->Caption = iNode;

}

}

//---------------------------------------------------------------------------

protected __fastcall WriteMeasure1::Execute(protected)

{

do

{

if(FirstLoop == true)

{

Synchronize(&UpdateLabel1);

Sleep(600);

}

else

{

Sleep(10);

Page 120: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.cpp

120

GetSystemTime(&systime_Now);

lNow = systime_Now.wMilliseconds + 1000 * (systime_Now.wSecond +

60 * (systime_Now.wMinute + 60 * (long) systime_Now.wHour));

if(lStart > lNow)

{

lNow = lNow + 1000 * 60 * 60 * 24;

}

lDif = difftime(lNow, lStart);

if(lDif >= 1000)

{

Synchronize(&UpdateLabel1);

Sleep(600);

}

}

}

while(Cond1 == true);

}

//---------------------------------------------------------------------------

protected __fastcall WriteMeasure1::UpdateLabel1(protected)

{

GetSystemTime(&systime_Start);

lStart = systime_Start.wMilliseconds + 1000 * (systime_Start.wSecond +

60 * (systime_Start.wMinute + 60 * (long) systime_Start.wHour));

FirstLoop = false;

Form3->ReadParameterDirect(iNode, 1, 0, 2, 0,

800, sAnswer, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

iAnswer = atoi(sAnswer);

y1 = (float)((iAnswer *100)/32000);

sprintf(sm1, "%.2f", y1);

sprintf(g->ThrMeas1, "%s", sm1);

x1 += 0.01666666666666666666667;

Form2->Label6->Caption = sm1;

PagesDlg->Label4->Caption = sm1;

Form2->Series1->AddXY(x1,y1,"",clGreen);

}

else

{

CountError++;

if(CountError == 10)

{

Cond1 = false;

Form2->Label6->Caption = "Error";

strcpy(g->ThrMeas1, " ---");

Form3->Memo1->Lines->Add("Measure could not be read..");

Form3->Memo1->Lines->Add("10 read errors have ocurred..");

Form3->Memo1->Lines->Add("-----------------------------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if(Form2->Label5->Caption == " ---")

{

Form3->ReadParameterDirect(iNode, 1, 1, 2, 1,

800, sAnswer, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

iAnswer = atoi(sAnswer);

y1 = (float)((iAnswer*100)/32000);

sprintf(PagesDlg->sp1, "%.2f", y1);

sprintf(g->ThrSetp1, "%s", PagesDlg->sp1);

Page 121: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.cpp

121

Form2->Label5->Caption = PagesDlg->sp1;

PagesDlg->Label5->Caption = PagesDlg->sp1;

}

else

{

Form2->Label5->Caption = " ---";

Form3->Memo1->Lines->Add("Setpoint could not be read..");

Form3->Memo1->Lines->Add("-----------------------------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if((Form2->Series1->Active == false)||(g->bComOpened == false))

{

Cond1 = false;

Form2->Label4->Caption = " ---";

Form2->Label5->Caption = " ---";

Form2->Label6->Caption = " ---";

PagesDlg->Label4->Caption = " ---";

PagesDlg->Label5->Caption = " ---";

}

}

//---------------------------------------------------------------------------

__fastcall WriteMeasure2::WriteMeasure2(bool CreateSuspended)

: TThread(CreateSuspended)

{

Cond2 = true;

CountError = 0;

Form2->Visible = true;

FirstLoop = true;

if(Form2->Series2->Active == false)

{

Form2->Series2->Active = true;

Form2->Series2->Clear();

Form2->Series2->AddXY(0, 0, "", clRed);

}

if(Form2->Label10->Caption != " ---")

iNode = Form2->Label10->Caption.ToInt();

else

{

iNode = 4;

Form2->Label10->Caption = iNode;

}

}

//---------------------------------------------------------------------------

protected __fastcall WriteMeasure2::Execute(protected)

{

do

{

if(FirstLoop == true)

{

Synchronize(&UpdateLabel2);

Sleep(600);

}

else

{

Sleep(10);

GetSystemTime(&systime_Now);

lNow = systime_Now.wMilliseconds + 1000 * (systime_Now.wSecond +

60 * (systime_Now.wMinute + 60 * (long) systime_Now.wHour));

if(lStart > lNow)

Page 122: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.cpp

122

{

lNow = lNow + 1000 * 60 * 60 * 24;

}

lDif = difftime(lNow, lStart);

if(lDif >= 1000)

{

Synchronize(&UpdateLabel2);

Sleep(600);

}

}

}

while(Cond2 == true);

}

//---------------------------------------------------------------------------

protected __fastcall WriteMeasure2::UpdateLabel2(protected)

{

GetSystemTime(&systime_Start);

lStart = systime_Start.wMilliseconds + 1000 * (systime_Start.wSecond +

60 * (systime_Start.wMinute + 60 * (long) systime_Start.wHour));

FirstLoop = false;

Form3->ReadParameterDirect(iNode, 1, 0, 2, 0,

800, sAnswer, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

iAnswer = atoi(sAnswer);

y2 = (float)((iAnswer*100)/32000);

sprintf(sm2, "%.2f", y2);

sprintf(g->ThrMeas2, "%s", sm2);

x2 += 0.01666666666666666666667;

Form2->Label12->Caption = sm2;

PagesDlg->Label8->Caption = sm2;

Form2->Series2->AddXY(x2,y2,"",clRed);

}

else

{

CountError++;

if(CountError == 10)

{

Cond2 = false;

Form2->Label12->Caption = "Error";

strcpy(g->ThrMeas2, " ---");

Form3->Memo1->Lines->Add("Measure could not be read..");

Form3->Memo1->Lines->Add("10 read errors have ocurred..");

Form3->Memo1->Lines->Add("-----------------------------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if(Form2->Label11->Caption == " ---")

{

Form3->ReadParameterDirect(iNode, 1, 1, 2, 1,

800, sAnswer, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

iAnswer = atoi(sAnswer);

y2 = (float)((iAnswer*100)/32000);

sprintf(PagesDlg->sp2, "%.2f", y2);

sprintf(g->ThrSetp2, "%s", PagesDlg->sp2);

Form2->Label11->Caption = PagesDlg->sp2;

PagesDlg->Label13->Caption = PagesDlg->sp2;

}

else

Page 123: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.cpp

123

{

Form2->Label11->Caption = " ---";

Form3->Memo1->Lines->Add("Setpoint could not be read..");

Form3->Memo1->Lines->Add("-----------------------------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if((Form2->Series2->Active == false)||(g->bComOpened == false))

{

Cond2 = false;

Form2->Label10->Caption = " ---";

Form2->Label11->Caption = " ---";

Form2->Label12->Caption = " ---";

PagesDlg->Label13->Caption = " ---";

PagesDlg->Label8->Caption = " ---";

}

}

//---------------------------------------------------------------------------

__fastcall WriteMeasure3::WriteMeasure3(bool CreateSuspended)

: TThread(CreateSuspended)

{

Cond3 = true;

CountError = 0;

Form2->Visible = true;

FirstLoop = true;

if(Form2->Series3->Active == false)

{

Form2->Series3->Active = true;

Form2->Series3->Clear();

Form2->Series3->AddXY(0, 0, "", clAqua);

}

if(Form2->Label16->Caption != " ---")

iNode = Form2->Label16->Caption.ToInt();

else

{

iNode = 5;

Form2->Label16->Caption = iNode;

}

}

//---------------------------------------------------------------------------

protected __fastcall WriteMeasure3::Execute(protected)

{

do

{

if(FirstLoop == true)

{

Synchronize(&UpdateLabel3);

Sleep(600);

}

else

{

Sleep(10);

GetSystemTime(&systime_Now);

lNow = systime_Now.wMilliseconds + 1000 * (systime_Now.wSecond +

60 * (systime_Now.wMinute + 60 * (long) systime_Now.wHour));

if(lStart > lNow)

{

lNow = lNow + 1000 * 60 * 60 * 24;

}

lDif = difftime(lNow, lStart);

Page 124: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.cpp

124

if(lDif >= 1000)

{

Synchronize(&UpdateLabel3);

Sleep(600);

}

}

}

while(Cond3 == true);

}

//---------------------------------------------------------------------------

protected __fastcall WriteMeasure3::UpdateLabel3(protected)

{

GetSystemTime(&systime_Start);

lStart = systime_Start.wMilliseconds + 1000 * (systime_Start.wSecond +

60 * (systime_Start.wMinute + 60 * (long) systime_Start.wHour));

FirstLoop = false;

Form3->ReadParameterDirect(iNode, 1, 0, 2, 0,

800, sAnswer, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

iAnswer = atoi(sAnswer);

y3 = (float)((iAnswer*100)/32000);

sprintf(sm3, "%.2f", y3);

sprintf(g->ThrMeas3, "%s", sm3);

x3 += 0.01666666666666666666667;

Form2->Label18->Caption = sm3;

PagesDlg->Label10->Caption = sm3;

Form2->Series3->AddXY(x3,y3,"",clAqua);

}

else

{

CountError++;

if(CountError == 10)

{

Cond3 = false;

Form2->Label18->Caption = "Error";

strcpy(g->ThrMeas3, " ---");

Form3->Memo1->Lines->Add("Measure could not be read..");

Form3->Memo1->Lines->Add("10 read errors have ocurred..");

Form3->Memo1->Lines->Add("-----------------------------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if(Form2->Label17->Caption == " ---")

{

Form3->ReadParameterDirect(iNode, 1, 1, 2, 1,

800, sAnswer, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

iAnswer = atoi(sAnswer);

y3 = (float)((iAnswer*100)/32000);

sprintf(PagesDlg->sp3, "%.2f", y3);

sprintf(g->ThrSetp3, "%s", PagesDlg->sp3);

Form2->Label17->Caption = PagesDlg->sp3;

PagesDlg->Label18->Caption = PagesDlg->sp3;

}

else

{

Form2->Label17->Caption = " ---";

Form3->Memo1->Lines->Add("Setpoint could not be read..");

Form3->Memo1->Lines->Add("-----------------------------------");

Page 125: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.cpp

125

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if((Form2->Series3->Active == false)||(g->bComOpened == false))

{

Cond3 = false;

Form2->Label16->Caption = " ---";

Form2->Label17->Caption = " ---";

Form2->Label18->Caption = " ---";

PagesDlg->Label18->Caption = " ---";

PagesDlg->Label10->Caption = " ---";

}

}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------

__fastcall WriteMeasure4::WriteMeasure4(bool CreateSuspended)

: TThread(CreateSuspended)

{

Cond4 = true;

CountError = 0;

Form2->Visible = true;

FirstLoop = true;

if(Form2->Series4->Active == false)

{

Form2->Series4->Active = true;

Form2->Series4->Clear();

Form2->Series4->AddXY(0, 0, "", clAqua);

}

if(Form2->Label22->Caption != " ---")

iNode = Form2->Label22->Caption.ToInt();

else

{

iNode = 6;

Form2->Label22->Caption = iNode;

}

}

//---------------------------------------------------------------------------

protected __fastcall WriteMeasure4::Execute(protected)

{

do

{

if(FirstLoop == true)

{

Synchronize(&UpdateLabel4);

Sleep(600);

}

else

{

Sleep(10);

GetSystemTime(&systime_Now);

lNow = systime_Now.wMilliseconds + 1000 * (systime_Now.wSecond +

60 * (systime_Now.wMinute + 60 * (long) systime_Now.wHour));

if(lStart > lNow)

{

lNow = lNow + 1000 * 60 * 60 * 24;

}

lDif = difftime(lNow, lStart);

Page 126: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.cpp

126

if(lDif >= 1000)

{

Synchronize(&UpdateLabel4);

Sleep(600);

}

}

}

while(Cond4 == true);

}

//---------------------------------------------------------------------------

protected __fastcall WriteMeasure4::UpdateLabel4(protected)

{

GetSystemTime(&systime_Start);

lStart = systime_Start.wMilliseconds + 1000 * (systime_Start.wSecond +

60 * (systime_Start.wMinute + 60 * (long) systime_Start.wHour));

FirstLoop = false;

Form3->ReadParameterDirect(iNode, 1, 0, 2, 0,

800, sAnswer, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

iAnswer = atoi(sAnswer);

y4 = (float)((iAnswer*100)/32000);

sprintf(sm4, "%.2f", y4);

sprintf(g->ThrMeas4, "%s", sm4);

x4 += 0.01666666666666666666667;

Form2->Label24->Caption = sm4;

PagesDlg->Label16->Caption = sm4;

Form2->Series4->AddXY(x4,y4,"",clWhite);

}

else

{

CountError++;

if(CountError == 10)

{

Cond4 = false;

Form2->Label24->Caption = "Error";

strcpy(g->ThrMeas4, " ---");

Form3->Memo1->Lines->Add("Measure could not be read..");

Form3->Memo1->Lines->Add("10 read errors have ocurred..");

Form3->Memo1->Lines->Add("-----------------------------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if(Form2->Label23->Caption == " ---")

{

Form3->ReadParameterDirect(iNode, 1, 1, 2, 1,

800, sAnswer, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

iAnswer = atoi(sAnswer);

y4 = (float)((iAnswer*100)/32000);

sprintf(PagesDlg->sp4, "%.2f", y4);

sprintf(g->ThrSetp4, "%s", PagesDlg->sp4);

Form2->Label23->Caption = PagesDlg->sp4;

PagesDlg->Label20->Caption = PagesDlg->sp4;

}

else

{

Form2->Label23->Caption = " ---";

Form3->Memo1->Lines->Add("Setpoint could not be read..");

Form3->Memo1->Lines->Add("-----------------------------------");

Page 127: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form2) Unit2.cpp

127

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if((Form2->Series4->Active == false)||(g->bComOpened == false))

{

Cond4 = false;

Form2->Label22->Caption = " ---";

Form2->Label23->Caption = " ---";

Form2->Label24->Caption = " ---";

PagesDlg->Label20->Caption = " ---";

PagesDlg->Label16->Caption = " ---";

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm2::Initial(protected)

{

Label4->Caption = " ---";

Label5->Caption = " ---";

Label6->Caption = " ---";

Label10->Caption = " ---";

Label11->Caption = " ---";

Label12->Caption = " ---";

Label16->Caption = " ---";

Label17->Caption = " ---";

Label18->Caption = " ---";

Label22->Caption = " ---";

Label23->Caption = " ---";

Label24->Caption = " ---";

Form2->Series1->Active = false;

Form2->Series2->Active = false;

Form2->Series3->Active = false;

Form2->Series4->Active = false;

}

Page 128: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.h

128

7.1.10. Unit3.h

//$$---- Form HDR ----

//---------------------------------------------------------------------------

#ifndef Unit3

#define Unit3

//---------------------------------------------------------------------------

#include "GlobalVariables.h"

#include "FlowbusAPI.h"

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <ComCtrls.hpp>

#include <Controls.hpp>

#include <Dialogs.hpp>

#include <ExtCtrls.hpp>

#include <ExtDlgs.hpp>

#include <StdCtrls.hpp>s.hpp>

//---------------------------------------------------------------------------

#define iLINE 2000

//---------------------------------------------------------------------------

class AutomaticMode : public TThread

{

private:

SYSTEMTIME systime_Now;

SYSTEMTIME systime_Start;

protected:

protected __fastcall Execute(protected);

protected __fastcall UpdateLabel(protected);

public:

bool Cond;

short iNode;

short iErrVal;

char sErrVal[100];

char bytStatus;

short iSetpoint;

char sSetpoint[8];

long lDif, lNow, lStart;

float lTimer, lPercent;

bool FirstLoop;

char buffer[100];

char s[80];

char sp1[80];

char sp2[80];

char sp3[80];

char sp4[80];

typedef struct{

int iNode[iLINE];

float lPercent[iLINE];

float lTimer[iLINE];

}Script;

Script var;

int i;

__fastcall AutomaticMode(bool CreateSuspended);

};

Page 129: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.h

129

class TForm3 : public TForm

{

__published: // IDE-managed Components

TButton *Button1;

TGroupBox *GroupBox2;

TButton *Button2;

TButton *Button4;

TButton *Button3;

TButton *Button5;

TGroupBox *GroupBox4;

TMemo *Memo2;

TMemo *Memo3;

TLabel *Label4;

TLabel *Label5;

TGroupBox *GroupBox5;

TButton *Button6;

TComboBox *ComboBox1;

TOpenTextFileDialog *OpenTextFileDialog1;

TStatusBar *StatusBar1;

TTimer *Timer1;

TMemo *Memo1;

TComboBox *ComboBox2;

TGroupBox *GroupBox1;

TButton *Button10;

TButton *Button9;

TGroupBox *GroupBox6;

TButton *Button8;

TButton *Button15;

TGroupBox *GroupBox7;

TMemo *Memo4;

TButton *Button16;

TGroupBox *GroupBox3;

TButton *Button11;

TButton *Button7;

TCheckBox *CheckBox1;

TCheckBox *CheckBox2;

TLabel *Label2;

TComboBox *ComboBox3;

TButton *Button12;

TLabel *Label1;

TLabel *Label3;

TCheckBox *CheckBox3;

TEdit *Edit1;

TEdit *Edit2;

TSaveDialog *SaveDialog1;

//---------------------------------------------------------------------------

protected __fastcall Button1Click(TObject *Sender);

protected __fastcall Button2Click(TObject *Sender);

protected __fastcall Button3Click(TObject *Sender);

protected __fastcall Button4Click(TObject *Sender);

protected __fastcall Button5Click(TObject *Sender);

protected __fastcall Button6Click(TObject *Sender);

protected __fastcall Button7Click(TObject *Sender);

protected __fastcall Button8Click(TObject *Sender);

protected __fastcall Button10Click(TObject *Sender);

protected __fastcall Button11Click(TObject *Sender);

protected __fastcall Button9Click(TObject *Sender);

protected __fastcall Timer1Timer(TObject *Sender);

protected __fastcall Button15Click(TObject *Sender);

protected __fastcall Button16Click(TObject *Sender);

protected __fastcall CheckBox2Click(TObject *Sender);

protected __fastcall Button12Click(TObject *Sender);

Page 130: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.h

130

protected __fastcall CheckBox3Click(TObject *Sender);

//---------------------------------------------------------------------------

private:

bool __fastcall TForm3::GetAnswer(short & iMsgId, char * sAnswer,

char * sErrVal, short & iErrVal, char & bytStatus);

SYSTEMTIME systime_Start;

//---------------------------------------------------------------------------

public:

__fastcall TForm3(TComponent* Owner);

short iNode;

short iErrVal;

char sErrVal[100];

char sAnswer[256];

char bytStatus;

short iSetpoint;

char sSetpoint[8];

short iPortIndex;

short iChoice;

char * sPort;

char ** sAvailComPorts;

short iAvailComPorts;

unsigned short uiBaudRate;

unsigned short iBaudRate;

char sCalibNumber[1];

char sCalibName[10];

bool FileClosed;

protected __fastcall TForm3::StartCommunication(char * sPort, bool bProcChain,

bool bParmChain,short & iErrVal,

unsigned short uiBaudRate,char * sErrVal);

protected __fastcall TForm3::CloseCommunication(char * sErrVal);

protected __fastcall TForm3::WriteParameterDirect(short iNode, short iProc,

short iParm,short iParmType, short iParmTypeLength,

long lTimeOut, char * sValue, short & iErrVal,

char & bytStatus, char * sErrVal);

protected __fastcall TForm3::SendWriteRequest(short iNode, short iProc,

short iParm, short iParmType, short iParmTypeLength,

char * sValue, short & iMsgId, short & iErrVal,

char * sErrVal);

protected __fastcall TForm3::ReadParameterDirect(short iNode, short iProc,

short iParm,short iParmType, short iParmTypeLength,

long lTimeOut, char * sAnswer, short & iErrVal,

char & bytStatus, char * sErrVal);

Page 131: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.h

131

protected __fastcall TForm3::SendReadRequest(short iNode, short iProc,

short iParm, short iParmType,short iParmTypeLength,

short & iMsgId, short & iErrVal,char * sErrVal);

bool __fastcall TForm3::GetInfoDirect(short iMsgId, long lTimeOut,

char & bytStatus, short & iErrVal, char * sErrVal,char *

sAnswer);

protected __fastcall TForm3::StartTimeOutTimer(protected);

bool __fastcall TForm3::TimeUp(long lTimeOut);

protected __fastcall TForm3::GetAvailablePorts(char ** & sAvailComPorts,

short & iAvailComPorts);

protected __fastcall TForm3::ReadingCalibration(protected);

protected __fastcall TForm3::WritingCalibration(protected);

protected __fastcall TForm3::Initial(protected);

protected __fastcall TForm3::FinalCloseComm(protected);

protected __fastcall TForm3::InitialOpenComm(protected);

protected __fastcall TForm3::AutomaticModeOn(protected);

protected __fastcall TForm3::AutomaticModeOff(protected);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm3 *Form3;

//---------------------------------------------------------------------------

#endif

Page 132: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

132

7.1.11. Unit3.cpp

//$$---- Form CPP ----

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include <iostream.h>

#include <stdlib.h>

#include <stdio.h>

#include <time.h>

#include <windows.h>

//---------------------------------------------------------------------------

#include "Unit1.h"

#include "Unit2.h"

#include "Unit3.h"

#include "Unit4.h"

#include "GlobalVariables.h"

#include "TabPgDlg.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

//---------------------------------------------------------------------------

TForm3 *Form3;

GlobalVariables * g;

//---------------------------------------------------------------------------

__fastcall AutomaticMode::AutomaticMode(bool CreateSuspended)

: TThread(CreateSuspended)

{

Cond = true;

FirstLoop = true;

Script var;

i = 0;

}

//---------------------------------------------------------------------------

protected __fastcall AutomaticMode::Execute(protected)

{

do

{

if(FirstLoop == true)

{

Synchronize(&UpdateLabel);

Sleep((lTimer*1000)-500);

}

else

{

GetSystemTime(&systime_Now);

lNow = systime_Now.wMilliseconds + 1000 * (systime_Now.wSecond +

60 * (systime_Now.wMinute + 60 * (long) systime_Now.wHour));

if(lStart > lNow)

{

lNow = lNow + 1000 * 60 * 60 * 24;

}

lDif = difftime(lNow, lStart);

if(lDif >= lTimer)

{

Synchronize(&UpdateLabel);

Sleep((lTimer*1000)-500);

}

}

}

while(Cond == true);

}

Page 133: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

133

//---------------------------------------------------------------------------

protected __fastcall AutomaticMode::UpdateLabel(protected)

{

FILE* fp;

GetSystemTime(&systime_Start);

lStart = systime_Start.wMilliseconds + 1000 * (systime_Start.wSecond +

60 * (systime_Start.wMinute + 60 * (long) systime_Start.wHour));

memset(buffer,'\0',100);

if(Form3->Label2->Caption != "")

{

if(FirstLoop == true)

{

Form3->CheckBox2->Font->Color = clBlue;

fp = fopen((const char*)Form3->OpenTextFileDialog1

->FileName.c_str(),"r");

if(fp == NULL) Form3->Memo1->Lines->

Add("File could not be opened..");

Form3->FileClosed = false;

fscanf(fp, "%[^\n]",buffer);

fscanf(fp, "%c", buffer);

FirstLoop = false;

while(!feof(fp))

{

fscanf(fp, "%d", &var.iNode[i]);

fscanf(fp, "%c", buffer);

fscanf(fp, "%f", &var.lPercent[i]);

fscanf(fp, "%c", buffer);

fscanf(fp, "%f", &var.lTimer[i]);

fscanf(fp, "%c", buffer);

i++;

}

fclose(fp);

i = 0;

}

iNode = var.iNode[i];

lPercent = var.lPercent[i];

lTimer = var.lTimer[i];

i ++;

if(iNode == 0)

{

Form3->Memo1->Lines->Add("Automatic proces has finished");

Cond = false;

Sleep(500);

Form3->AutomaticModeOff();

}

iSetpoint = (int)(32000*lPercent/100);

itoa((int)iSetpoint, sSetpoint, 10);

Form3->WriteParameterDirect(iNode, 1, 1, 2, 0,

400, sSetpoint, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

sprintf(s, "Setpoint correctly written at node %d", iNode);

Form3->Memo1->Lines->Add(s);

Form3->Memo1->Lines->Add("-------------------"

"----------------");

Form2->Visible = true;

Page 134: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

134

switch(iNode)

{

case 3:

Form2->Label4->Caption = 3;

sprintf(sp1, "%.2f", lPercent);

sprintf(g->ThrSetp2, "%s", sp1);

Form2->Label5->Caption = sp1;

break;

case 4:

Form2->Label10->Caption = 4;

sprintf(sp2, "%.2f", lPercent);

sprintf(g->ThrSetp2, "%s", sp2);

Form2->Label11->Caption = sp2;

break;

case 5:

Form2->Label16->Caption = 5;

sprintf(sp3, "%.2f", lPercent);

sprintf(g->ThrSetp3, "%s", sp3);

Form2->Label17->Caption = sp3;

break;

case 6:

sprintf(sp3, "%.2f", lPercent);

sprintf(g->ThrSetp4, "%s", sp4);

Form2->Label23->Caption = sp4;

PagesDlg->Label20->Caption = sp4;

break;

default: NULL;

}

switch(iNode)

{

case 3:

if(g->iThread1Off == true)

{

WriteMeasure1 *Thread = new WriteMeasure1 (false);

Thread->Resume();

g->iThread1Off = false;

}

break;

case 4:

if(g->iThread2Off == true)

{

WriteMeasure2 *Thread = new WriteMeasure2 (false);

Thread->Resume();

g->iThread2Off = false;

}

break;

case 5:

if(g->iThread3Off == true)

{

WriteMeasure3 *Thread = new WriteMeasure3 (false);

Thread->Resume();

g->iThread3Off = false;

}

break;

case 6:

if(g->iThread4Off == true)

{

WriteMeasure4 *Thread = new WriteMeasure4 (false);

Thread->Resume();

g->iThread4Off = false;

}

break;

default: NULL;

}

Page 135: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

135

}

else

{

sprintf(s, "Setpoint not correctly written at"

"node %d", iNode);

Form3->Memo1->Lines->Add("-----------------------"

"------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

if(g->bComOpened == false) Cond = false;

}

//---------------------------------------------------------------------------

__fastcall TForm3::TForm3(TComponent* Owner)

: TForm(Owner)

{

Initial();

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button1Click(TObject *Sender)

{

g = new GlobalVariables();

Button3->Visible = true;

Memo4->Clear();

Memo4->Lines->Add("Available com ports:");

GetAvailablePorts(sAvailComPorts, iAvailComPorts);

if(iAvailComPorts > 0)

{

for (iPortIndex = 0; iPortIndex < iAvailComPorts;

iPortIndex++)

{

delete sAvailComPorts[iPortIndex];

}

delete sAvailComPorts;

ComboBox1->Enabled = true;

Button4->Enabled = true;

Button1->Enabled = false;

if(CheckBox1->Checked == true)

{

ComboBox2->Enabled = true;

CheckBox1->Font->Color = clBlue;

}

else

{

CheckBox1->Font->Color = clBlack;

iBaudRate = 3;

}

}

else

{

Memo4->Lines->Add("Ports was not found..");

}

Memo4->Lines->Add("---------------------");

}

Page 136: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

136

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button2Click(TObject *Sender)

{

if(g->bComOpened)

{

Memo1->Lines->Add("Trying to close the communication...");

CloseCommunication(sErrVal);

if(strlen(sErrVal) == 0)

{

Memo1->Lines->Add("Communication as succesfully closed");

FinalCloseComm();

}

else

{

GroupBox4->Visible = true;

Memo1->Lines->Add("Communication could not be closed");

Memo2->Lines->Add(iErrVal);

Memo3->Lines->Add(sErrVal);

}

}

else

{

Memo1->Lines->Add("Communication already closed..");

}

Memo1->Lines->Add("-----------------------------------");

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button3Click(TObject *Sender)

{

if(g->bComOpened)

{

Memo1->Lines->Add("You must close the comunication before!");

Memo1->Lines->Add("-----------------------------------");

}

else

{

delete g;

exit(1);

}

if(!g->bComOpened) exit(1);

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button4Click(TObject *Sender)

{

Button4->Enabled = false;

iChoice = (unsigned short)ComboBox1->ItemIndex;

iChoice ++;

if(CheckBox1->Checked == true)

iBaudRate = (unsigned short)ComboBox2->ItemIndex;

if((iChoice >= 1) && iChoice <= iAvailComPorts)

{

StartCommunication(sAvailComPorts[iChoice - 1], false, true, iErrVal,

uiBaudRate, sErrVal);

if(strlen(sErrVal) == 0)

{

Memo1->Lines->Add("Communication was succesfully opened");

InitialOpenComm();

WriteHistory *Thread = new WriteHistory (false);

Page 137: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

137

Thread->Resume();

}

else

{

Button4->Enabled = true;

GroupBox4->Visible = true;

Button4->Visible = true;

Memo1->Lines->Add("Communication could not be opened");

Memo2->Lines->Add(iErrVal);

Memo3->Lines->Add(sErrVal);

}

}

Memo1->Lines->Add("-----------------------------------");

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button5Click(TObject *Sender)

{

Memo1->Lines->Add("---Checking communication---");

if(g->bComOpened)

{

Memo1->Lines->Add("-Communication currently open..");

}

else

{

Memo1->Lines->Add("-Communication currently closed..");

}

Memo1->Lines->Add("-----------------------------------");

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button6Click(TObject *Sender)

{

Memo2->Clear();

Memo3->Clear();

GroupBox4->Visible = false;

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button7Click(TObject *Sender)

{

Form2->Visible = true;

if(g->iThread1Off == true)

{

WriteMeasure1 *Thread = new WriteMeasure1 (false);

Thread->Resume();

g->iThread1Off = false;

}

if(g->iThread2Off == true)

{

WriteMeasure2 *Thread = new WriteMeasure2 (false);

Thread->Resume();

g->iThread2Off = false;

}

if(g->iThread3Off)

{

WriteMeasure3 *Thread = new WriteMeasure3 (false);

Thread->Resume();

g->iThread3Off = false;

}

if(g->iThread4Off)

{

WriteMeasure4 *Thread = new WriteMeasure4 (false);

Page 138: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

138

Thread->Resume();

g->iThread4Off = false;

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button8Click(TObject *Sender)

{

if(CheckBox2->Checked == true)

{

AutomaticModeOff();

}

else ShellExecute(Handle, "open",

"C:\\FlowBusDDE\\Files\\pl.csv", 0, 0, SW_SHOWNORMAL);

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button9Click(TObject *Sender)

{

SaveDialog1->Execute();

if(SaveDialog1->FileName != "")

{

Memo1->Lines->Add("Saving the Commands History at..");

Memo1->Lines->Add("-----------------------------------");

Memo1->Lines->Add(Now().TimeString());

Memo1->Lines->Add("-----------------------------------");

Memo1->Lines->SaveToFile(SaveDialog1->FileName);

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button10Click(TObject *Sender)

{

Form4->Visible = true;

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button11Click(TObject *Sender)

{

PagesDlg->Visible = true;

PagesDlg->Initial();

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button15Click(TObject *Sender)

{

if(CheckBox2->Checked == false && FileClosed == true)

{

OpenTextFileDialog1->Execute();

if(OpenTextFileDialog1->FileName != "")

Label2->Caption = OpenTextFileDialog1->FileName.c_str();

}

else

{

Form3->AutomaticModeOn();

Form2->Initial();

AutomaticMode *Thread = new AutomaticMode (false);

Thread->Resume();

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button16Click(TObject *Sender)

{

Page 139: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

139

if(CheckBox3->Checked == false) ReadingCalibration();

else WritingCalibration();

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Timer1Timer(TObject *Sender)

{

StatusBar1->Panels->Items[1]->Text = Now().DateString();

StatusBar1->Panels->Items[2]->Text = Now().TimeString();

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::CheckBox2Click(TObject *Sender)

{

if(CheckBox2->Checked == true)

{

Button15->Caption = "Load";

CheckBox2->Caption = "Automatic way";

Label2->Font->Color = clBlue;

Button8->Caption = "STOP";

Button8->Font->Color = clBlue;

}

else

{

Button15->Caption = "Open";

CheckBox2->Caption = "LOAD CSV File";

Label2->Font->Color = clBlack;

CheckBox2->Font->Color = clBlack;

Button8->Caption = "New";

Button8->Font->Color = clBlack;

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::CheckBox3Click(TObject *Sender)

{

if(CheckBox3->Checked == true)

{

Button16->Caption = "Write Calibration";

CheckBox3->Font->Color = clBlue;

Edit1->Enabled = true;

Edit2->Enabled = true;

}

else

{

Button16->Caption = "Read Calibration";

CheckBox3->Font->Color = clBlack;

Edit1->Enabled = false;

Edit2->Enabled = false;

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::ReadingCalibration(protected)

{

char s[80];

if(g->bComOpened)

{

iNode = (int) ComboBox3->ItemIndex;

switch(iNode)

{

case 0: iNode = 3;break;

case 1: iNode = 4;break;

case 2: iNode = 5;break;

Page 140: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

140

case 3: iNode = 6;break;

default: NULL;

}

Memo1->Lines->Add("Reading Calibration..");

ReadParameterDirect(iNode, 1, 17, 0, 10,

1000, sAnswer, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

sprintf(s, "Node %d calibrate with %s", iNode, sAnswer);

Memo1->Lines->Add(s);

Memo1->Lines->Add("-----------------------------------");

}

else

{

Memo1->Lines->Add("Fluid Name could not be read..");

Memo1->Lines->Add("-----------------------------------");

GroupBox4->Visible = true;

Memo2->Lines->Add(iErrVal);

Memo3->Lines->Add(sErrVal);

}

}

else Memo1->Lines->Add("Parameter setpoint could not be read"

"(no comunication)");

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::WritingCalibration()

{

char s[80];

int iNum;

char sName;

if(g->bComOpened)

{

iNode = (int) ComboBox3->ItemIndex;

switch(iNode)

{

case 0: iNode = 3;break;

case 1: iNode = 4;break;

case 2: iNode = 5;break;

case 3: iNode = 6;break;

default: NULL;

}

Memo1->Lines->Add("Writing Calibration..");

iNum = Edit1->Text.ToInt();

itoa(iNum, sCalibNumber, 10);

WriteParameterDirect(iNode, 1, 16, 0, 0,

1000, sCalibNumber, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

sprintf(s, "Node %i at mode %d", iNode, iNum);

Memo1->Lines->Add(s);

Memo1->Lines->Add("-----------------------------------");

}

else

{

Memo1->Lines->Add("Fluid Number could not be write..");

Memo1->Lines->Add("-----------------------------------");

GroupBox4->Visible = true;

Memo2->Lines->Add(iErrVal);

Memo3->Lines->Add(sErrVal);

}

Sleep(100);

if(Edit2->Text != "")

{

Page 141: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

141

sName = (int)Edit2->Text.ToInt();

itoa(sName, sCalibName, 10);

WriteParameterDirect(iNode, 1, 17, 0, 10,

1000, sCalibName, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

sprintf(s, "Node %d new calibrate name: %s", iNode, sName);

Memo1->Lines->Add(s);

Memo1->Lines->Add("-----------------------------------");

}

else

{

Memo1->Lines->Add("Fluid Name could not be write..");

Memo1->Lines->Add("-----------------------------------");

GroupBox4->Visible = true;

Memo2->Lines->Add(iErrVal);

Memo3->Lines->Add(sErrVal);

}

}

}

else Memo1->Lines->Add("Parameter setpoint could not be read"

"(no comunication)");

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Initial()

{

Memo1->Clear();

Memo2->Clear();

Memo3->Clear();

Memo4->Clear();

Edit1->Clear();

Edit2->Clear();

Edit1->Enabled = false;

Edit2->Enabled = false;

ComboBox2->Enabled = false;

GroupBox1->Visible = false;

GroupBox3->Visible = false;

GroupBox4->Visible = false;

GroupBox6->Visible = false;

GroupBox7->Visible = false;

Button4->Enabled = false;

Button2->Enabled = false;

Button3->Visible = false;

Label2->Visible = false;

StatusBar1->Panels->Items[0]->Text = "Welcome to Flow DDE V1.0.1";

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::FinalCloseComm()

{

GroupBox1->Visible = false;

Button2->Enabled = false;

GroupBox3->Visible = false;

GroupBox4->Visible = false;

GroupBox6->Visible = false;

GroupBox7->Visible = false;

Button1->Enabled = true;

Memo4->Enabled = true;

Memo4->Clear();

Memo2->Clear();

Memo3->Clear();

ComboBox1->Clear();

Page 142: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

142

CheckBox1->Enabled = true;

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::InitialOpenComm()

{

ComboBox1->Enabled = false;

ComboBox2->Enabled = false;

Button4->Enabled = false;

Button2->Enabled = true;

GroupBox1->Visible = true;

GroupBox3->Visible = true;

GroupBox6->Visible = true;

GroupBox7->Visible = true;

PagesDlg->Initial();

Label2->Visible = true;

Label2->Caption = "";

FileClosed = true;

CheckBox1->Enabled = false;

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::AutomaticModeOn()

{

Button11->Enabled = false;

Button12->Enabled = false;

Button15->Enabled = false;

Button16->Enabled = false;

CheckBox2->Enabled = false;

CheckBox3->Enabled = false;

ComboBox3->Enabled = false;

Edit1->Enabled = false;

Edit2->Enabled = false;

Label1->Enabled = false;

Label3->Enabled = false;

Form2->Series1->Active = false;

Form2->Series2->Active = false;

Form2->Series3->Active = false;

Form2->Series4->Active = false;

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::AutomaticModeOff(protected)

{

Button11->Enabled = true;

Button12->Enabled = true;

Button15->Enabled = true;

Button16->Enabled = true;

CheckBox2->Enabled = true;

CheckBox2->Checked = false;

CheckBox3->Enabled = true;

ComboBox3->Enabled = true;

Edit1->Enabled = true;

Edit2->Enabled = true;

Label1->Enabled = true;

Label3->Enabled = true;

}

Page 143: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

143

protected __fastcall TForm3::GetAvailablePorts(char ** & sAvailComPorts,

short & iAvailComPorts)

{

char bytNrOfComPorts;

char bytPortIndex;

short iMemSize;

short iErrVal;

bool bInUse;

char * sTemp;

short iIndex;

iAvailComPorts = 0;

bytNrOfComPorts = g->oFlowbusAPI->GetNrPorts();

sAvailComPorts = (char **) malloc(sizeof(char*) * bytNrOfComPorts);

/*Add all ports that where found to the combobox*/

for(bytPortIndex = 0; bytPortIndex < bytNrOfComPorts; bytPortIndex++)

{

iMemSize = g->oFlowbusAPI->GetPort(bytPortIndex, 0, &bInUse, sTemp);

/*if actually needed memory size was returned.*/

if(iMemSize > 0)

{

/*Create a characterstring of iMemSize characters..*/

sTemp = new char[iMemSize];

iErrVal = g->oFlowbusAPI->GetPort(bytPortIndex, iMemSize,

&bInUse, sTemp);

if(iErrVal == 0)

{

iIndex = 0;

while(iIndex < (short) strlen(sTemp))

{

if(sTemp[iIndex] == 9)

{

break;

}

else

{

iIndex++;

}

}

if(iIndex < (short) strlen(sTemp))

{

sPort = new char[strlen(sTemp) - iIndex];

strcpy(sPort, &(sTemp[iIndex + 1]));

/*Add the port to the list of available ports..*/

sAvailComPorts[iAvailComPorts] = sPort;

Memo4->Lines->Add(sPort);

ComboBox1->AddItem(sPort,ComboBox1);

/*Increase the array with 1*/

iAvailComPorts++;

}

}

/*Release the memory claimed for sTemp*/

delete sTemp;

}

}

Page 144: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

144

}

protected __fastcall TForm3::StartCommunication(char * sPort, bool bProcChain,

bool bParmChain,short & iErrVal,

unsigned short uiBaudRate,char * sErrVal)

{

char bytNode;

char bytSecNode;

char bytNextNode;

char bytLastNode;

char bytArbiterMode;

char bytTxRetries;

char bytRxRetries;

char sOldPort[256];

short iAttempt;

const long MAXATTEMPTS = 3;

strcpy(sErrVal, "");

g->oFlowbusAPI->GetTNetConfig(&bytNode, &bytSecNode, &bytNextNode,

&bytLastNode, &bytArbiterMode, &bytTxRetries, &bytRxRetries, sOldPort);

iErrVal = g->oFlowbusAPI->ConfigureTNet(bytNode, bytSecNode,

bytNextNode, bytLastNode, bytArbiterMode, bytTxRetries, bytRxRetries,

sPort);

if(iErrVal == 0)

{

switch(iBaudRate)

{

case 0: uiBaudRate = 4800; break;

case 1: uiBaudRate = 9600; break;

case 2: uiBaudRate = 19200; break;

case 3: uiBaudRate = 38400; break;

default:

/*Baudrate not supported, set error*/

strcpy(sErrVal, "Baudrate not supported..");

}

/*Configure the port with the new baudrate*/

iErrVal = g->oFlowbusAPI->ConfigureRS232(sPort, uiBaudRate);

if(iErrVal == 0)

{

g->oFlowbusAPI->ConfigureChaining(bProcChain, bParmChain);

/*

Try to open the communication on port sPort.

Maximum number of attempts is MAXATTEMPTS

*/

for(iAttempt = 1; iAttempt <= MAXATTEMPTS; iAttempt++)

{

iErrVal = g->oFlowbusAPI->OpenCommunication(sPort);

if(iErrVal == 0)

{

g->bComOpened = true;

/*Communication opened, so exit this loop*/

break;

}

}

Page 145: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

145

if(!g->bComOpened)

{

strcpy(sErrVal,

"Port could not be opened for(communication)");

}

}

else

{

strcpy(sErrVal, "Baudrate could not be set");

}

}

else

{

strcpy(sErrVal,

"TNet could not be configured on the supplied port..");

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::CloseCommunication(char * sErrVal)

{

short iErrVal;

strcpy(sErrVal, "");

if(g->bComOpened)

{

/*if so, try to close the communication*/

iErrVal = g->oFlowbusAPI->CloseCommunication();

if(iErrVal != 0)

{

strcpy(sErrVal, "Error closing communication");

}

else

{

g->bComOpened = false;

}

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::WriteParameterDirect(short iNode, short iProc,

short iParm,short iParmType, short iParmTypeLength,

long lTimeOut, char * sValue, short & iErrVal,

char & bytStatus, char * sErrVal)

{

short iMsgId;

SendWriteRequest(iNode, iProc, iParm, iParmType, iParmTypeLength,

sValue, iMsgId, iErrVal, sErrVal);

if(strlen(sErrVal) == 0)

{

if(!GetInfoDirect(iMsgId, lTimeOut, bytStatus, iErrVal, sErrVal, 0))

{

/*

Set an error that no answer was received on the write-request

*/

strcpy(sErrVal, "No answer received on write-request, timeout");

}

}

}

Page 146: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

146

//---------------------------------------------------------------------------

protected __fastcall TForm3::SendWriteRequest(short iNode, short iProc, short

iParm,

short iParmType, short iParmTypeLength, char * sValue,

short & iMsgId, short & iErrVal, char * sErrVal)

{

switch(iNode)

{

case 3: iMsgId = 1; break;

case 4: iMsgId = 2; break;

case 5: iMsgId = 3; break;

case 6: iMsgId = 4; break;

}

strcpy(sErrVal, "");

while(iParmTypeLength > (short) strlen(sValue))

{

strcat(sValue, " ");

}

/*Valid parametertype?*/

if(iParmType >= 0 && iParmType <= 3)

{

/*Send a proper read-request to the instrument on the flowbus*/

switch(iParmType)

{

case 2: /*Parameter of type Integer?*/

iErrVal = g->oFlowbusAPI->WriteInt(g->iAppId, 0,

(char) iNode, (char) iProc, (char) iParm, atoi(sValue),

iMsgId);

break;

case 1: /*(Parameter of type Float?*/

iErrVal = g->oFlowbusAPI->WriteFloat(g->iAppId, 0,

(char) iNode, (char) iProc, (char) iParm,

(float) atof(sValue), iMsgId);

break;

case 3: /*Parameter of type Long?*/

iErrVal = g->oFlowbusAPI->WriteLong(g->iAppId, 0,

(char) iNode, (char) iProc, (char) iParm, atol(sValue),

iMsgId);

break;

case 0: /*Parameter of type String?*/

/*Is the parameter of type Byte (1 character)?*/

if( iParmTypeLength == 0)

{

iErrVal = g->oFlowbusAPI->WriteChar(g->iAppId, 0,

(char) iNode, (char) iProc, (char) iParm,

(char) atoi(sValue), iMsgId);

}

else

{

/*Is the parameter of type Zero Terminated String?*/

if(iParmTypeLength == -2)

{

iParmTypeLength = 0;

}

Page 147: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

147

/*

Check if( the parameter value is not an empty string.

Sending an empty string will hang-up FLOWDDE !!!!!

*/

if(strlen(sValue) == 0)

{

strcpy(sValue, " ");

}

iErrVal = g->oFlowbusAPI->WriteString(g->iAppId, 0,

(char) iNode, (char) iProc, (char) iParm,

(char) iParmTypeLength, sValue, iMsgId);

}

break;

}

if(iErrVal != 0)

{

/*Set an error indicating the cause of the error*/

strcpy(sErrVal,

"Error returned on write-request (error calling WriteXXX())");

}

}

else

{

/*

Set an error indicating the supplied parameter

type does not exist

*/

iErrVal = 1;

strcpy(sErrVal, "Parameter type not found");

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::ReadParameterDirect(short iNode, short iProc,

short iParm,short iParmType, short iParmTypeLength,

long lTimeOut, char * sAnswer, short & iErrVal,

char & bytStatus, char * sErrVal)

{

short iMsgId;

SendReadRequest(iNode, iProc, iParm, iParmType, iParmTypeLength,

iMsgId, iErrVal, sErrVal);

if(strlen(sErrVal) == 0)

{

/*if no answer was received on the read-request*/

if(!GetInfoDirect(iMsgId, lTimeOut, bytStatus, iErrVal, sErrVal,

sAnswer))

{

/*Set an error that the parameter value was not found*/

strcpy(sErrVal, "Parameter value not found, timeout");

}

}

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::SendReadRequest(short iNode, short iProc, short iParm,

short iParmType,short iParmTypeLength, short & iMsgId,

short & iErrVal,char * sErrVal)

{

Page 148: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

148

switch(iNode)

{

case 3: iMsgId = 1; break;

case 4: iMsgId = 2; break;

case 5: iMsgId = 3; break;

case 6: iMsgId = 4; break;

}

iErrVal = 0;

strcpy(sErrVal, "");

if(iParmType >= 0 && iParmType <= 3)

{

/*Send a proper read-request to the instrument on the flowbus*/

switch(iParmType)

{

case 2: /*Parameter of type Integer?*/

iErrVal = g->oFlowbusAPI->ReadInt(g->iAppId, 0,

(char) iNode, (char) iProc, (char) iParm, iMsgId);

break;

case 1: /*Parameter of type Float?*/

iErrVal = g->oFlowbusAPI->ReadFloat(g->iAppId, 0,

(char) iNode, (char) iProc, (char) iParm, iMsgId);

break;

case 3: /*Parameter of type Long?*/

iErrVal = g->oFlowbusAPI->ReadLong(g->iAppId, 0,

(char) iNode, (char) iProc, (char) iParm, iMsgId);

break;

case 0: /*Parameter of type String?*/

/*Is the parameter of type Byte?*/

if(iParmTypeLength == 0)

{

iErrVal = g->oFlowbusAPI->ReadChar(g->iAppId, 0,

(char) iNode, (char) iProc, (char) iParm, iMsgId);

}

else

{

/*Is the parameter is of type Zero Terminated String?*/

if(iParmTypeLength == -2)

{

/*

Set length of the parameter to 0, indicating

zero terminated string

*/

iParmTypeLength = 0;

}

/*

else the length of the parameter remains as it was,

indicating Fixed String

*/

iErrVal = g->oFlowbusAPI->ReadString(g->iAppId, 0,

(char) iNode, (char) iProc, (char) iParm,

(char) iParmTypeLength, iMsgId);

}

break;

}

Page 149: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

149

if(iErrVal != 0)

{

/*Set an error indicating the cause of the error*/

strcpy(sErrVal,

"Error returned on read-request (error calling ReadXXX())");

}

}

else

{

/*

Set an error indicating the supplied parameter type does not exist

*/

iErrVal = 1;

strcpy(sErrVal, "Parameter type not found");

}

}

//---------------------------------------------------------------------------

bool __fastcall TForm3::GetInfoDirect(short iMsgId, long lTimeOut,

char & bytStatus,short & iErrVal, char * sErrVal,char * sAnswer)

{

bool bFound; /*message has been found*/

bool bRetVal; /*message was answered*/

short iMsgIdFound;

char sValue[256];

bRetVal = false; /*Message not answered yet*/

StartTimeOutTimer(); /*Start the timeout timer*/

do

{

bFound = GetAnswer(iMsgIdFound, sValue, sErrVal, iErrVal,

bytStatus);

if(bFound)

{

/*Check if it is the message we are looking for..*/

if(iMsgId == iMsgIdFound)

{

/*Yes, it was our message..*/

bRetVal = true;

/*

Now check to see if the parameter sAnswer is not Null

*/

if(sAnswer != 0)

{

strcpy(sAnswer, sValue);

}

}

}

}while(!bRetVal && !TimeUp(lTimeOut));

return bRetVal;

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::StartTimeOutTimer()

{

GetSystemTime(&systime_Start);

}

Page 150: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

150

//---------------------------------------------------------------------------

bool __fastcall TForm3::TimeUp(long lTimeOut)

{

SYSTEMTIME systime_Now;

long lStart;

long lNow;

GetSystemTime(&systime_Now);

/*Get the time in milliseconds at the moment the timer was started*/

lStart = systime_Start.wMilliseconds + 1000 * (systime_Start.wSecond +

60 * (systime_Start.wMinute + 60 * (long) systime_Start.wHour));

/*Get the current time in milliseconds*/

lNow = systime_Now.wMilliseconds + 1000 * (systime_Now.wSecond +

60 * (systime_Now.wMinute + 60 * (long) systime_Now.wHour));

if(lStart > lNow)

{

lNow = lNow + 1000 * 60 * 60 * 24;

}

/*Check if timeout occured*/

return ((lNow - lStart) >= lTimeOut);

}

//---------------------------------------------------------------------------

bool __fastcall TForm3::GetAnswer(short & iMsgId, char * sAnswer,

char * sErrVal, short & iErrVal, char & bytStatus)

{

char bytNode;

char bytProc;

char bytParm;

char bytMsgType;

char bytParmType;

char bytValue;

short iValue;

float fValue;

long lValue;

char bytStrLen;

bool bMsgFound;

bMsgFound = false; //no message found yet

strcpy(sErrVal, "");

iErrVal = 0;

iErrVal = g->oFlowbusAPI->CheckReceivedMsg(g->iAppId, &bytNode,

&bytProc, &bytParm, &bytMsgType, &bytParmType, &iMsgId);

if(iErrVal == 0)

{

bMsgFound = true;

iErrVal = g->oFlowbusAPI->GetError();

if(iErrVal == 0)

{

if(bytMsgType == 0 || bytMsgType == 1)

{

iErrVal = g->oFlowbusAPI->GetStatus(g->iAppId, bytNode,

bytProc, bytParm, &bytStatus, &iMsgId);

Page 151: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

151

if(bytMsgType == 1)

{

if(iErrVal == 0 && bytStatus == 0)

{

switch(bytParmType)

{

/*Is the parameter of type Byte?*/

case 0:

iErrVal = g->oFlowbusAPI

->GetChar(g->iAppId, bytNode,

bytProc, bytParm, &bytValue,

&iMsgId);

sAnswer[0] = bytValue;

/*

zero terminate the string

of 1 character

*/

sAnswer[1] = 0;

break;

/*Is the parameter of type Integer?*/

case 1:

iErrVal = g->oFlowbusAPI

->GetInt(g->iAppId,

bytNode, bytProc, bytParm,

&iValue, &iMsgId);

itoa(iValue, sAnswer, 10);

//sprintf(sAnswer, "%i", iValue);

break;

/*Is the parameter of type Float?*/

case 2:

iErrVal = g->oFlowbusAPI

->GetFloat(g->iAppId,

bytNode, bytProc, bytParm,

&fValue,&iMsgId);

/*

Convert float to string,

7 significant digits

*/

_gcvt((double) fValue, 7,

sAnswer);

break;

/*Is the parameter of type Long?*/

case 3:

iErrVal = g->oFlowbusAPI

->GetLong(g->iAppId,

bytNode, bytProc, bytParm,

&lValue, &iMsgId);

/*Convert long to string, radix 10*/

_ltoa(lValue, sAnswer, 10);

break;

/*Is the parameter of type String?*/

case 4:

iErrVal = g->oFlowbusAPI

Page 152: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla principal (Form3) unit3.cpp

152

->GetString(g->iAppId, bytNode,

bytProc, bytParm,&iMsgId, sAnswer,

&bytStrLen);

break;

default:

/*Set an error..*/

strcpy(sErrVal, "Parameter type

not found!!");

iErrVal = 12;

break;

}

/*if an error occured while reading the parameter

value */

if(iErrVal != 0)

{

strcpy(sErrVal, "Error while reading parameter

value");

}

}

else

{

strcpy(sErrVal, "Statuscode indicated an

error");

}

}

}

else

{

strcpy(sErrVal, "Message type not found");

}

}

else

{

strcpy(sErrVal,"g->oFlowbusAPI->GetError() detected an internal

error");

}

g->oFlowbusAPI->RemoveMsg(g->iAppId, bytNode, bytProc, bytParm);

}

return bMsgFound;

}

//---------------------------------------------------------------------------

protected __fastcall TForm3::Button12Click(TObject *Sender)

{

Form1->Visible = true;

}

Page 153: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form4) Unit4.h

153

7.1.12. Unit4.h

//$$---- Form HDR ----

//---------------------------------------------------------------------------

#ifndef Unit4H

#define Unit4H

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <ComCtrls.hpp>

#include <ExtCtrls.hpp>

//---------------------------------------------------------------------------

#include "GlobalVariables.h"

#include <Classes.hpp>

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------

class WriteHistory : public TThread

{

private:

SYSTEMTIME systime_Now;

SYSTEMTIME systime_Start;

protected:

void __fastcall Execute(void);

void __fastcall UpdateList();

public:

bool Cond;

char s[200];

unsigned short iSeries;

short iNode;

AnsiString sTime;

AnsiString sDate;

long lDif, lNow, lStart;

bool FirstLoop;

__fastcall WriteHistory(bool CreateSuspended);

};

//---------------------------------------------------------------------------

class TForm4 : public TForm

{

__published: // IDE-managed Components

TListBox *ListBox1;

TStatusBar *StatusBar1;

TTimer *Timer1;

TLabel *Label1;

TLabel *Label2;

TLabel *Label3;

TLabel *Label4;

TLabel *Label5;

void __fastcall Timer1Timer(TObject *Sender);

Page 154: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form4) Unit4.h

154

private:

public:

__fastcall TForm4(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm4 *Form4;

//---------------------------------------------------------------------------

#endif

Page 155: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form4) Unit4.cpp

155

7.1.13. Unit4.cpp

//$$---- Form CPP ----

//---------------------------------------------------------------------------

//

#include <vcl.h>

#pragma hdrstop

#include <stdio.h>

#include <time.h>

//---------------------------------------------------------------------------

#include "Unit2.h"

#include "Unit4.h"

#include "GlobalVariables.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

//---------------------------------------------------------------------------

TForm4 *Form4;

//---------------------------------------------------------------------------

__fastcall TForm4::TForm4(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

__fastcall WriteHistory::WriteHistory(bool CreateSuspended)

: TThread(CreateSuspended)

{

Cond = true;

sTime = 0;

sDate = 0;

FirstLoop = true;

}

//---------------------------------------------------------------------------

void __fastcall WriteHistory::Execute(void)

{

do

{

GetSystemTime(&systime_Start);

if(FirstLoop == true)

{

Synchronize(&UpdateList);

Sleep(29700);

}

else

{

GetSystemTime(&systime_Now);

lNow = systime_Now.wMilliseconds + 1000 * (systime_Now.wSecond +

60 * (systime_Now.wMinute + 60 * (long) systime_Now.wHour));

if(lStart > lNow)

{

lNow = lNow + 1000 * 60 * 60 * 24;

}

lDif = difftime(lNow, lStart);

if(lDif >= 30000)

{

Synchronize(&UpdateList);

Sleep(29700);

}

}

}

Page 156: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form4) Unit4.cpp

156

while(Cond == true);

}

//---------------------------------------------------------------------------

void __fastcall WriteHistory::UpdateList(void)

{

if(g->bComOpened)

{

FirstLoop = false;

lStart = systime_Start.wMilliseconds + 1000 * (systime_Start.wSecond +

60 * (systime_Start.wMinute + 60 * (long) systime_Start.wHour));

for(iSeries = 1; iSeries < 5; iSeries++)

{

switch(iSeries)

{

case 1:

if(Form2->Series1->Active == true)

{

iNode = Form2->Label4->Caption.ToInt();

sDate = Form3->StatusBar1->Panels->Items[1]->Text;

sTime = Form3->StatusBar1->Panels->Items[2]->Text;

sprintf(s, " %s " " %s " " %i "

" %s "

" %s "

,sDate, sTime, iNode, g->ThrSetp1,

g->ThrMeas1);

Form4->ListBox1->Items->Add(s);

}

else

{

sDate = Form3->StatusBar1->Panels->Items[1]->Text;

sTime = Form3->StatusBar1->Panels->Items[2]->Text;

sprintf(s, " %s " " %s " " Series1 is not"

"Active", sDate, sTime);

Form4->ListBox1->Items->Add(s);

}

break;

case 2:

if(Form2->Series2->Active == true)

{

iNode = Form2->Label10->Caption.ToInt();

sDate = Form3->StatusBar1->Panels->Items[1]->Text;

sprintf(s, " %s " " %s " " %i "

" %s "

" %s "

,sDate, sTime, iNode, g->ThrSetp2,

g->ThrMeas2);

Form4->ListBox1->Items->Add(s);

}

else

{

sDate = Form3->StatusBar1->Panels->Items[1]->Text;

sTime = Form3->StatusBar1->Panels->Items[2]->Text;

sprintf(s, " %s " " %s " " Series2 is not"

"Active", sDate, sTime);

Form4->ListBox1->Items->Add(s);

}

break;

case 3:

if(Form2->Series3->Active == true)

{

iNode = Form2->Label16->Caption.ToInt();

Page 157: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (Form4) Unit4.cpp

157

sDate = Form3->StatusBar1->Panels->Items[1]->Text;

sTime = Form3->StatusBar1->Panels->Items[2]->Text;

sprintf(s, " %s " " %s " " %i "

" %s "

" %s "

,sDate, sTime, iNode, g->ThrSetp3,

g->ThrMeas3);

Form4->ListBox1->Items->Add(s);

}

else

{

sDate = Form3->StatusBar1->Panels->Items[1]->Text;

sTime = Form3->StatusBar1->Panels->Items[2]->Text;

sprintf(s, " %s " " %s " " Series3 is not"

"Active", sDate, sTime);

Form4->ListBox1->Items->Add(s);

}

break;

case 4:

if(Form2->Series4->Active == true)

{

iNode = Form2->Label22->Caption.ToInt();

sDate = Form3->StatusBar1->Panels->Items[1]->Text;

sTime = Form3->StatusBar1->Panels->Items[2]->Text;

sprintf(s, " %s " " %s " " %i "

" %s "

" %s "

,sDate, sTime, iNode, g->ThrSetp4,

g->ThrMeas4);

Form4->ListBox1->Items->Add(s);

}

else

{

sprintf(s, " %s " " %s " " Series4 is not"

"Active", sDate, sTime);

Form4->ListBox1->Items->Add(s);

Form4->ListBox1->Items->Add("---------------------"

"----------------------------------"

"----------------------------------------");

}

break;

default: NULL;

}

}

}

else

{

Cond = false;

Form4->ListBox1->Items->SaveToFile("C:\\FlowBusDDE\\

Files\\MeasurementHistory.txt");

}

}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------

void __fastcall TForm4::Timer1Timer(TObject *Sender)

{

StatusBar1->Panels->Items[0]->Text = "writing the measure every 30 seconds";

StatusBar1->Panels->Items[1]->Text = Now().TimeString();

}

Page 158: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (PagesDlg) PagesDlg.h

158

7.1.14. PagesDlg.h

//----------------------------------------------------------------------------

#ifndef TabPgDlgH

#define TabPgDlgH

//----------------------------------------------------------------------------

#include <Classes.hpp>

#include <ComCtrls.hpp>

#include <Controls.hpp>

#include <ExtCtrls.hpp>

#include <StdCtrls.hpp>

//----------------------------------------------------------------------------

class TPagesDlg : public TForm

{

__published:

TPanel *Panel1;

TPageControl *PageControl1;

TTabSheet *TabSheet1;

TGroupBox *GroupBox3;

TLabel *Label2;

TEdit *Edit2;

TButton *Button1;

TGroupBox *GroupBox1;

TLabel *Label3;

TLabel *Label4;

TTabSheet *TabSheet2;

TGroupBox *GroupBox2;

TLabel *Label6;

TEdit *Edit4;

TButton *Button2;

TGroupBox *GroupBox4;

TLabel *Label7;

TLabel *Label8;

TTabSheet *TabSheet3;

TGroupBox *GroupBox5;

TLabel *Label9;

TLabel *Label10;

TGroupBox *GroupBox6;

TLabel *Label12;

TEdit *Edit6;

TButton *Button3;

TTabSheet *TabSheet4;

TGroupBox *GroupBox7;

TLabel *Label14;

TEdit *Edit8;

TGroupBox *GroupBox8;

TLabel *Label15;

TLabel *Label16;

TButton *Button5;

TButton *Button6;

TButton *Button7;

TButton *Button8;

TButton *Button4;

TLabel *Label1;

TLabel *Label5;

TLabel *Label13;

TLabel *Label18;

TLabel *Label20;

TLabel *Label11;

TLabel *Label17;

TLabel *Label19;

void __fastcall Button1Click(TObject *Sender);

void __fastcall Button2Click(TObject *Sender);

void __fastcall Button3Click(TObject *Sender);

Page 159: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (PagesDlg) PagesDlg.h

159

void __fastcall Button5Click(TObject *Sender);

void __fastcall Button6Click(TObject *Sender);

void __fastcall Button7Click(TObject *Sender);

void __fastcall Button8Click(TObject *Sender);

void __fastcall Button4Click(TObject *Sender);

private:

public:

short iNode;

short iErrVal;

char sErrVal[100];

char sAnswer[256];

char bytStatus;

short iSetpoint;

char sSetpoint[8];

char sp1[80];

char sp2[80];

char sp3[80];

char sp4[80];

virtual __fastcall TPagesDlg(TComponent* AOwner);

void __fastcall TPagesDlg::Initial(void);

};

//----------------------------------------------------------------------------

extern PACKAGE TPagesDlg *PagesDlg;

//----------------------------------------------------------------------------

#endif

Page 160: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (PagesDlg) PagesDlg.cpp

160

7.1.15. PagesDlg.cpp

#include <vcl.h>

#pragma hdrstop

#include <iostream.h>

#include <stdlib.h>

//---------------------------------------------------------------------

#include "Unit2.h"

#include "Unit3.h"

#include "Unit4.h"

#include "GlobalVariables.h"

#include "TabPgDlg.h"

//---------------------------------------------------------------------

#pragma resource "*.dfm"

TPagesDlg *PagesDlg;

//---------------------------------------------------------------------

__fastcall TPagesDlg::TPagesDlg(TComponent* AOwner)

: TForm(AOwner)

{

}

//---------------------------------------------------------------------

void __fastcall TPagesDlg::Button1Click(TObject *Sender)

{

float percent = 0;

if(g->bComOpened)

{

percent = PagesDlg->Edit2->Text.ToDouble();

if((percent >= 0)&&(percent <= 100))

{

Form2->Label5->Caption = percent;

iSetpoint = ((32000 * percent)/100);

itoa(iSetpoint, sSetpoint, 10);

Form3->WriteParameterDirect(3,1, 1, 2, 0,

700, sSetpoint, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

Form2->Visible = true;

Form3->Memo1->Lines->Add("Setpoint correctly written..");

Form3->Memo1->Lines->Add("-----------------------“

”------------");

Form2->Label4->Caption = 3;

sprintf(sp1, "%.2f", percent);

sprintf(g->ThrSetp1, "%s", sp1);

Form2->Label5->Caption = sp1;

PagesDlg->Label5->Caption = sp1;

if(g->iThread1Off == true)

{

WriteMeasure1 *Thread = new WriteMeasure1 (false);

Thread->Resume();

g->iThread1Off = false;

}

}

else

{

Form3->Memo1->Lines->Add("Setpoint not correctly"

"written..");

Form3->Memo1->Lines->Add("------------------"

"-----------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Page 161: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (PagesDlg) PagesDlg.cpp

161

Form3->Memo3->Lines->Add(sErrVal);

}

}

else

{

Form3->Memo1->Lines->Add("Enter value since 1 to 100..");

}

}

else

{

Form3->Memo1->Lines->Add("Parameter setpoint could"

"not be written (no comunication)");

}

}

//---------------------------------------------------------------------------

void __fastcall TPagesDlg::Button2Click(TObject *Sender)

{

float percent = 0;

if(g->bComOpened)

{

percent = PagesDlg->Edit4->Text.ToDouble();

if((percent >= 0)&&(percent <= 100))

{

iSetpoint = ((32000 * percent)/100);

itoa(iSetpoint, sSetpoint, 10);

Form3->WriteParameterDirect(4,1, 1, 2, 0,

700, sSetpoint, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

Form2->Visible = true;

Form3->Memo1->Lines->Add("Setpoint correctly written..");

Form3->Memo1->Lines->Add("------------------"

"-----------------");

Form2->Label10->Caption = 4;

sprintf(sp2, "%.2f", percent);

sprintf(g->ThrSetp2, "%s", sp2);

Form2->Label11->Caption = sp2;

PagesDlg->Label13->Caption = sp2;

if(g->iThread2Off == true)

{

WriteMeasure2 *Thread = new WriteMeasure2 (false);

Thread->Resume();

g->iThread2Off = false;

}

}

else

{

Form3->Memo1->Lines->Add("Setpoint not correctly"

"written..");

Form3->Memo1->Lines->Add("------------------"

"-----------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

else

{

Form3->Memo1->Lines->Add("Enter value since 1 to 100..");

}

}

else

{

Page 162: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (PagesDlg) PagesDlg.cpp

162

Form3->Memo1->Lines->Add("Parameter setpoint could"

" not be written (no comunication)");

}

}

//---------------------------------------------------------------------------

void __fastcall TPagesDlg::Button3Click(TObject *Sender)

{

float percent = 0;

if(g->bComOpened)

{

percent = PagesDlg->Edit6->Text.ToDouble();

if((percent >= 0)&&(percent <= 100))

{

iSetpoint = ((32000 * percent)/100);

itoa(iSetpoint, sSetpoint, 10);

Form3->WriteParameterDirect(5,1, 1, 2, 0,

700, sSetpoint, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

Form2->Visible = true;

Form3->Memo1->Lines->Add("Setpoint correctly written..");

Form3->Memo1->Lines->Add("-----------------------“

”------------");

Form2->Label16->Caption = 5;

sprintf(sp3, "%.2f", percent);

sprintf(g->ThrSetp3, "%s", sp3);

Form2->Label17->Caption = sp3;

PagesDlg->Label18->Caption = sp3;

if(g->iThread3Off == true)

{

WriteMeasure3 *Thread = new WriteMeasure3 (false);

Thread->Resume();

g->iThread3Off = false;

}

}

else

{

Form3->Memo1->Lines->Add("Setpoint not correctly"

"written..");

Form3->Memo1->Lines->Add("------------------"

"-----------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

else

{

Form3->Memo1->Lines->Add("Enter value since 1 to 100..");

}

}

else

{

Form3->Memo1->Lines->Add("Parameter setpoint could"

" not be written (no comunication)");

}

}

//---------------------------------------------------------------------------

void __fastcall TPagesDlg::Button4Click(TObject *Sender)

{

float percent = 0;

Page 163: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (PagesDlg) PagesDlg.cpp

163

if(g->bComOpened)

{

percent = PagesDlg->Edit8->Text.ToDouble();

if((percent >= 0)&&(percent <= 100))

{

iSetpoint = ((32000 * percent)/100);

itoa(iSetpoint, sSetpoint, 10);

Form3->WriteParameterDirect(6,1, 1, 2, 0,

200, sSetpoint, iErrVal, bytStatus, sErrVal);

if(strlen(sErrVal) == 0)

{

Form2->Visible = true;

Form3->Memo1->Lines->Add("Setpoint correctly written..");

Form3->Memo1->Lines->Add("-----------------------“

”------------");

Form2->Label22->Caption = 6;

sprintf(sp3, "%.2f", percent);

sprintf(g->ThrSetp4, "%s", sp4);

Form2->Label23->Caption = sp4;

PagesDlg->Label20->Caption = sp4;

if(g->iThread4Off == true)

{

WriteMeasure4 *Thread = new WriteMeasure4 (false);

Thread->Resume();

g->iThread4Off = false;

}

}

else

{

Form3->Memo1->Lines->Add("Setpoint not correctly"

"written..");

Form3->Memo1->Lines->Add("------------------"

"-----------------");

Form3->GroupBox4->Visible = true;

Form3->Memo2->Lines->Add(iErrVal);

Form3->Memo3->Lines->Add(sErrVal);

}

}

else

{

Form3->Memo1->Lines->Add("Enter value since 1 to 100..");

}

}

else

{

Form3->Memo1->Lines->Add("Parameter setpoint could"

" not be written (no comunication)");

}

}

//---------------------------------------------------------------------------

void __fastcall TPagesDlg::Initial(void)

{

PagesDlg->Edit2->Clear();

PagesDlg->Edit4->Clear();

PagesDlg->Edit6->Clear();

PagesDlg->Edit8->Clear();

PagesDlg->Label4->Caption = " ---";

PagesDlg->Label5->Caption = " ---";

PagesDlg->Label13->Caption = " ---";

PagesDlg->Label8->Caption = " ---";

Page 164: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Plantilla secundaria (PagesDlg) PagesDlg.cpp

164

PagesDlg->Label18->Caption = " ---";

PagesDlg->Label10->Caption = " ---";

PagesDlg->Label20->Caption = " ---";

PagesDlg->Label16->Caption = " ---";

}

//---------------------------------------------------------------------------

void __fastcall TPagesDlg::Button5Click(TObject *Sender)

{

Form2->Series1->Active = false;

g->iThread1Off = true;

}

//---------------------------------------------------------------------------

void __fastcall TPagesDlg::Button6Click(TObject *Sender)

{

Form2->Series2->Active = false;

g->iThread2Off = true;

}

//---------------------------------------------------------------------------

void __fastcall TPagesDlg::Button7Click(TObject *Sender)

{

Form2->Series3->Active = false;

g->iThread3Off = true;

}

//---------------------------------------------------------------------------

void __fastcall TPagesDlg::Button8Click(TObject *Sender)

{

Form2->Series4->Active = false;

g->iThread4Off = true;

}

//---------------------------------------------------------------------------

Page 165: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Instruction manual

Operation instructions digital Mass Flow / Pressure instruments

parameters and properties

Doc. no.: 9.17.023I Date: 26-10-2005

ATTENTION Before installing and operating the instrument it is recommended that this instruction be read. Not following the guidelines could result in personal injury and/or damage to the equipment.

Page 166: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 2 9.17.023

SCOPE OF THIS MANUAL This manual covers the operation part of digital massflow / pressure instruments for gases or liquids. It describes the parameters and their properties needed for (digital) operation. More information can be found in other documents. Multibus instruments have modular instruction manuals consisting of: - General instructions digital Mass Flow / Pressure instruments

laboratory style / IN-FLOW (document nr. 9.17.022) - General instructions CORI-FLOW (document nr. 9.17.031) - General instructions digital LIQUI-FLOW L30 (document nr. 9.17.044) - Operation instructions digital instruments (document nr. 9.17.023)

- Fieldbus/interface descriptions.

- FLOW-BUS interface (document nr. 9.17.024) - PROFIBUS–DP interface (document nr. 9.17.025) - DeviceNet interface (document nr. 9.17.026) - RS232 interface with FLOW-BUS protocol (document nr. 9.17.027) - Modbus interface (document nr. 9.17.035) special request

Page 167: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 3 9.17.023

TABLE OF CONTENTS 1 DIGITAL INSTRUMENT.........................................................................................................................5

1.1 General ..........................................................................................................................................5 1.2 Functional block diagram ................................................................................................................6 1.3 Calibration with mathematical functions...........................................................................................6

1.3.1 General information .................................................................................................................6 1.3.2 Polynomial functions ................................................................................................................6 1.3.3 General form of a polynomial function ......................................................................................6 1.3.4 Polynomial function of sensor signal ........................................................................................7 1.3.5 Look-up tables .........................................................................................................................7 1.3.6 General form of 2-dimensional look-up tables...........................................................................7 1.3.7 Look-up table for sensor signal ................................................................................................7 1.3.8 Look-up tables with temperature compensation........................................................................7 1.3.9 General form of 3-dimensional look-up tables...........................................................................8 1.3.10 Look-up table with temperature compensation for sensor signal ...............................................8 1.3.11 Using mathematical functions at a digital instrument.................................................................8

1.4 Multi Fluid / Multi Range instruments...............................................................................................9 1.4.1 General information .................................................................................................................9 1.4.2 Differences between traditional and MFMR instruments ...........................................................9

2 PARAMETERS AND PROPERTIES ....................................................................................................10 2.1 Measured value (measure) ...........................................................................................................12 2.2 Setpoint ........................................................................................................................................12 2.3 Setpoint slope...............................................................................................................................12 2.4 Analog input .................................................................................................................................12 2.5 Setpoint/control modes .................................................................................................................13

2.5.1 Dual interface operation.........................................................................................................13 2.5.2 Master/slave (ratio) control.....................................................................................................14 2.5.3 Tuning, test and calibration ....................................................................................................14

2.6 Fluid number.................................................................................................................................14 2.7 Fluid name....................................................................................................................................14 2.8 Valve output .................................................................................................................................15 2.9 Temperature.................................................................................................................................15

3 DIRECT READING PARAMETERS .....................................................................................................16 3.1 Sensor type ..................................................................................................................................16 3.2 Capacity (100%) ...........................................................................................................................16 3.3 Capacity 0% .................................................................................................................................16 3.4 Fmeasure .....................................................................................................................................16 3.5 Fsetpoint.......................................................................................................................................17 3.6 Capunit.........................................................................................................................................17 3.7 Capacity unit string .......................................................................................................................17

4 IDENTIFICATION PARAMETERS .......................................................................................................18 4.1 Serialnumber ................................................................................................................................18 4.2 Modelnumber................................................................................................................................18 4.3 Firmware version ..........................................................................................................................18 4.4 Usertag.........................................................................................................................................18 4.5 Manufacturer config ......................................................................................................................18 4.6 Identnumber .................................................................................................................................19 4.7 Device type...................................................................................................................................19

5 ALARM/STATUS PARAMETERS ........................................................................................................20 5.1 Alarminfo ......................................................................................................................................20 5.2 Status...........................................................................................................................................20 5.3 Alarm mode ..................................................................................................................................20 5.4 Alarm maximum limit.....................................................................................................................21 5.5 Alarm minimum limit......................................................................................................................21 5.6 Alarm output mode .......................................................................................................................21 5.7 Alarm setpoint mode.....................................................................................................................21 5.8 Alarm new setpoint .......................................................................................................................21 5.9 Alarm delay time...........................................................................................................................21 5.10 Reset alarm enable ...................................................................................................................22 5.11 Using an alarm (examples)........................................................................................................22

Page 168: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 4 9.17.023

6 COUNTER PARAMETERS..................................................................................................................24 6.1 Counter value ...............................................................................................................................24 6.2 Counter mode...............................................................................................................................24 6.3 Counter setpoint mode..................................................................................................................24 6.4 Counter new setpoint ....................................................................................................................24 6.5 Counter limit .................................................................................................................................24 6.6 Counter output mode ....................................................................................................................24 6.7 Counter unit..................................................................................................................................25 6.8 Counter unit string ........................................................................................................................25 6.9 Using a counter (example) ............................................................................................................25

7 SPECIAL PARAMETERS ....................................................................................................................26 7.1 Reset............................................................................................................................................26 7.2 Init/reset (key-parameter)..............................................................................................................26 7.3 Wink.............................................................................................................................................26

8 CONTROLLER PARAMETERS ...........................................................................................................27 8.1 Controller......................................................................................................................................27 8.2 RespOpen0 ..................................................................................................................................27 8.3 ContrResp ....................................................................................................................................27 8.4 RespStable...................................................................................................................................27 8.5 PIDKp...........................................................................................................................................27 8.6 PIDTi ............................................................................................................................................27 8.7 PIDTd...........................................................................................................................................27 8.8 TdsUp...........................................................................................................................................28 8.9 TdsDn...........................................................................................................................................28 8.10 ExpSmooCon............................................................................................................................28 8.11 ExpSmooAd ..............................................................................................................................28

9 SPECIAL INSTRUMENT FEATURES..................................................................................................29 9.1 Zero (mass flow instruments only).................................................................................................29

9.1.1 Zeroing with the Micro-switch.................................................................................................29 9.1.2 Zeroing with digital communication.........................................................................................29

9.2 Restore parameter settings...........................................................................................................30 10 MANUAL INTERFACE: micro-switch and LED’s ...............................................................................31

10.1 General .....................................................................................................................................31 10.2 Readout/change bus-address/MAC-ID and baudrate .................................................................34

10.2.1 Set instrument to default installation address/MAC-ID: ...........................................................34 10.2.2 Readout bus-address/MAC-ID and baudrate: .........................................................................34 10.2.3 Change bus-address/MAC-ID and baudrate: ..........................................................................35

11 JUMPER SETTINGS MULTIBUS INSTRUMENTS ...........................................................................36 12 TESTING AND DIAGNOSTICS........................................................................................................37

Page 169: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 5 9.17.023

1 DIGITAL INSTRUMENT

1.1 General A digital instrument of Bronkhorst High-Tech is a Mass Flow or Pressure Meter/Controller which is equipped with a digital electronic multibus PCB. These electronics consist of a micro-controller with peripheral circuitry for measuring, controlling and communication. The flow/pressure signal, is measured and digitized directly at the sensor and processed by means of the internal software (firmware). Measured and processed values can be output through the analog interface or through the digital communication line (RS232 or optional fieldbus interface). For controllers the setting for the actuator is calculated by the firmware. Setpoint can be given through the analog interface or through the digital communication line. Digital instruments have many parameters for settings for signal processing, controlling and many extra features and therefore they have a wide range in use. Reading and changing of these settings is only possible through fieldbus or RS232, except for measured value, setpoint and valve output, which is also possible through the analog interface. (Depending on parameter setting) See operating instructions of Readout and Control module or PC-program how to read/change parameter values of digital instruments. Digital instruments can be operated by means of:

1. Analog interface (0...5Vdc/0...10Vdc/0...20mA/4...20mA) 2. RS232 interface (connected to COM-port by means of special cable on 38400 Baud) 3. FLOW-BUS 4. PROFIBUS-DP 5. DeviceNet 6. Modbus (special request)

Option 1 and 2 are always present on multibus instruments. An interface to any available fieldbus is optional. Operation via analog interface, RS232 interface and an optional fieldbus can be performed at the same time. A special parameter called “control mode” indicates to which setpoint the controller should listen: analog or digital (via fieldbus or RS232). The RS232 interface behaves like a FLOW-BUS interface. When using more interfaces at the same time, reading can be done simultaneously without problems. When changing a parameter value, the last value send by an interface will be valid. Also the micro push-switch switch and the LED’s on top of the instrument can be used for manual operation of some options. The green LED will indicate in what mode the instrument is active. The red LED will indicate error/warning situations.

Page 170: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 6 9.17.023

1.2 Functional block diagram

DMFC/DEPC functional block diagram

1.3 Calibration with mathematical functions

1.3.1 General information A standard calibrated digital instrument has a linearized transfer function within 1% F.S. accuracy. This means that real flow/pressure is proportional to the output and setpoint signal (0-5 V, 0-10 V, 0-20 mA or 4-20 mA) within 1% of the full scale range. Depending on instrument and sensor type an instrument output signal is calculated with one of the following mathematical methods:

• polynomial function • look-up table (2 dimensions) • look-up table with temperature compensation (3 dimensions)

All these methods are methods of approximation which mathematically describes a continues transfer function to calculate a flow/pressure out of the sensor signal of the device.

1.3.2 Polynomial functions By means of a few samples, a polynomial function can be obtained. After determining the polynomial function, the original calibration points and an infinite amount of values in between, can be calculated with high accuracy. In a system where pressure- and/or flow meters and -controllers should be readout and set with high accuracy, these polynomial functions often are used for approximation of their transfer function.

1.3.3 General form of a polynomial function The general form of a polynomial function of the n-nd degree is as follows:

nn XaXaXaXaay ⋅++⋅+⋅+⋅+= .....3

32

210

Where 'a0' to 'an' are polynomial parameters, which can be calculated. When you have 'n + 1' measure-points, they can be approximated by means of a 'nnd' degree polynomial function.

Microcontroller

ControlMeasure

Analog Output

DACSwitch LED's

Analog Input

ADC

Setpoint

Slope

Difference

PID controllerDifferentiator

Linearisation

Filter

ADC

Sensor Valve

DAC

Digitalcommunication

Page 171: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 7 9.17.023

1.3.4 Polynomial function of sensor signal By means of a calibration at Bronkhorst High-Tech B.V. several measured calibration points will be used to obtain a polynomial function. The form of this function of the 3rd degree is:

32 XdXcXbaY ⋅+⋅+⋅+= In which 'Y' is the normalized measured value (0-100%) and 'X' is the value of the sensor signal. Characters 'a - d' are polynomial parameters, which can be obtained by a mathematical program. The polynomial parameters are calculated in such a way that the fit error between the calibration points and the polynomial function is minimized.

1.3.5 Look-up tables In certain cases it is not possible to describe a sensor signal curve by means of a polynomial function of the 3rd degree. In those cases a look-up table is a good alternative. A look-up table is a table filled with calibration points. The embedded software inside the digital instrument calculates a continues smooth function which fits exactly through these calibration points. Using this method it is possible to describe any monotone rising sensor signal curve with high accuracy.

1.3.6 General form of 2-dimensional look-up tables The general form of a 2-dimensional look-up table is as follows:

index X Y

0 x0 y0

1 x1 y1

2 x2 y2

3 x3 y3

… … …

n xn yn

In which 'Y' is the normalized measured value (0-100%), 'X' is the value of the sensor signal and ‘index’ represents the position in the look-up table.

1.3.7 Look-up table for sensor signal A digital instrument with look-up table capability for sensor signal can store look-up tables with at maximum 21 calibration points.

1.3.8 Look-up tables with temperature compensation Almost all flow and pressure sensors are temperature sensitive. For most of these sensors it is easy to decrease the temperature sensitivity to acceptable level by means of easy methods. This is called ‘intrinsic temperature compensation’. For some sensor types intrinsic temperature compensation is hard to establish. In those cases Bronkhorst uses a 3-dimensional look-up table with temperature compensation in its instruments. To compensate the measured sensor signal for the actual temperature, in those instruments a temperature sensor is added inside the flow or pressure sensor. The temperature signal is used to compensate the flow or pressure sensor signal to the correct value.

Page 172: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 8 9.17.023

1.3.9 General form of 3-dimensional look-up tables The general form of a 3-dimensional look-up table is as follows:

In which 'T' is the calibration temperature, 'Y' is the normalized measured value (0-100%), 'X' is the value of the sensor signal and ‘index’ represents the position in the look-up table.

1.3.10 Look-up table with temperature compensation for sensor signal By means of a calibration at two different temperatures several measured calibration points will be used to obtain two look-up tables. Bronkhorst uses climatic chambers and fully automated calibration systems for calibration of the sensor signal. The actual measurement is based on both sensor and temperature measurement.

1.3.11 Using mathematical functions at a digital instrument Digital instruments are capable of storing 8 different fluid calibrations. Parameters for these calibrations are stored inside the instrument and can be changed through the fieldbus or the RS232 connection by means of a PC-program or a digital Readout and Control module. Factory calibration parameters are secured and can not be changed unless you have special rights to do this. Selection of another fluid is part of operation and therefore not secured. Digital instruments will need at least 1 fluidset of calibration parameters for operation.

Page 173: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 9 9.17.023

1.4 Multi Fluid / Multi Range instruments

1.4.1 General information Multi Fluid / Multi Range (MFMR) instruments are calibrated for standard ranges which can easily be configured for other fluids and ranges. This applies for both Bronkhorst and its customers. Changing fluid and range can be performed by means of a simple computer program through the RS232 connection of an instrument. The program can convert the primal calibration curve inside the instrument to the selected fluid and range.

1.4.2 Differences between traditional and MFMR instruments In traditional digital instruments the parameters capacity, density, unittype, unitname etc are static parameters and do not harm the behavior of the instrument. These parameters are used by for example read out units or PC-software to convert the measured value in percentage of the maximum output to a real value in a certain unit. However in MFMR instruments these parameters are dynamic. Examples: An instrument is configured for 2000 mln/min Air.

Changing the unit name from ‘mln/min’ to ‘ln/min’ effects that the capacity automatically changes from ‘2000’ to ‘2’. The 100% output is not affected. Changing the capacity from ‘2000’ to ‘1000’ effects that the instruments full scale range (100% output) changes to 1000 mln/min. The instrument is reranged.

Page 174: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 10 9.17.023

2 PARAMETERS AND PROPERTIES Digital instruments consist of a microcontroller with several processes running simultaneously for: Measuring sensor value Reading analog input signal Digital signal processing Driving valve Setting analog output signal Communication with world outside Memory handling Each process needs its own specific parameters in order to function correctly. Most parameter values are accessible through the available interface(s) to influence the process behaviour. Many parameters may be controlled by end-users for more flexible use of the instruments. Bronkhorst High-Tech offers special software for these purposes (in combination with FLOWDDE): FlowView : Windows application for operation of max. 8 instruments FlowPlot : Windows application for adjustment of controllers (Value versus time on screen) End-users are also free to use their own software using either: FLOWDDE : DDE-server for data exchange with Microsoft Windows applications FLOWB32.DLL : Dynamic Link Library for Microsoft Windows applications RS232 interface : Protocol description for instructions with ASCII or Binary HEX telegrams Each parameter has its own properties, like data-type, size, reading/writing allowance, security. In general: all parameters used for operation of instruments are free to be used by end-users. (eg.: measure, setpoint, control mode, slope, fluid number, alarm and counter) all parameter for settings of instruments are meant for BHT-service personnel only. (eg.: calibration settings, controller settings, identification, network/fieldbus settings) Parameters for settings are secured. They can be read-out, but can not be changed without knowledge of special key-parameters and knowledge of the instrument. FLOWDDE parameter numbers: Reading/changing parameter values via FLOWDDE offers the user a different interface to the instrument. Besides the application name: ‘FLOWDDE’ there is only need of: topic, used for channel number: ‘C(X)’ item, used for parameter number: ‘P(Y)’ A DDE-parameter number is a unique number in a special FLOWDDE instruments/parameter database and not the same as the parameter number from the process on an instrument. Node-address and process number will be translated by FLOWDDE to a channel number. When not using FLOWDDE for communication with FLOW-BUS, each parameter value needs: node-address of instrument on FLOW-BUS process number on instrument parameter number on instrument All parameter information needed can be found in the parameter table(s) of FLOWDDE.MDB.

Page 175: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 11 9.17.023

Following paragraphs will give short descriptions of how to use parameters for operation. For a more complete description of the parameters the document “917030 FLOWPLOT” can be used. The second line after the parameter name gives some additional information about the parameter. An explanation of the line is: Valve output [unsigned long, RW, secured, 0…16777215, DDEpar. = 55, Proces/par. = 114/1] unsigned long = one of the datatypes below.

Unsigned char 1 byte Unsigned int 2 bytes, MSB first Unsigned long 4 bytes, MSB first Float 4 bytes IEEE 32-bit single precision numbers, MSB first Unsigned char [] array of characters (string)

RW = R - parameter can be read, W – parameter can be written. Secured = Parameter is secured. If omitted parameter is not secured. 0…16777215 = Parameter range. DDEpar. = 55 = FlowDDE parameter number Process/par. = 114/1 = Process number / process parameter number Another example is: Fluidname [unsigned char[10], RW,secured,a...Z, 0...9, DDEpar. = 25, Proces/par. = 1/17] unsigned char[10] = Datatype Unsigned char[], array of characters. [10] = number of characters. RW = R - parameter can be read, W – parameter can be written. Secured = Parameter is secured. If omitted parameter is not secured. a...Z = characters which can be used in the string 0...9 = numbers which can be used in the string DDEpar. = 25 = FlowDDE parameter number Process/par. = 1/17 = Process number / process parameter number

Page 176: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 12 9.17.023

Normal operation parameters

2.1 Measured value (measure) [unsigned int, R ,0...41942, DDEpar. = 8, Proces/par. = 1/0] Depending on the type of instrument, measured value indicates the amount of mass flow or pressure metered by the instrument. Sensor signals at digital instruments will be digitized at the sensor bridge by means of highly accurate AD-converters, using at least 16 bits. Digitized signals will be internally processed by the microcontroller using floating point notation. The sensor signal will be differentiated, linearized and filtered. At the digital output measured values will be presented as an unsigned integer in the range of 0...65535. For Unipolair mode the signal of 0...100% will be presented in a range of 0...32000. For the instruments, maximum signal to be expected is 131.07 %, which is: 41942. 0 32000 41942 65535

Not used 0% 100% 130.07% For Bipolair mode the signal of 0...100% will be presented in a range of 0...32000. Maximum signal is 131.07 %, which is: 41942, minimum signal is -73.73 %, which is 41943 0 32000 41942 41943 65535

0% 100% 130.07% -73.73% -0.003%

2.2 Setpoint [unsigned int, RW,0...32000, DDEpar. = 9, Proces/par. = 1/1] Setpoint is used to tell the controller of an instrument what the wanted amount of mass flow or pressure is. Signals are in the same range as the measured value, only setpoint is limited between 0 and 100 %. Setpoint can be given either via optional fieldbus or RS232 or via analog interface. Parameter control mode selects the active setpoint for the controller. See that paragraph for more detailed information.

2.3 Setpoint slope [unsigned int, RW,0...30000, DDEpar. = 10, Proces/par. = 1/2] Digital instruments can establish a smooth setpoint control using the setpoint slope time. The setpoint will be linear increased in time from old setpoint to new setpoint value. A value between 0 and 3000 seconds, with a resolution of 0.1 seconds, can be given to set the time for the integrator on the setpoint signal. Setpoint will reach its endvalue after

=⋅−slope

100oldspnewsp

seconds

Example; When slope = 10 seconds how long will it take to go from 20% to 80%?

610100

2080 =⋅− seconds

2.4 Analog input [unsigned int, R ,0...65535, DDEpar. = 11, Proces/par. = 1/3] Depending on the parameter value of analog mode, this signal converts either 0..5Vdc / 0..10Vdc / 0..20mA / 4..20mA. Analog input signals (digitized) are in the same range as measured values (0...32000 = 0...100%). This input can be used to give setpoint or slave factor, depending on the value of control mode.

Page 177: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 13 9.17.023

2.5 Setpoint/control modes [unsigned char, RW,0...255, DDEpar. = 12, Proces/par. = 1/4] For switching between different functions in use of a digital meter or controller several modes are available. Output signals (sensor signal) on both analog and fieldbus interface are available at the same time. Table 1: Overview setpoint/control modes Nr Mode Instrument action Setpoint source Master source Slave factor

source 0 BUS/RS232 Controlling BUS/RS232 1 external input Controlling analog input 2 FLOW-BUS/

RS232 slave controlling as slave from other instrument on bus

Master/slave process

FLOW-BUS FLOW-BUS/ RS232

3 valve close close valve 4 controller idle stand-by on

BUS/RS232

5 test mode testing enabled (BHT only)

6 tuning mode tuning enabled (BHT only)

7 setpoint 100% controlling on 100% 100% 8 valve purge purge valve 9 calibration mode calibration enabled

(BHT only)

10 ext input slave controlling as slave from other instrument on analog input

Master/slave process

analog input FLOW-BUS/ RS232

12 setpoint 0% controlling on 0% 0% 13 FLOW-BUS

slave external input

controlling as slave from other instrument on bus, slavefactor is set with signal on analog input

Master/slave process

FLOW-BUS analog input

18 RS232 Controlling RS232 note: analog input= external input= pin 3 on DB 9 connector.

BUS = any available fieldbus

2.5.1 Dual interface operation When operating a controller (reading measured value and sending setpoint) for proper operation it is important that the controller gets its setpoint from the right source. Setpoints may come from different sources: analog input, fieldbus interface or RS232 or may be overruled by close valve or open valve (purge) commands. Therefore it is important to know what is the setpoint source of the controller. This can be set by means of parameter controlmode (parameter 12). In some cases it is possible that the setpoints may come from 2 sources at the same time. The last send setpoint will be valid and send to the controller. This is the case in controlmode = 0, when setpoints may come through any fieldbus interface or RS232. However, there could be situations where control over the instrument seems impossible. This is the case when the instrument comes into a safe-state e.g. when fieldbus communication is disturbed or disconnected. Valve will be forced to a safe state automatically: closed (NC) or fully open (NO). In case you want to get control back via RS232 operation, you have to change the controlmode. When controlmode gets value 18, safe state will be overruled and sending setpoints via RS232 interface will have effect on the controller again.

Page 178: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 14 9.17.023

2.5.2 Master/slave (ratio) control In master/slave or ratio control the setpoint of an instrument is related to the output signal of another instrument. Setpoint (slave) = Output signal (master) * slave factor/100% Digital instruments offer possibilities for master/slave control via the FLOW-BUS. The output value of any instrument connected to the FLOW-BUS is automatically available to all other instruments (without extra wiring). When master/slave control is wanted the instrument can be put in control mode 2 or 13, depending on how the slave factor should be set (see table above). Through FLOW-BUS an instrument can be told that it should be a slave, who should be its master and what should be the slave factor to follow the master with. It is possible to have more masters and more slaves in one system. A slave can also be a master itself for other instruments. Notes: These options are available for FLOW-BUS or RS232 instruments only. Output signals from master can be received via FLOW-BUS only. Slave factors can also be changed via RS232. Master/slave is ment here for controlling purposes and has nothing to do with master and slave behaviour on fieldbus networks.

2.5.3 Tuning, test and calibration These are special modes to prepare the instrument for either a tuning, test or calibration action. These modes are used by Bronkhorst High-Tech service personnel only and are not meant for customer use. Putting the instrument in this mode, will disable normal control. The instrument will wait until: 1. Control mode will change again. 2. Instrument receives command (secured parameter) via bus which item should be tuned, tested or

calibrated. When ready perfoming the wanted action the instrument will return to its previous control mode again.

2.6 Fluid number [unsigned char, RW,0...7, DDEpar. = 24, Proces/par. = 1/16] Fluid number is a pointer to the set of calibration parameters. For each fluid (gas or liquid) several parameters get values in order to store the calibration for a specific fluid. This increases accuracy. Fluid number is an unsigned char parameter (ucFluidnr) in a range of 0...7, where 0 = fluid1 and 7=fluid8. Up to 8 fluids can be stored in one instrument. Default value = 0 (fluid 1).

2.7 Fluid name [unsigned char[10], RW,secured,a...Z, 0...9, DDEpar. = 25, Proces/par. = 1/17] Fluid name consists of the name of the fluid of the actual selected fluidnumber. Up to 10 characters are available for storage of this name. Parameter is secured and read-only for normal users. During calibration of the instrument this parameter will get its value. Default value is “Air”.

Page 179: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 15 9.17.023

2.8 Valve output [unsigned long, RW,secured,0...16777215, DDEpar. = 55, Proces/par. = 114/1] This parameter is the signal coming out of the controller, going to the DAC for driving the valve. 0...16777215 corresponds with approximately 0...265mAdc for a 60 Ohm .valve coil. Maximum output voltage is approximately 14V.

2.9 Temperature [float, RW,,-250..500, DDEpar. = 142, Proces/par. = 33/7] This parameter shows the temperature of the tubes in the Cori-Flow. It is not used in other instruments.

Page 180: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 16 9.17.023

3 DIRECT READING PARAMETERS

3.1 Sensor type [unsigned char, RW,secured,0...4, DDEpar. = 22, Proces/par. = 1/14] Unsigned char used to select proper set of units for certain sensor, together with Counter unit. Default settings is 3.

Value Description Controller/Sensor 0 pressure ( no counting allowed) 1 liquid volume 2 liquid/gas mass 3 gas volume 4 other sensor type (no counting allowed)

Controller

128 pressure ( no counting allowed) 129 liquid volume 130 liquid/gas mass 131 gas volume 132 other sensor type (no counting allowed)

Sensor

3.2 Capacity (100%) [float, RW,secured,1E-10...1E+10, DDEpar. = 21, Proces/par. = 1/13] Capacity is the maximum value (span) at 100% for direct reading in sensor base units. The base unit will be determined by ‘sensor type’. For each fluid(number) capacity will be stored seperately.

3.3 Capacity 0% [float, RW,secured,-1E-10...1E+10, DDEpar. = 183, Proces/par. = 33/22] This is the capacity zero point (offset) for direct reading in sensor base units. The base unit will be determined by ‘sensor type’. This capacity 0% is the same for all stored fluid(number)s.

3.4 Fmeasure [float,R, 1E-10...1E+10, DDEpar. = 205, Proces/par. = 33/0] Floating point version of variable measure (see 2.1). The user will read-out the measured value in the capacity and capacity unit for which the instrument has been calibrated. These settings depend on variables: capacity, capunit, sensortype and capacity0%. Fmeasure is a read-only float on (FLOW-BUS) proc 33, par 0. Value is calculated as follows: proc33,par0 proc1,par 0 proc1,par13 proc33,par 22 proc33,par22

fmeasure = ((measure/32000)*(capacity-capacity0%)) + capacity0% The value is in units as described in parameter capunitstr (proc 1, par 31).

Page 181: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 17 9.17.023

3.5 Fsetpoint [float,RW, 1E-10...1E+10, DDEpar. = 206, Proces/par. = 33/3] With the use of parameter fmeasure, also fsetpoint is often needed. This parameter is R/W as variable in FLOW-BUS proc33, par3. Setpoint can be operated via 2 parameters at the same time. One parameter is setpoint (see 2.1), a short integer. The other one is fsetpoint, a float (in the capacity in which the instrument was calibrated (see also fmeasure). Last received setpoint by the instrument will be valid. It is not advised to use setpoint and fsetpoint at the same time. Choose either one or the other. Relation between setpoint and fsetpoint is calculated as follows: proc1,par1 proc33,par3 proc33,par22 proc1,par13 proc33,par22 setpoint = ((fsetpoint – capacity0% ) / (capacity - capacity0%)) * 32000 Note: Reading back actual values of fsetpoint is also possible. When a value has been send to proc1, par1 (integer setpoint), then this will be converted to the float setpoint for direct reading in the right capacity and unit.

3.6 Capunit [unsigned char, RW,secured,0...9, DDEpar. = 23, Proces/par. = 1/15] Capacity unit is a pointer to select an actual readout unit (see list below). For FLOW-BUS instruments all capacity units are available for direct reading. Other fieldbusses (eg. DeviceNet) are limited in options for direct reading facilities. Overview of capacity-unit strings in digital instruments and E-7000 for analog instruments: capunit

Sensor Type

0 1 2 3 4 5 6 7 8 9

0 bar mbar psi kPa cmH2O cmHg atm kgf/cm2 unused unused 1 l/min ml/h ml/min l/h mm3/s cm3/min unused unused unused unused 2 kg/h kg/min kg/s g/h g/min g/s mg/h mg/min mg/s unused 3 ln/min mln/h mln/min ln/h m3n/h mls/min mls/h ls/min ls/h m3s/h 4 usrtype usrtype usrtype unused Unused unused unused unused unused unused 5 °C °F K unused Unused unused unused unused unused unused 6 hour minute seconds unused Unused unused unused unused unused unused 7 kHz Hz rpm unused Unused unused unused unused unused unused 8 kg g mg ug Unused unused` unused unused unused unused 9 g/l kg/l g/m3 kg/m3 Unused unused unused unused unused unused

name description sensortype Indicator for type of sensor in instrument in relation with a list of units for direct

reading capunit Points to wanted capacity unit for direct reading in list of available units Example: If you want to readout your instrument in ln/min, then make sure parameter ‘sensortype’ has value 3 and parameter ‘capunit’ has value 0. By means of parameter ‘capunitstr’ the unit string can read-back as a 7 character string.

3.7 Capacity unit string [unsigned char[7], RW,secured, DDEpar. = 129, Proces/par. = 1/31] Parameter ‘capunitstr’ consisting of 7 characters (string) with selected unit out of table. Can only be written when sensortype = 4: usertype, userunit string of 7 chars can be send.

Page 182: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 18 9.17.023

4 IDENTIFICATION PARAMETERS

4.1 Serialnumber [unsigned char[20], RW,secured, DDEpar. = 92, Proces/par. = 113/3] This parameter consists of a maximum 20-byte string with instrument serial number for identification. Example: “M0202123A”

4.2 Modelnumber [unsigned char[14], RW,secured, DDEpar. = 91, Proces/par. = 113/2] Bronkhorst High-Tech instrument model number information string.

4.3 Firmware version [unsigned char[5], R, DDEpar. = 105, Proces/par. = 113/5] Revision number of firmware. Eg. “V6.01”

4.4 Usertag [unsigned char[13], RW,secured, DDEpar. = 115, Proces/par. = 113/6] User definable alias string. Maximum 13 characters allow the user to give the instrument his own tagname. It is advised here to limit the name up to 7 characters when using E-7000 readout and control modules. These modules can display the tagname of an instrument only up to 7 characters. Eg.: “Room1s6”

4.5 Manufacturer config [unsigned char[16], RW,secured, DDEpar. = 93, Proces/par. = 113/4] Digital instrument manufacturing configuration information string. This string can be used by Bronkhorst High-Tech to add extra information to the model number information.

Page 183: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 19 9.17.023

4.6 Identnumber [unsigned char, RW,secured,0...255, DDEpar. = 175, Proces/par. = 113/12] Bronkhorst High-Tech (digital) device/instrument identification number (pointer). See list below:

Value Description 1 RS232/FLOW-BUS interface 2 PC(ISA) interface 3 ADDA4 (4 channels) 4 R/C-module, 32 channels 5 T/A-module 6 ADDA1: 1 channel ADDA converter module 7 DMFC: digital mass flow controller 8 DMFM: digital mass flow meter 9 DEPC: digital electronic pressure controller

10 DEPM: digital electronic pressure meter 11 ACT: single actuator 12 DLFC: digital liquid flow controller 13 DLFM: digital liquid flow meter 14 DSCM-A: digital single channel module for analog instruments 15 DSCM-D: digital single channel module for digital instr. 16 FRM: FLOW-BUS rotor meter (calibration-instrument) 17 FTM: FLOW-BUS turbine meter (calibration-instrument) 18 FPP: FLOW-BUS piston prover/tube (calibration-instrument) 19 F/A-module: special version of T/A-module 20 DSCM-E: evaporator controller module (single channel) 21 DSCM-C: digital single channel module for calibrators 22 DDCM-A: digital dual channel module for analog instruments 23 DMCM-D: digital multi channel module for digital instruments 24 PRODPS: FLOW-BUS/PROFIBUS DP-slave interface 25 FCM: FLOW-BUS Coriolis meter 26 FBI: FLOW-BUS Balance Interface 27 CoriFC: Cori-Flow Controller 28 CoriFM: Cori-Flow Meter

4.7 Device type [unsigned char[6], R, DDEpar. = 90, Proces/par. = 113/1] Devicetype information string: String value in max. 6 chars of descriptions in table above.

Page 184: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 20 9.17.023

5 ALARM/STATUS PARAMETERS

5.1 Alarminfo [unsigned char, R,0...255, DDEpar. = 28, Proces/par. = 1/20] This parameter contains 8 bits with status information about some (alarm) events in the instrument.

Bit Meaning 0 0 – no error, 1 – Error message in alarm error status register 1 0 – no error, 1 – Warning message in alarm warning status register 2 0 – no error, 1 – Minimum alarm (sensor signal < minimum limit) 3 0 – no error, 1 – Maximum alarm (sensor signal > maximum limit) 4 0 – no error, 1 – Batch counter has reached its limit 5 0 – no error, 1 – This bit only: Power-up alarm (probably power dip occurred)

Together wit bit 2 or bit 3: Response alarm message (setpoint-measure too much difference) (bit 2 or bit 3 indicate if difference is positive or negative)

6 0 – no error, 1 – Master/slave alarm: master output signal not received or slave factor out of limits (> 100%)

7 0 – no error, 1 – Hardware alarm: check hardware

5.2 Status [unsigned char, R,,0...255] This parameter is a special byte for monitoring communication between converter and instruments (via FLOW-BUS). It contains 8 bits with information about certain (alarm) events. This parameter is unlike the other parameters not a PROPAR parameter and can not be read via FLOW-BUS but only via PROFIBUS.

Bit Meaning 0 0 - no error in communication with channel, 1 - error in communication 1 0 - no PROPAR process error, 1 - a PROPAR process error has occurred 2 0 - no PROPAR parameter error, 1 - a PROPAR parameter error has occurred 3 0 - no PROPAR type error, 1 - a PROPAR type error has occurred 4 0 - no PROPAR value error, 1 - a PROPAR value error has occurred 5 0 - no error, 1 - a PROPAR process claim or command error has occurred 6 Reserved 7 Reserved

5.3 Alarm mode [unsigned char, RW,secured,0...3, DDEpar. = 118, Proces/par. = 97/3] Available alarm modes for device:

Value Description 0 Off 1 alarm on absolute limits 2 alarm on limits related to setpoint (response alarm) 3 alarm when instrument powers-up (eg. after power-down)

Note: Not all modes are available for all fieldbusses. Eg. For DeviceNet only mode 0 and 1 are available.

Page 185: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 21 9.17.023

5.4 Alarm maximum limit [unsigned int, RW,secured,0...32000, DDEpar. = 116, Proces/par. = 97/1] Maximum limit for sensor signal to trigger alarm situation (after delay time). Note: Minimum limit ≤ Maximum limit ≤ 100 %

5.5 Alarm minimum limit [unsigned int, RW,secured,0...32000, DDEpar. = 117, Proces/par. = 97/2] Minimum limit for sensor signal to trigger alarm situation (after delay time). Note: 0 % ≤ Minimum limit ≤ Maximum limit

5.6 Alarm output mode [unsigned char, RW,secured,0...2, DDEpar. = 119, Proces/par. = 97/4] Available alarm output modes for device:

Value Description 0 no relais/TTL-output activity at alarm 1 relais/TTL-output pulses until reset 2 relais/TTL-output activated until reset

5.7 Alarm setpoint mode [unsigned char, RW,secured,0...1, DDEpar. = 120, Proces/par. = 97/5] Available alarm setpoint modes for device:

Value Description 0 no setpoint change at alarm 1 new/safe setpoint at alarm enabled (set at alarm new setpoint)

5.8 Alarm new setpoint [unsigned int, RW,secured,0...32000, DDEpar. = 121, Proces/par. = 97/6] New/safe setpoint during alarm situation until reset.

5.9 Alarm delay time [unsigned char, RW,secured,0...255, DDEpar. = 182, Proces/par. = 97/7] Time in seconds alarm action will be delayed when alarm limit has been exceeded. Also time in seconds automatic reset will be delayed when sensor signal reaches safe level again.

Page 186: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 22 9.17.023

5.10 Reset alarm enable [unsigned char, RW,secured,0...15, DDEpar. = 69, Proces/par. = 115/4] Available alarm reset options:

Value Description 0 no reset possible 1 reset: keyboard/micro-switch 2 reset: external 3 reset: keyboard/micro-switch or external 4 reset: BUS/RS232 5 reset: BUS/RS232 or keyboard/micro-switch 6 reset: BUS/RS232 or external 7 reset: BUS/RS232 or keyboard/micro-switch or external 8 reset: automatic 9 reset: automatic or keyboard/micro-switch

10 reset: automatic or external 11 reset: automatic or keyboard/micro-switch or external 12 reset: automatic or BUS/RS232 13 reset: automatic or BUS/RS232 or keyboard/micro-switch 14 reset: automatic or BUS/RS232 or external 15 reset: automatic or BUS/RS232 or keyboard/micro-switch or external

5.11 Using an alarm (examples) Using the alarms will take three steps: 1. Preparing the instrument (setting correct values for mode, limits etc.) 2. Monitoring the alarm info byte (gives info which alarm has occurred) 3. Resetting the alarm (will re-initialize the alarm and set output to normal values again) All settings needed are secured parameters. These parameters can only be changed if a key-parameter (‘init/reset’) value has been send first to get the instrument in a soft-init mode. It will stay in this mode until a new power-up situation. Using maximum and minimum alarm This alarm will check if the measured signal crosses the maximum or minimum limit set by the user. Example: Setting maximum alarm on 90 %. Setting minimum alarm on 10 %. Relay/TTL output should be on off. No new setpoint wanted at crossing alarm limit. Delay on action at output should be 10 seconds. Reset should be automatically, when signal comes into safe area again or via FLOW-BUS. Through DDE links send following parameter values:

Parameter Value init/reset 64 alarm maximum limit 28800 alarm minimum limit 3200 alarm output mode 0 alarm setpoint mode 0 alarm reset enable * 12 alarm delay time 10 alarm mode 1

*) Default all reset inputs are enabled, so this command isn’t really necessary

Page 187: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 23 9.17.023

Now the alarm will be active. Alarm status can be monitored by means of parameter alarminfo. Resetting the alarm will need the following command reset = 0 and then reset=2. To inactivate the alarm, put it in alarm mode “off”. This will also reset your outputs. This can be done sending command: alarm mode = 0. Using instrument with response alarm. This alarm will check if the measured value will come within an area limited by maximum limit and minimum limit, related to the setpoint, within a certain delay-time. Example: Setting maximum alarm limit on setpoint + 3 % . Setting minimum alarm limit on setpoint – 0.9 %. Relay/TTL output should not be used. Setpoint wanted at crossing alarm limit = 0 %. Delay on action at output should be 2 minutes. Reset via keyboard or BUS/RS232. Send following parameter values:

Parameter Value init/reset 64 alarm maximum limit 960 alarm minimum limit 288 alarm output mode 0 alarm setpoint mode 1 alarm new setpoint 0 alarm reset enable * 5 alarm delay time 120 alarm mode 2

*) Default all reset inputs are enabled, so this command isn’t really necessary Now the alarm will be active. Alarm status can be monitored by means of parameter alarminfo. Resetting the alarm will need following command: reset = 2. To inactivate the alarm, put it in alarm mode “off”. This will also reset your outputs. This can be done sending command: alarm mode = 0.

Page 188: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 24 9.17.023

6 COUNTER PARAMETERS

6.1 Counter value [float, RW,secured,0...10000000, DDEpar. = 122, Proces/par. = 104/1] Actual counter value in units selected at Counter unit. Value is a float in IEEE 32-bits single precision notation.

6.2 Counter mode [unsigned char, RW,secured,0...2, DDEpar. = 130, Proces/par. = 104/8] Available counter modes for device:

Value Description 0 Off 1 counting upwards continuously 2 counting up to limit (batchcounter)

Default value = 0.

6.3 Counter setpoint mode [unsigned char, RW,secured,0...1, DDEpar. = 126, Proces/par. = 104/5] Setpoint change enable during counter limit/batch situation (until reset). Default = 0.

Value Description 0 no setpoint change at batch limit allowed 1 setpoint change at batch limit allowed

6.4 Counter new setpoint [unsigned int, RW,secured,0...32000, DDEpar. = 127, Proces/par. = 104/6] New/safe setpoint at counter limit/batch situation (until reset). See measure for range. Normally this value is set to 0%.

6.5 Counter limit [float, RW,secured,0...10000000, DDEpar. = 124, Proces/par. = 104/3] Counter limit/batch. in units selected at Counter unit. Value is a float in IEEE 32-bits single precision notation. Default setting is 1000000 ln.

6.6 Counter output mode [unsigned char, RW,secured,0...2, DDEpar. = 125, Proces/par. = 104/4] Parameter to determine counter relais/TTL-output activity mode when limit/batch has been reached. Default setting is 0.

Value Description 0 no relais/TTL-output activity at batch limit 1 relais/TTL-output pulses after reaching batch limit until reset 2 relais/TTL-output activated after reaching batch limit until reset

Page 189: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 25 9.17.023

6.7 Counter unit [unsigned char, RW,secured,0...13, DDEpar. = 123, Proces/par. = 104/2] Parameter used to select a unit from for certain sensor type (pointer to a unit). Default setting is 0: ‘ln’ (for sensor type 3).

Sensor type

0 1 2 3 4 5 6 7 8 9 10 11 12 13

0 n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. 1 l mm3 ml cm3 ul m3 n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. 2 g mg ug kg n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. 3 ln mm3n mln cm3n uln dm3n m3n Uls mm3s mls cm3s ls dm3s m3s 4 and > n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a. n.a.

6.8 Counter unit string [unsigned char[4], R, DDEpar. = 128, Proces/par. = 104/7] Parameter ‘CntrUntstr’ consisting of 4 characters (string) with selected unit out of table. Read-only parameter.

6.9 Using a counter (example) Using the counter will take three steps: 1. Preparing the instrument (setting correct values for mode, limit etc.) 2. Monitoring the alarm info byte (gives info which alarm has occurred) 3. Resetting the counter (will re-initialize the counter and set output to normal values again) All settings needed are secured parameters. These parameters can only be changed if a key-parameter (‘init/reset’) value has been send first to get the instrument in a soft-init mode. It will stay in this mode until a new power-up situation. Using a batch counter The measured signal will be integrated in time and there will be a check on a certain limit set by the user. Example: You have an instrument with a range of 1 ln/min. Setting the batch to be reached on 1000 ln. Relay/TTL output should do nothing. New setpoint wanted at reaching the limit is 0% (valve should be closed). Reset should be enabled via BUS/RS232 or by means of keyboard/micro-switch. Through DDE links send following parameter values:

Parameter Value init/reset 64 counter limit 1000.0 counter output mode 0 counter setpoint mode 1 counter new setpoint 0 counter reset enable * 5 counter mode 2

*) Default all reset inputs are enabled, so this command isn’t really necessary Now the counter will be active. Alarm/counter status can be monitored by means of parameter alarminfo. Resetting the counter will need following command: reset = 1. To inactivate the counter, put it in counter mode “off”. This will also reset your outputs. This can be done sending command: counter mode = 0.

Page 190: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 26 9.17.023

7 SPECIAL PARAMETERS

7.1 Reset [unsigned char, W,secured,0...5, DDEpar. = 114, Proces/par. = 115/8] Parameter to reset program, counter or alarms. Default value = 0.

Value Description 0 no reset 1 reset counter value (no mode change) or common reset 2 reset alarm 3 restart batch counter 4 reset counter value (counter off) 5 Reset module (soft reset)

Note: To make sure the parameter is accepted send a 0 first.

7.2 Init/reset (key-parameter) [unsigned char, RW,0...255, DDEpar. = 7, Proces/par. = 0/10] Init and reset security key command for network/parameter settings. Make 64 to enable changing of secured parameters. Make 0 again to reset. Default setting is 82. Note: when an instrument powers-up this value will be reset to 82 always automatically.

7.3 Wink [unsigned char, W,0...9, DDEpar. = 1, Proces/par. = 0/0] Unsigned char in range 0...9 enables master to let the instrument connected to that channel wink for several seconds for tracing the physical location. Type of winking depends on instrument. This will be either with red and green LED turn-by-turn or with special characters on an LCD. Default setting = 0.

Page 191: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 27 9.17.023

8 CONTROLLER PARAMETERS

8.1 Controller The controlling algorithm for the valve handled by the micro-controller consists of several parameters which can be set via the BUS/RS232. Although many parameters could be accessed via BUS/RS232, Bronkhorst High-Tech advises not to change these parameters because during manufacturing they have got optimal values for their purposes. Controller parameters are classified as setting parameters. Changing of controller settings should be performed by or under supervision from trained service personnel only. Main parameter settings for controller adjustment are listed below:

8.2 RespOpen0 [unsigned char, RW,secured,0...255, DDEpar. = 165, Proces/par. = 114/18] Controller response when starting-up from 0% (when valve opens). Value 128 is default and means: no correction. Otherwise controller speed will be adjusted as follows: (128-RespOpen0) New response = old response * 1.05

8.3 ContrResp [unsigned char, RW, secured,0...255, DDEpar. = 72, Proces/par. = 114/5] Controller response during normal control (at setpoint step) (128-ContrResp) New response = old response * 1.05

8.4 RespStable [unsigned char, RW, secured,0...255, DDEpar. = 141, Proces/par. = 114/17] Controller response when controller is stable (within band of 2 %) (128-RespStable) New response = old response * 1.05

8.5 PIDKp [float, RW, secured,0...1E+10, DDEpar. = 167, Proces/par. = 114/21] PID controller response, proportional action, multiplication factor.

8.6 PIDTi [float, RW, secured,0...1E+10, DDEpar. = 168, Proces/par. = 114/22] PID controller response, integration action in seconds.

8.7 PIDTd [float, RW, secured,0...1E+10, DDEpar. = 169, Proces/par. = 114/23] PID controller response, differentiation action in seconds.

Page 192: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 28 9.17.023

8.8 TdsUp [float, RW, secured,0...1E+10, DDEpar. = 51, Proces/par. = 1/12] Sensor signal differentiation time in seconds needed to speed-up sensor signals going upwards.

8.9 TdsDn [float, RW, secured,0...1E+10, DDEpar. = 50, Proces/par. = 1/11] Sensor signal differentiation time in seconds needed to speed-up sensor signals going downwards.

8.10 ExpSmooCon [float, RW, secured,0...1, DDEpar. = 74, Proces/par. = 117/4] This factor is used for filtering the signal coming from the sensor circuitry before it is further processed. It filter according the following formula: out = in * ExpSmooCon + (1 - ExpSmooCon) * out For El-flow types of instruments it will be the “slow” (not differentiated), non-linearized sensor signal. Only in case of much noise on the sensor this value will have another value than 1.0. Advise: do not give a value much lower than 0.8, otherwise it would slow down sensor response too much. Best setting here: 1.0. For CoriFlow instruments it will influence the amount of averaging of the “bare” values. The smaller this value gets, the slower a CoriFlow instrument will get a sensor signal, but less noise will be on the signal.

Response Factor setting Slow 0.05 Normal 0.1 Fast 0.2 Very fast 0.5...1.0 (not advised)

This filter is in the control loop so it affects the response time.

8.11 ExpSmooAd [float, RW, secured,0...1, DDEpar. = 222, Proces/par. = 117/5] This parameter is used in combination with the ExpSmooCon. It changes the rate of filtering for the exponential filter depending on the change of the measuring value. So it is adapting to the measuring input. If a step is seen on the measuring signal the exponential filter is decreased so a fast response is possible. If only noise is seen the exponential filter is increased to its set value to suppress noise. Possible values:

0.0 -> Exponential Smoothing filter behaves as an standard exponential smoothing filter. 1.0 -> Exponential Smoothing filter behaves as an adaptive exponential smoothing filter

Page 193: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 29 9.17.023

9 SPECIAL INSTRUMENT FEATURES

9.1 Zero (mass flow instruments only) The zero procedure is able to remove zero offset signals on the sensor signal automatically. This automatic procedure can be started through the BUS/RS232 or by means of the micro-switch on top of the instrument.

9.1.1 Zeroing with the Micro-switch • Set process conditions

Warm-up, pressure up the system and fill the instrument according to the process conditions. • Stop flow

Make sure no flow is going through the instrument by closing valves near the instrument. • Press and hold, Until

With no flow, use the push-button switch (#) on the outside of the instrument to start the zero adjustment procedure. Press the push-button (#) and hold it, after a short time the red LED will go ON and OFF then the green LED will go ON. At that moment release the push-button (#).

• Zeroing The zeroing procedure will start at that moment and the green LED will blink fast. The zeroing procedure waits for a stable signal and saves the zero. If the signal is not stable zeroing will take long and the nearest point to zero is accepted. The procedure will take approx. 10 sec. So make always sure that there is going no flow through the instrument when performing the zeroing procedure.

• Ready When indication is showing 0% signal and the green indication LED is burning continuously again, then zero has been performed well.

9.1.2 Zeroing with digital communication The following parameters must be used for zeroing an instrument:

Initreset [unsigned char, RW,0...255, DDEpar. = 7, Proces/par. = 0/10] Cntrlmode [unsigned char, RW,0...255, DDEpar. = 12, Proces/par. = 1/4]

CalMode [unsigned char, RW,0...255, DDEpar. = 58, Proces/par. = 115/1] • Set process conditions

Warm-up, pressure up the system and fill the instrument according to the process conditions. • Stop flow

Make sure no flow is going through the instrument by closing valves near the instrument. • Send parameters

Send the following values to the parameters in this sequence. Initreset 64

Cntrlmode 9 Calmode 255 Calmode 0 Calmode 9 • Zeroing

The zeroing procedure will start at that moment and the green LED will blink fast. The zeroing procedure waits for a stable signal and saves the zero. If the signal is not stable zeroing will take long and the nearest point to zero is accepted. The procedure will take approx. 10 sec. So make always sure that there is going no flow through the instrument when performing the zeroing procedure.

• Ready When indication is showing 0% signal and the green indication LED is burning continuously again, then zero has been performed well. Also parameter Cntrlmode goes back to zero.

As last send 0 to parameter Initreset. This action will be performed already during production at Bronkhorst High-Tech, but may be repeated at wish on site (For Cori-Flow always perform a zero on site).

Page 194: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 30 9.17.023

9.2 Restore parameter settings All parameter value settings in the instruments are stored in non-volatile memory so each time at power-up these settings are known. However, several settings can be changed afterwards in the field by a user if needed. Sometimes it may be necessary to get back all original settings. Therefore a backup of all settings at production final-test will be stored in non-volatile memory also. Because of this it will be possible to restore these original factory settings at any moment. Of course this will only function as long as there is no memory failure. Restoring original factory settings can be achieved by means of the micro-switch on top of the instrument or through a command via BUS/RS232. See instructions for manual operation with switch and LED’s for details.

Page 195: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 31 9.17.023

10 MANUAL INTERFACE: micro-switch and LED’s

10.1 General The micro-switch on top of the digital instrument can be used to start a certain function at the instrument. When the switch is pressed down, both LED’s will start indicating different patterns in a loop. The switch has to be pressed down until the 2 LED’s are indicating the right pattern. Then the switch has to be released and the choice has been made. Normally (when the switch is not pressed) the green and red LED are used for mode indication on digital instruments (FLOW-BUS / PROFIBUS-DP / DeviceNet). (see table 1 and 2). When the switch is pressed-down both LED’s will be switched-off for function selection. As long as the switch will be pressed-down, there will be a change in indication by the 2 LED’s after each 4 seconds. The moment the user recognizes the indication (LED-pattern) for the function he wants, he must release the switch. Now he has triggered the wanted function. In table 3 is described what the indications are for the function to be performed at normal situation. This is when the switch will be pressed-down during normal operation of the instrument. In table 4 is described what the indications are for the functions to be performed at power-up situation of an instrument. This can be realized by pressing the switch first and while pressing, connecting the power. These actions have a more ‘initializing’ character for the instrument. In paragraph 10.2 is described how bus-address and baudrate can be set for an instrument. Using this 1 switch and 2 LED’s this way, offers the user a maximum of possibilities, even if this instrument is only operated by an analog interface.

Page 196: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 32 9.17.023

Table 1: Green LED indication modes for digital instrument (no switch used)

Green LED Time Indication off Continuously Power-off or program not running on Continuously Normal running/operation mode

Special mode, see specific fieldbus for more details FLOW-BUS PROFIBUS-DP DeviceNet

short flash 0.1 sec on, 2 sec off

Initialization mode Secured params can be changed/ Remote install to FLOW-BUS

Initialization mode Secured params can be changed

Abort state or Initialization mode Secured params can be changed

normal flash 0.2 sec on, 0.2 sec off Special function mode Instrument is busy performing any special function. E.g. auto-zero or self-test Special mode, see specific fieldbus for more details FLOW-BUS PROFIBUS-DP DeviceNet

long flash 2 sec on, 0.1 sec off

not used not used Idle state slow wink 0.2 sec on, 0.2 sec off Wink mode

By a command send via FLOW-BUS the instrument can “wink” with LED’s to indicate its position in a (large) system

normal wink 1 sec on, 1 sec off Alarm indication: minimum alarm, limit/maximum alarm; power-up alarm or limit exceeded or batch reached.

fast wink 0.1 sec on, 0.1 sec off Switch-released, selected action started Note: wink = green-red-green-red turn-by-turn Table 2: Red LED indication modes for digital instrument (no switch used)

Red LED Time Indication off Continuously No error

Bus communication warning. Instrument functions o.k. See specific fieldbus for more details.

FLOW-BUS PROFIBUS-DP DeviceNet

short flash 0.1 sec on, 2 sec off

Node occupied: Re-install instrument

No data-exchange between master and slave Automatic recovery

Minor communication error

Warning message An error occurred of minor importance It would be wise to investigate the cause of this You are still able to work with your instrument See specific fieldbus for more details FLOW-BUS PROFIBUS-DP DeviceNet

normal flash 0.2 sec on, 0.2 sec off

No details No details No bus power

See specific fieldbus for more details FLOW-BUS PROFIBUS-DP DeviceNet

long flash 2 sec on, 0.1 sec off

Not used For special service purpose only

Serious communication error; manual intervention needed

on Continuously Critical error message A serious error occured in the instrument Instrument needs service before further using

Page 197: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 33 9.17.023

Table 3: LED indications using micro-switch at normal running mode of an instrument Green LED Red LED Time Indication off off 0 – 1 sec Pressing a switch shortly by accident will not

cause unwanted reactions of instrument. Pressing the switch 3x briefly with intervals of max. 1 sec. will force instrument to indicate its bus-address/MAC-ID and evt. baudrate. See paragraph 10.2 for more details. In case of min/max alarm or counter batch reached: Reset alarm (only if reset by keyboard has been enabled) See specific fieldbus for more details. FLOW-BUS PROFIBUS-DP DeviceNet

off off 1 – 4 sec

When address is occupied: Autom. installation on FLOW-BUS.

Not used Not used

off on 4 – 8 sec Reset instrument Instrument program will be restarted and all warning and error message will be cleared During (new) start-up intrument will perform a (new) self-test

on off 8 – 12 sec Auto-zero Instrument will be re-adjusted for measurement of zero-flow (not for pressure meter/controller) NOTE: First make sure there is no flow and instrument is connected to power for at least 30 minutes !

on on 12 – 16 sec Prepare instrument for FLASH mode At next power-up FLASH mode will be active This mode will be indicated by both LEDs off when instrument is normally powered

Note: short flash = 0.1 sec on, 2 sec off Table 4: LED indications using micro-switch at power-up situation of an instrument Green LED Red LED Time Indication off off 0 – 4 sec No action

Pressing a switch shortly by accident will not cause unwanted reactions of the instrument

off normal flash 4 – 8 sec Restore parameters All parameter settings (except fieldbus settings) will be restored to situation of final test at BHT production See specific fieldbus for more details.

FLOW-BUS PROFIBUS-DP DeviceNet

normal flash off 8 – 12 sec

Auto install to bus Instrument will install itself to a (new) free node- address on the FLOW-BUS

Not used Not used

Remote/manual install. Instrument will get a default address.This can be changed by means of micro-switch and LEDs. See description below for description of this procedure. See specific fieldbus for default installation address: FLOW-BUS PROFIBUS-DP DeviceNet

normal flash normal flash 12 – 16 sec

Node-address = 0 Station address = 126 MAC-ID = 63

Note: normal flash = 0.2 sec on, 0.2 sec off

Page 198: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 34 9.17.023

10.2 Readout/change bus-address/MAC-ID and baudrate

10.2.1 Set instrument to default installation address/MAC-ID: First instrument needs to be forced into “remote/manual install mode”. The switch needs to be pressed-down during power-up and released when both LEDs indicate normal flash (pattern: 0.2 sec. on, 0.2 sec. off). See also table 4 for more details. When the switch is released, instrument will get the default installation address. This will be different for each fieldbus system. Instrument may be switched-off now or will return into “normal running/operation mode” automatically after 60 sec.. Baudrate setting will not be changed by this action.

10.2.2 Readout bus-address/MAC-ID and baudrate: Pressing the switch 3x briefly with intervals of max. 1 second in normal running/operation mode will trigger the instrument to “show” its bus-address/MAC-ID and baudrate. For indication the bus-address/MAC-ID the green LED will flash the amount of tens and the red LED the amount of units in the number. For indication of baudrate setting, both LEDs will flash. The flashes are called “count-flashes” and have a pattern of 0.5 sec. on, 0.5 sec. off. Table 5: LED indications for bus-address/MAC-ID and baudrate Green LED Red LED Time Indication amount of count flashes(0...12)

Off 0 ... 12 sec. Maximum

tens in bus-address/MAC-ID for instrument

off Amount of count flashes (0...9)

0 ... 9 sec. Maximum

units in bus-address/MAC-ID for instrument

amount of count flashes(0...10)

amount of count flashes (0...10)

0 ... 10 sec. Maximum

baudrate setting for instrument

Note: Value zero will be indicated by a period of 1 sec. off (0.5 sec. off + 0.5 sec. off). E.g.: - for bus-address/MAC-ID 35 the green LED will flash 3 times and the red LED will flash 5 times. - for bus-address/MAC-ID 20 the green LED will flash 2 times and the red LED will flash 0 times. - for bus-address/MAC-ID 3 the green LED will flash 0 times and the red LED will flash 3 times. - for bus-address 126 the the green LED will flash 12 times and the red LED will flash 6 times. Table 6: Baudrate settings for different fieldbus systems: FLOW-BUS PROFIBUS-DP DeviceNet 0 = 187500 Baud (only 1 fixed baudrate)

0 = not detected 1 = 9600 Baud 2 = 19200 Baud 3 = 45450 Baud 4 = 93750 Baud 5 = 187500 Baud 6 = 500000 Baud 7 = 1500000 Baud 8 = 3000000 Baud 9 = 6000000 Baud 10 = 12000000 Baud

1 = 125000 Baud 2 = 250000 Baud 3 = 500000 Baud

E.g.: - for PROFIBUS-DP baudrate readout of 12000000 Baud, both LEDs will flash 10 times. - for DeviceNet baudrate readout of 250000 Baud, both LEDs will flash 2 times.

Page 199: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 35 9.17.023

10.2.3 Change bus-address/MAC-ID and baudrate: First instrument needs to be forced into “remote/manual install mode”. Within the time-out period of 60 sec. it is possible to start changing the bus-address/MAC-ID of the instrument. For certain fieldbus systems it is necessary to select the baudrate also. Other fieldbus systems only have one baudrate or the baudrate setting will adapt to the setting of the master automatically. In these cases baudrate selection is not needed and will be skipped. Table 7: Procedure for changing bus-address/MAC-ID and baudrate step action Indication time handling 1 Force instrument into

“remote/manual install mode”

both LEDs flashing normal 0.2 sec on, 0.2 sec

12-16 sec after power-up

Press switch during power-up and release when both LEDs indicate normal flash.

2 Set tens of bus- address/MAC-ID

Green LED flashes 0.1 sec on, 0.1 sec off count-flashes start when switch is pressed: 0.5 sec on, 0.5 sec off

time-out: 60 sec

Press switch and count green flashes for tens of bus-address/MAC-ID. Release when wanted amount has been count. Counts up to max. 12 and than starts at 0 again. When counting fails, keep switch pressed and restart counting for next attempt.

3 Set units of bus- address/MAC-ID

red LED flashes 0.1 sec on, 0.1 sec off count-flashes start when switch is pressed: 0.5 sec on, 0.5 sec off

time-out: 60 sec

Press switch and count red flashes for units of bus-address/MAC-ID. Release when wanted amount has been count. Counts up to max. 9 and than starts at 0 again. When counting failed, keep switch pressed and restart counting for next attempt.

4 Set baudrate of fieldbus communication.Only for specific types of fieldbusses: e.g. DeviceNet. This part will be skipped if no baudrate needs to be selected.

both red and green LED flashes 0.1 sec on, 0.1 sec off count-flashes start when switch is pressed: 0.5 sec on, 0.5 sec off

time-out: 60 sec

Press switch and count red and green flashes for baudrate setting of the specific fieldbus. Release when wanted amount has been count. Counts up to max. 10 and than starts at 0 again. When counting failed, keep switch pressed and restart counting for next attempt. Note: selection of 0 means: No change

Instrument returns to normal running/operation mode. Changes are valid when they are made within the time-out times. Actual setting can be checked by pressing the switch 3x briefly with intervals of max. 1 sec. for readout the bus-address/MAC-ID and baudrate (see paragraph 10.2.2 for more details). Note 1: Value zero will be indicated by a period of 1 sec. off (0.5 sec. off + 0.5 sec. off). When value zero is wanted, press switch shortly and release it again within 1 sec. Note 2: Before each action of flash-counting, the LED(s) to be used for counting will flash in a high frequency. (Pattern: 0.1 sec on, 0.1 sec off). As soon as the switch is pressed-down, this LED (or both LEDs) will be off and the counting sequence will start.

Page 200: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 36 9.17.023

Flatconductorcable

main PC board

fieldbusinterface

1234

S1S2S3S4

on

off

11 JUMPER SETTINGS MULTIBUS INSTRUMENTS

Multibus instruments consist of 4 jumpers or a DIPswitch on the pc-board. In normal operation it is not necessary to change the jumpersetting (see table 8) If it is inevitable, the jumpers can only be reached when the uppercase of the housing is opened. Opening the uppercase should be done with great care, because the connection of the fieldbus and main p.c.board is accomplished by a small flatconductor cable. Each jumper or switch can be used to make a certain setting by placing a link between a set of pins or by switching one of the DIPswitches as shown below:

with DIPswitch with jumpers

Table 8: Jumper settings digital pc-board

Switch Jumper When placed (on) When not placed (off) Remarks S2 J1 Default settings from

EPROM loaded at power-up

Settings loaded from non-volatile memory at power-up

Normally not placed

S3 J2 Analog input used as standard setpoint for controller at power-up

Digital (bus) input used as standard setpoint for controller at power-up

Setting depends on how instrument was ordered. Setting can be changed during normal operation using parameter ControlMode so take-over of setpoint control by RS232 or fieldbus is possible. At next power-up however, controller will read jumper first for actual setpoint source.

S4 J3 reserved - J4 reserved Not always present

S1 J5 Normal RS232 communication

Instrument in FLASH mode RS232 used for download of new firmware

FLASH mode can also be selected using the micro-switch on top of the instrument (see chapter 10, table 3).

(J4) J5

J1

J3J2

J5

CORI-FLOW

J2J1

J3

MBC-II

J1J2J3

J5

L30 digital

Page 201: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

page 37 9.17.023

12 TESTING AND DIAGNOSTICS All digital instruments have facilities to run self-test procedures for diagnostics. Most of the instrument functions will be tested automatically during start-up or normal running mode of the instrument. All results of testing or malfunctioning will be stored in special diagnostics registers in the non-volatile memory of the instrument. These registers will contain actual information about the functioning of the instrument. The red LED on top of the instrument is used to indicate if there is something wrong. The longer the LED is burning (blinking) red, the more is wrong with the instrument. See chapter 10 for more details about the LEDs and other documents for more specific troubleshooting.

Page 202: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Instruction manual

RS232 interface With FLOW-BUS protocol

for digital Mass Flow / Pressure instruments

Doc. no.: 9.17.027G Date: 26-01-2006

ATTENTION Before installing and operating the instrument it is recommended that this instruction be read. Not following the guidelines could result in personal injury and/or damage to the equipment.

Page 203: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 2

SCOPE OF THIS MANUAL

This manual covers the interface part of digital massflow / pressure instruments for gases or liquids. It describes the communication between the instrument and the operator according to the specific (fieldbus) protocol. More information can be found in other documents. Multibus instruments have modular instruction manuals consisting of: - General instructions digital Mass Flow / Pressure instruments

laboratory style / IN-FLOW (document nr. 9.17.022) - General instructions CORI-FLOW (document nr. 9.17.031) - Operation instructions digital instruments (document nr. 9.17.023)

- Fieldbus/interface description:

Page 204: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 3

Short form start-up All necessary settings for this module are already performed at Bronkhorst High-Tech B.V. To follow next steps carefully is the quickest way to get this module operational in your own system. Procedure: - Make sure your PC or PLC is connected to the RS232 interface by means of the correct cable

• Multibus instruments need a special cable with T-connector. • RS232/FLOW-BUS interfaces need a one-on-one 9-pole cable without crossings with male

and female connector • Cable lengths for RS232 must not exceed 10 meters.

- Make sure instrument or interface is powered (+15Vdc or +24Vdc) - In case of RS232/FLOW-BUS interface without micro-switch and LED’s, first see that interface

gets a free address on the FLOW-BUS. Follow initialisation procedure described at [Initialising RS232/FLOW-BUS interface]

- Use settings [38400,n,8,1] for your COM-port: Baudrate = 38K4 Baud, no parity, 8 databits, 1

stopbit.

- Start sending messages as described in following paragraphs.

- In case of trouble programs like Hyperterminal (available in MS-Windows) or FlowDDE (from Bronkhorst High-Tech B.V.) could be very useful.

Page 205: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 4

Table of contents 1 INTRODUCTION ...................................................................................................................................5 2 Available interfaces................................................................................................................................6

2.1 RS232/FLOW-BUS interface...........................................................................................................6 2.1.1 D-connector for RS232 ............................................................................................................6 2.1.2 Specifications ..........................................................................................................................6

2.2 RS232 on multibus instrument ........................................................................................................7 2.2.1 Facilities ..................................................................................................................................8 2.2.2 Specifications multibus RS232: ................................................................................................8

3 FLOW-BUS protocol description ............................................................................................................9 3.1 General ..........................................................................................................................................9 3.2 Initialisation of local host interfaces on Multibus instruments ...........................................................9 3.3 Interface structure.........................................................................................................................10

3.3.1 Basic datalink format..............................................................................................................10 3.3.2 RS232 ASCII protocol............................................................................................................10 3.3.3 Enhanced binary protocol.......................................................................................................11

3.4 Communication messages............................................................................................................13 3.5 Chaining .......................................................................................................................................14 3.6 Status message............................................................................................................................14 3.7 Send parameters ..........................................................................................................................15 3.8 Request parameter .......................................................................................................................15 3.9 Initialising RS232/FLOW-BUS interface ........................................................................................17 3.10 Examples ..................................................................................................................................18

3.10.1 Sending setpoint ....................................................................................................................18 3.10.2 Sending chained parameters .................................................................................................18 3.10.3 Request setpoint....................................................................................................................20 3.10.4 Request chained parameters .................................................................................................21 3.10.5 Request measure ..................................................................................................................23 3.10.6 Request counter value ...........................................................................................................23

4 Dual interface operation.......................................................................................................................24 5 Parameter information .........................................................................................................................25 6 Troubleshooting...................................................................................................................................27 Appendices 1 Parameter properties table 2 Parameter values table

Page 206: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 5

1 INTRODUCTION This manual will explain how to communicate with a Bronkhorst High-Tech instrument to your PC/PLC using RS232 serial communication. You have to write software yourself using the information of this document in order to be able to operate these instruments. Bronkhorst High-Tech B.V. also offers software to support a quicker way to operate digital instruments with your PC using MS-Windows 95, 98, NT, 2000 or XP On the highest supported communication level, you may use DDE-channels for Windows application-programs with this facility. You can use the program FlowDDE for easy connection between MS-Windows applications (e.g. Excel, Visual Basic, LabView, Delphi, Borlandc) and digital instruments. There are several examples available for LabView, Visual Basic and Excel environments. On a lower communication level, you can also use the FLOWB32.DLL for reading/changing parameter values. To read and write parameter values from or to FLOW-BUS devices directly through the available interfaces there is a special protocol for messages between these devices. This protocol has been specially developed for Bronkhorst High-Tech equipment so no third party equipment can be connected. It consists of a hierarchical setup for instruments/nodes (max. 128) containing processes (max. 128) with parameters(FBnr) (max. 32) which values can be set to certain values to enable settings/properties for the instruments. When operating a FLOW-BUS system with a HOST computer, you need to know this message protocol if you choose to drive the interfaces directly. When you use a RS232/FLOW-BUS interface (without the micro-switch and 2 LED’s), you first have to initialise the interface. This can be done by means of sending some ASCII-strings to the interface through RS232. See chapter 3 for more details. When you communicate directly via RS232 on a multibus instrument or when you use a new type of RS232/FLOW-BUS (baudrates up to 38K4 with switch and 2 LED’s) interface, no special initialisation is needed.

Page 207: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 6

2 Available interfaces

2.1 RS232/FLOW-BUS interface The RS232/FLOW-BUS interface is an interface between the FLOW-BUS and the RS232 V24 serial (computer) port. It will either be supplied as a separate enclosed unit with a FLOW-BUS connector and a RS232 connector or as an integral 14TE module of your E-7000 readout and control system. The converter offers communication with a baudrate up to 38,4 kBaud. Communication software support is available. Communication settings are: 38400,n,8,1.

2.1.1 D-connector for RS232 The female RS232 (x) (subminiature 9-pin) D-connector has the following pin configuration: Pinnumber Description 1 2 3 4 5 6 7 8 9

not connected TXD RXD not connected 0 Vd DTR CTS RTS Shield

2.1.2 Specifications Power supply +15Vdc/+24Vdc +/- 10% Power consumption +15Vdc : 50 mA

+24Vdc : 35 mA Operating temperature

0…+50 ºC

Storing temperature -20…+60 ºC Housing dimensions

box: 160x80x44mm module: 14TE

Baudrates 4800 Baud 9600 Baud 19200 Baud 38400 Baud

Galvanic Isolation FLOW-BUS: opto isolated Power : DC-DC converter

FLOW-BUS

RS232

FLOW-BUS status

Page 208: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 7

2.2 RS232 on multibus instrument The RS232 interface on a multibus instrument can be connected to any RS232 V24 serial (computer) port. The interface offers communication with a baudrate of 38.4 kBaud. On the 9-pin male subD connector of the instrument RX and TX are available on pin 6 and pin 1. RS232 communication is possible by: - 9-pin Sub D-connector (non IP65 applications, e.g. EL-FLOW) - 8 DIN connector (IP65 applications, e.g. CORI-FLOW) For the exact connections please advise your hook-up diagram. Non IP65 applications, e.g. EL-FLOW Analog I/O, without businterface Instrument is supplied through 9-pin Sub D-connector. Application with businterface FLOW-BUS/DeviceNet Instrument is supplied through the bus. Application with businterface PROFIBUS Instrument is supplied through 9-pin Sub D-connector. IP65 applications, e.g. CORI-FLOW Analog I/O, without businterface Instrument is supplied through 8 DIN connector.

Powersupply

RS232 COM-port

RS232 COM-port

Powersupply

RS232 COM-port

RS232 COM-port

Powersupply

Page 209: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 8

Application with businterface FLOW-BUS/DeviceNet Instrument is supplied through the bus. Application with businterface PROFIBUS Instrument is supplied through 8 DIN connector.

2.2.1 Facilities No handshaking facilities are used. On the side of the PC/PLC a nul-modem connector is needed. Communication settings are: 38400,n,8,1. Bronkhorst High-Tech B.V. offers a special cable needed for communication. Communication software support is available.

2.2.2 Specifications multibus RS232: Operating temperature

0…+70 ºC

Storing temperature -20…+60 ºC Baudrates 38400 Baud Galvanic Isolation not for RS232 The multibus RS232 interface is a serial interface between the multibus instrument and the RS232 V24 serial (computer) port using the FLOW-BUS protocol for communication. This means that for serial RS232 communication a multibus instrument with RS232 can be treated as a FLOW-BUS system with one instrument and a FLOW-BUS/RS232 interface. All available software already existing for FLOW-BUS RS232 communication can be used for multibus instruments also. Only initialisation is different. Use of FLOWDDE32 is only possible from V4.23 and higher.

RS232 COM-port

RS232 COM-port

Powersupply

Page 210: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 9

3 FLOW-BUS protocol description

3.1 General On the highest supported communication level, you may use DDE-channels for Windows application-programs with this facility. On a lower communication level, you can use the FLOWB32.DLL, FLOWBUS.DLL or FLOWBUS.LIB, for changing parameter values. To read and write parameter values from or to FLOW-BUS devices directly through the available interfaces there is a special protocol for messages between these devices. When operating a FLOW-BUS system with a HOST computer, you need to know this message protocol if you choose to drive the interfaces directly. When you use a type of RS232/FLOW-BUS interface (baudrate up to 38K4) you may first have to initialise the interface. This can be done by means of sending some ASCII-strings to the interface through RS232. See also paragraph 3.2. There are two different communication protocols for the PC and the RS232 HOST: • an ASCII protocol for communication that is compatible with existing Flowbus applications.

This protocol serves only one master/slave dialog at a time. • an enhanced binary protocol that supports concurrent sending of messages to different nodes. This

protocol contains a message-sequence number an serves more than one master/slave dialogs at a time. The RS232-HOST module automatically recognises the protocol used by the PC and adapts its behaviour to the protocol in use. The type of protocol is determined by the first character of a message. • the first character is >:= (0x3A) existing type of message. • the first character is DLE (0x10) enhanced type of message. Via the FLOW-BUS DLL (FLOWB32.DLL)The PC determines which protocol is in use. The communication relation is always master (PC) and slave (HOST). The HOST will always respond on a request from the PC.

3.2 Initialisation of local host interfaces on Multibus instruments When you use a digital instrument with RS232 interface, baudrate is fixed on 38K4 baud and no special initialisation is needed. Through the serial line connected to a COM-port of your computer or to a PLC you have to communicate with the instrument using the FLOW-BUS protocol. Each instrument has its own node-address (3...120). If you want to send a message to the instrument you have to know this node-address. However, if you send a message to node-address 128 the instrument will always respond to your message. On a point-to-point connection like RS232 it is the easiest way to make the communication work under all circumstances (its independent of the real node-address of the instrument).

Page 211: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 10

3.3 Interface structure

3.3.1 Basic datalink format The basic datalink message format has the following fields:

node message destination length data field length data data Data etc.

In the Flowbus environment the data field may contain up to 256 bytes of data. In the HOST application described here, the messages are according to PROPAR coding rules and the data field will contain a maximum of 64 bytes.

3.3.2 RS232 ASCII protocol An ASCII protocol is used on the existing RS232-HOST. To be compatible with existing driver software the ASCII protocol is available. A basic datalink message is coded in ASCII as follows: len node data : len1 len2 node1 node2 data1 data2 CR >:= (semicolon) initial character len1, len2 length of message including the node address in bytes, so (len1,len2) is the basic

message length +1. node1, node2 node address of destination (PC to HOST)

node address of source (HOST to PC) data1, data2 message field CR termination character All bytes (except the initial and termination character) are converted from 1 binary byte to 2 hexadecimal bytes in ASCII representation.

Example: binary data byte 0x2A --> hexadecimal ASCII characters 0x32, 0x41. A special message type is used to pass error messages from the HOST to the PC. Its structure is as follows: 0x01 error : 0x30 0x31 error1 error2 CR >:= (semicolon) initial character 0x30, 0x31 length of the message (1 byte) error error code, two digit HEX number CR termination character

Page 212: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 11

The error code can have the following values:

Value Meaning 1 no >:= at the start of the message 2 error in first byte 3 error in second byte or number of bytes is 0 or message to long 4 error in received message (receiver overrun, framing error etc.) 5 Flowbus communication error: timeout or message rejected by receiver 8 time out during sending 9 no answer received within time out

3.3.3 Enhanced binary protocol Binary coding and control sequences The enhanced protocol is binary coded. Control sequences are used to recognise the begin and end of a message in a byte stream. A control sequence starts with a DLE byte (0x10) and is followed by a control byte. The following control sequences are defined:

First byte Second byte Function DLE (0x10) STX (0x02) Start of message DLE (0x10) ETX (0x03) End of message DLE (0x10) DLE (0x10) Data byte 0x10 DLE (0x10) any other

character Not allowed. Messages that contain such a sequence will be ignored. The receiver waits until a new DLE STX sequence.

The [DLE DLE] sequence is used to prevent possible DLE bytes in the transmitted binary data stream from being recognised as the start of a control sequence. The sender replaces any DLE bytes in the data by two DLE bytes. The datalink of the receiver will convert a [DLE DLE] sequences to one DLE byte. Note: If a RS232 error (receiver overrun, framing error, not allowed control sequence) occurs, the datalink

frame is ignored. Enhanced message coding The enhanced binary coded messages between PC and HOST are structured as follows:

DLE STX seq node len data DLE ETX DLE, STX start sequence seq message sequence number node node address of destination (PC to HOST)

node address of source (HOST to PC) len length of data field in bytes data message field DLE, ETX end sequence The enhanced protocol allows the transmission of more than one request at a time. The sequence number makes it possible to associate the answer to the according request. The HOST has more than one message buffer where messages may be stored (typical 5). When the message buffers are full, the HOST responds with an error message.

Page 213: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 12

The responses from the HOST to the PC have the same message format as the request. An error message has a special format:

DLE STX seq node 0x00 error DLE ETX DLE, STX start sequence seq message sequence number, as in request node node address of source, as in request error error code DLE, ETX end sequence The error code can have the following values:

Value Meaning 3 Message rejected by HOST, host receiver buffer overflow 5 Flowbus communication error: timeout or message rejected by Flowbus node 8 time out during sending 9 no response on a request received within time out

Page 214: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 13

3.4 Communication messages Communication messages between FLOW-BUS interfaces and other devices consist of command strings with specific information. This command string is either ASCII (RS232) or BINARY. Basically the string contains several information bytes. Through RS232 these hexadecimal bytes are converted in ASCII (f.i.: bytevalue 0x0A is "0A" in ASCII and capital letters should be used). Messages via RS232 are preceded by the ':' character and terminated with "\r\n" (Carriage return-Line-feed). There are several COMMANDS available in the FLOW-BUS messages. However only Command RD (04) and WR (01) are enough to do all the standard parameter reading and writing. A RD command will be answered with a WR command, containing the value asked for or a status message, containing an error-number. A WR command will be answered with a status message, containing an error-number (if error-number = 0, than WR command was OK). Note: ASCII character ‘:’ has hexadecimal value: 3A ASCII character ‘\r’ has hexadecimal value: 0D ASCII character ‘\n’ has hexadecimal value: 0A Communication commands Command Description

00 Status message 01 Send parameter with destination address, will be answered with type 00 command 02 Send parameter with destination address, no status requested 03 Send parameter with source address, no status requested 04 Request parameter, will be answered with type 02 or 00 command 05 Instruction: send parameter repeatedly (followed by byte with repeating time) 06 Stop process 07 Start process 08 Claim process 09 Unclaim process

To access a specific parameter you need to know the following numbers. 1. Node-address, each FLOW-BUS device is connected to a specific node-address in the system. 2. Process number, each device (node) consists of several processes. 3. Parameter number(FBnr), each process consists of several parameters. 4. Parameter type, each parameter can be of a different type and value. For parameters numbers and values see tables “parameter properties” and “parameter values” in this manual. Parameter types Type Id Bytes Range Character 00h 1 0…255 Integer 20h 2 0…65535 Float 40h 4 +-1.18e-38...+-3.39e+38 Long 40h 4 4 bytes 0... 4294967296 String 60h X length needs to be specified

Page 215: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 14

3.5 Chaining Chaining can be used to send or request more than one parameter per message. When the parameters are all members of the same process, they can be chained at parameter level. When the parameters are members of different processes, they can be chained at process level. A combination is also possible. For chaining at parameter level the first bit of the parameter number should be set if there is following another parameter at the same process. For chaining at process level the first bit of the process number should be set if there is another process following.

3.6 Status message status Nr Byte Description

0 : Start character

1 04 Fixed message length 4.

2 Node Node address

3 00 Command status

4 Status 00 No error 01 Process claimed 02 Command error 03 Process error 04 Parameter error 05 Parameter type error 06 Parameter value error 07 Network not active 08 Time-out start character 09 Time-out serial line 0A Hardware memory error 0B Node number error 0C General communication error 0D Read only parameter. 0E Error PC-communication 0F No RS232 connection 10 PC out of memory 11 Write only parameter 12 System configuration unknown 13 No free node address 14 Wrong interface type 15 Error serial port connection 16 Error opening communication 17 Communication error 18 Error interface busmaster 19 Timeout answer 1A No start character 1B Error first digit 1C Buffer overflow in host 1D Buffer overflow 1E No answer found 1F Error closing communication 20 Synchronisation error 21 Send error 22 Protocol error 23 Buffer overflow in module

5 Index or Claimed process

Index pointing to the first byte in the send message for witch the above status applies. In case of the status CLAIM ERROR, this field contains the claimed process.

6 ‘\r’ Carriage Return

7 ‘\n’ Line Feed

*Note: Value from byte 5 of status message may be neglected if value of byte 4 = 0 !

Page 216: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 15

3.7 Send parameters Send Nr Byte Layout Description 0 : start character 1 Length Message length 2 Node Node address 3 01 or 02 Command write, for type 01 a status message (00) will be returned

c Process chained 4 Process Cppppppp p Process number c Parameter chained t Parameter type

5 Parameter type

Cttppppp

p Parameter number 6 Value 1 Value for all types. For ‘strings’ this field contains the string length.

7 Value 2 Value for type ‘integer’, ‘float’ or ‘long’.

8 Value 3 Value for type ‘float’ or ‘long’.

9 Value 4 Value for type ‘float’ or ‘long’.

X Value x More value fields follow for type ‘string’ depending on string length. If given string length is zero, the final field should also contain a zero.

X+1 ‘\r’ Carriage Return

X+2 ‘\n’ Line Feed

3.8 Request parameter For each requested parameter an index number can be given. The answering node will return this index number with the requested parameter. This can be used to check which parameter is returned when several parameters are requested. Request Nr Byte Layout Description 0 : start character 1 Length Message length 2 Node Node address 3 04 Command read

c Process chained 4* Process (return) Cppppppp

p Process number c Parameter chained t Parameter type

5* Parameter type & index (return)

Cttnnnnn

n Parameter index 0…31 - Not used 6 Process -ppppppp

p Process number - Not used t Type parameter

7 Parameter -ttppppp

p Parameter number 8 String length For parameter type ‘string’ this field contains the expected string length. 9 ‘\r’ Carriage Return 10 ‘\n’ Line Feed

Page 217: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 16

Answer of request Nr Byte Layout Description 0 : start character 1 Length Message length 2 Node Node address 3 02 Command write

c Process chained 4* Process Cppppppp p Process number c Parameter chained t Parameter type

5* Parameter type & index

Cttnnnnn

n Parameter index 0…31 6 Value 1 Value for all types. For ‘strings’ this field contains the string length.

7 Value 2 Value for type ‘integer’, ‘float’ or ‘long’.

8 Value 3 Value for type ‘float’ or ‘long’.

9 Value 4 Value for type ‘float’ or ‘long’.

X Value x More value fields follow for type ‘string’ depending on string length. If given string length is zero, the final field should also contain a zero.

X+1 ‘\r’ Carriage Return

X+2 ‘\n’ Line Feed

*The requested module copies these values from the request message directly into the answer message.

Page 218: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 17

3.9 Initialising RS232/FLOW-BUS interface If you use a RS232/FLOW-BUS interface for communication (without the micro-switch and 2 LED’s), note that this module is not part of the (FLOW-BUS) token-ring network, directly at power-up. This means that it is always necessary to re-initialise the module when power has been interrupted! This is not the case when using an RS232/FLOW-BUS interface with micro-switch, red LED, green LED and RJ45 connector for FLOW-BUS. By means of the switch you may force the interface to find a free address on the FLOW-BUS once. You may skip the initialisation and start directly sending messages. Also when using digital (Multibus) instruments with RS232 directly on the instrument it is not needed to initialise (give a free node-address to) the instrument on the FLOW-BUS because instrument is not physically connected to the FLOW-BUS, but only uses the same protocol. You may start directly sending your messages to the instrument on either the node-address of the instrument in its memory e.g. node 3 (selective response) or to node-address 128 (always response). At power-up situation you can communicate with the RS232 interface only at the RS232 side via node 0. To get part of the FLOW-BUS you have to send an init. command, send the network parameters PNA, SNA, NNA, LNA and BM and send a reset command. From this moment the interface is part of the FLOWBUS. Ensure the module gets a free and unique address on the bus, 2 modules on the same address will cause communication problems. When you are sure that there are no more interfaces in the system, simply force the RS232/FLOW-BUS interface to address 1. This address is reserved for an interface. PC-support software (FLOWB32.DLL, FLOWBUS.DLL and FLOWBUS.LIB) will search for a free address on which the interface will be installed. Follow the steps below to realise correct initialisation for this interface via RS232: Initialisation RS232 interface (needed for FLOW-BUS/RS232 interfaces without switch and LEDs only) Send Response Comment :050001000A49\r\n* Init instruction for node 0 process 0. :04000000XX\r\n No error. :050001000101\r\n PNA = Primary Node Address = 1 :04000000XX\r\n No error. :05000100027F\r\n SNA = Secondary Node Address = 127 :04000000XX\r\n No error. :050001000302\r\n NNA = Next Node Address = 2 :04000000XX\r\n No error. :050001000420\r\n LNA = Last Node Address = 32 (depends on system size) :04000000XX\r\n No error. :050001000502\r\n BM = Bus Management = 67

67 = everything automatically (auto arbitration+gap skipping) 3 = auto arbitration 2 = always busmaster 1 = temporary In older systems: when no R/C-modules in system make BM = 2, when R/C-modules in system (already busmasters present) than make BM = 1; otherwise make = 67

:04000000XX\r\n No error. :050001000A52\r\n Reset instruction for module; from this moment on module will

be active on FLOW-BUS at node address = PNA :04000000XX\r\n No error. • Sometimes it could be necessary to repeat the first instruction. Wait approx. 2 seconds before sending

the next command. • XX means: don’t care Communication can be closed and interface can be disabled from FLOW-BUS token-ring traffic by sending the command below via the RS232 to the interface. Stop communication RS232 interface Send Comment :050101001101\r\n close communication instruct. for interface module there will be no aswer (because

communication stops) second byte is actual node address for interface (here: 01)

Page 219: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 18

3.10 Examples

3.10.1 Sending setpoint Sending setpoint 50% to node 3 process 1. Setpoint values should be given in a range from 0 to 32000 so for this example 16000 should be send. Send parameters to node 3 Nr Byte Layout Description 0 ':' Start character 1 06 Length 6 2 03 Node 3 3 01 Command write with status response

C 00 Process not chained 4 01 00000001

P 01 Process 1 C 00 Parameter not chained T 20 Parameter type ‘integer’

5 21 00100001

P 01 Parameter number 1 6 3E

7 80

Setpoint 16000 = 3E80h

8 ‘\r’ Carriage Return 9 ‘\n’ Line Feed Answer from node 3 Nr Byte Description

0 ‘:’ Start character

1 04 Fixed message length 4.

2 01 Node address 01

3 00 Command status

4 00 Status ok.

5 05 Status ok, value points to end of send message.

6 ‘\r’ Carriage Return

7 ‘\n’ Line Feed

3.10.2 Sending chained parameters Interface sends following parameters to module at node 3: Process 0: INIT MODE (10), 64 = soft init Process 1: FLUIDNUMBER(16). 1 Process 1: POLYNOMIAL CONSTANTE A(5), 0.0 Process 1: POLYNOMIAL CONSTANTE B(6), 1.0 Process 1: POLYNOMIAL CONSTANTE C(7), 0.0 Process 1: POLYNOMIAL CONSTANTE D(8), 0.0 Process 0: INIT MODE (10), 82 = reset initmode. Send parameters to node 3 Nr Byte Layout Description 0 ':' 1 1D Length 29 2 03 Node 3 3 01 Command write with status response

C 80 Process chained 4 80 10000000

P 00 Process 0

Page 220: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 19

C 00 Parameter not chained T 00 Parameter type ‘character’

5 0A 00001010

N 0A Parameter number 10 6 40 01000000 Parameter value 64 set soft init mode

C 80 Process chained 7 81 10000001

P 01 Process 1 C 80 Parameter chained T 40 Parameter type ‘float’

8 C5 11000101

N 05 Parameter number 5 9 00

10 00

11 00

12 00

Parameter value ‘float’ 0.0

C 80 Parameter chained T 40 Parameter type ‘float’

13 C6 11000110

N 06 Parameter number 6 14 3F

15 80

16 00

17 00

Parameter value ‘float’ 1.0

C 80 Parameter chained T 40 Parameter type ‘float’

18 C7 1100111

N 07 Parameter number 7 19 00

20 00

21 00

22 00

Parameter value ‘float’ 0.0

C 80 Parameter chained T 40 Parameter type ‘float’

23 C8 11001000

N 08 Parameter number 8 24 00

25 00

26 00

27 00

Parameter value ‘float’ 0.0

C 00 Process not chained 28 00 00000000

P 00 Process 0 C 00 Parameter not chained T 00 Parameter type ‘character’

29 0A 00001010

N 0A Parameter number 10 30 52 01010010 Parameter value 82, reset init mode 31 ‘\r’ Carriage Return 32 ‘\n’ Line Feed

Page 221: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 20

Answer from node 3 Nr Byte Description 0 ‘:’ Start character

1 04 Fixed message length 4.

2 03 Node address

3 00 Command status

4 00 Status ok.

5 1C Status ok, value points to end of send message.

6 ‘\r’ Carriage Return

7 ‘\n’ Line Feed

3.10.3 Request setpoint Request setpoint from node 3 process 1, type integer. Nr Byte Layout Description 0 ':' 1 06 Length 6 2 03 Node 3 3 04 Command read

C 00 Process not chained (return) 4 01 00000001

P 01 Process 1 (return) C 00 Parameter not chained (return) T 20 Parameter type ‘integer’ (return)

5 21 00100001

N 01 Parameter index 1 (return) 6 01 -0000001 P 01 Process 1 7 21 -0100001 T 20 Parameter type ‘integer’ P 01 Parameter number 1 ( setpoint) 8 ‘\r’ Carriage Return 9 ‘\n’ Line Feed Answer by node 3 Nr Byte Layout Description 0 ':' 1 06 Length 6 2 03 Node 3 3 02 Command write

C 00 Process not chained 4 01 00000001

P 01 Process 1 ( receiving process) C 00 Parameter not chained T 20 Parameter type ‘integer’

5 21 00100001

N 01 Parameter index 1 6 3E

7 80

Value 3E80h = 16000 = 50%

8 ‘\r’ Carriage Return 9 ‘\n’ Line Feed

Page 222: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 21

3.10.4 Request chained parameters Interface sends a request for the following parameters to module at node 3: Process 113: SerialNum (3), UserTag (6) Process 1 : Measure (0), Capacity (13), Capunitstr (31), Fluidname (17) Request by node 3 Nr Byte Layout Description 0 ':' 1 1A Length 31 2 03 Node 3 3 04 Command read

C 80 Process chained (return) 4 F1 11110001

P 71 Process 113 (return) C 80 Parameter chained (return) T 60 Parameter type ‘string’ (return)

5 EC 11101100

N 0C Parameter index 12 (return) 6 71 -1110001 P 71 Process 113

T 60 Parameter type ‘string’ 7 63 -1100011

P 03 Parameter number 3 – Serial Number 8 14 10000100 14 String length 20

C 00 Parameter not chained (return) T 60 Parameter type ‘string’ (return)

9 6D 01101101

N 0D Parameter index 13 (return) 10 71 -1110001 P 71 Process 113

T 60 Parameter type ‘string’ 11 66 -1100110

P 06 Parameter number 6 – Usertag 12 00 00000000 String length 00, length not defined

C 00 Parameter not chained (return) 13 01 00000001

P 01 Process 1 (return) C 80 Parameter chained (return) T 20 Parameter type ‘integer’ (return)

14 AE 10101110

N 0E Parameter index 14 (return) 15 01 -0000001 P 00 Process 1

T 20 Parameter type ‘integer’ 16 20 -0100000

P 00 Parameter number 0 – Measure C 80 Process chained (return) T 40 Parameter type ‘float’ (return)

17 CF 11001111

N 0F Parameter index 15 (return) 18 01 -0000001 P 01 Process 1

T 40 Parameter type ‘float’ 19 4D -1001101

P 0D Parameter number 13 – Capacity C 80 Parameter chained (return) T 60 Parameter type ‘string’ (return)

20 F0 11110000

N 10 Parameter index 16 (return) 21 01 -0000001 P 01 Process 1 22 7F -1111111 T 60 Parameter type ‘string’ P 1F Parameter number 31 – Capacity Unit Sting 23 07 00001110 07 String length 7

C 00 Parameter not chained (return) T 60 Parameter type ‘string’ (return)

24 71 01110001

N 11 Parameter index 17 (return)

Page 223: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 22

25 01 -0000001 P 01 Process 1 T 60 Parameter type ‘string’ 26 71 01110001

P 11 Parameter number 17 – Fluidname 27 0A String length 10 33 ‘\r’ Carriage Return 34 ‘\n’ Line Feed Answer by node 3 Nr Byte Layout Description 0 ':' 1 41 Number of bytes which do follow: 65 bytes 2 03 Node 3 3 02 Command write

C 80 Process chained 4 F1 11110001 P 71 Process 113 ( recieving process) C 80 Parameter chained T 60 Parameter type ‘string’

5 EC 11101100

N 0C Parameter index 12 6 14 Length of the answer 20 Bytes 7-25 4D 36 32 31 32 33 34 35 41 20 20 20 20 20 20 20 20 20 20 20

Parameter value converted from hex to ASCII : M6212345A 27 6D 01101101 C 00 Process not chained T 60 Parameter type ‘string’ N 0D Parameter index 13 28 00 String length 00, length not defined 29-36 55 53 45 52 54 41 47 00

Parameter value converted from hex to ASCII, the values do read: USERTAG 37 01 00000001 C 00 Process not chained P 01 Process 1 ( receiving process) 38 AE 10101110 C 80 Parameter chained T 20 Parameter type ’integer’ N 0E Parameter index 14 39 1C 40 D8

Parameter value is: 1CD8 (hex) Measure Value is: 7384 (dec)

41 CF 11001111 C 80 Parameter chained T 40 Parameter type ‘float’ N 0F Parameter index 15 42 3F 43 80 44 00 45 00

Parameter Value: 3F 80 00 00 (IEEE-floating point notation , 32-bit single precision ) Parameter value converted from float to decimal , the values do read: 1.0

46 F0 11110000 C 80 Parameter chained T 60 Parameter type ’string N 10 Parameter index 16 47 07 Length of the answer 7 Bytes 48-54 6D 6C 6E 2F 6D 69 6E Parameter value converted from hex to ASCII, the values do read: mln/min

55 71 01110001 C 00 Parameter not chained T 60 Parameter type ’string’ N 11 Parameter index 17 56 0A Length of the answer 10 Bytes 57-66 4E 32 20 20 20 20 20 20 20 20

Parameter value converted from hex to ASCII, the values do read: N2

Page 224: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 23

3.10.5 Request measure Request measure from node 3 process 1, type integer. Nr Byte Layout Description 0 ':' 1 06 Length 6 2 03 Node 3 3 04 Command read

C 00 Process not chained (return) 4 01 00000001

P 01 Process 1 (return) C 00 Parameter not chained (return) T 20 Parameter type ‘integer’ (return)

5 21 00100001

N 01 Parameter index 1 (return) 6 01 -0000001 P 01 Process 1 7 20 -0100000 T 20 Parameter type ‘integer’ P 00 Parameter number 0 ( measure) 8 ‘\r’ Carriage Return 9 ‘\n’ Line Feed Answer by node 3 Nr Byte Layout Description 0 ':' 1 06 Length 6 2 03 Node 3 3 02 Command write

C 00 Process not chained 4 01 00000001

P 01 Process 1 ( receiving process) C 00 Parameter not chained T 20 Parameter type ‘integer’

5 21 00100001

N 01 Parameter index 1 6 3E

7 80

Value 3E80h = 16000 = 50%

8 ‘\r’ Carriage Return 9 ‘\n’ Line Feed

3.10.6 Request counter value Request countervalue (cntrvalue) from node 3 process 104, type float. Nr Byte Layout Description 0 ':' 1 06 Length 6 2 03 Node 3 3 04 Command read

C 00 Process not chained (return) 4 68 01101000

P 68 Process 104 (return) C 00 Parameter not chained (return) T 40 Parameter type ‘float’ (return)

5 41 01000001

N 01 Parameter index 1 (return) 6 68 -1101000 P 68 Process 104 7 41 -1000001 T 40 Parameter type ‘float’ P 01 Parameter number 1 ( cntrvalue) 8 ‘\r’ Carriage Return 9 ‘\n’ Line Feed

Page 225: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 24

Answer by node 3 Nr Byte Layout Description 0 ':' 1 08 Length 8 2 03 Node 3 3 02 Command write

C 00 Process not chained 4 68 01101000

P 68 Process 104 ( receiving process) C 00 Parameter not chained T 40 Parameter type ‘float’

5 41 01000001

N 01 Parameter index 1 6 45

7 9C

Parameter value ‘float’ = 5023.96 dec.

8 FF 9 AE 10 ‘\r’ Carriage Return 11 ‘\n’ Line Feed

4 Dual interface operation When operating a controller (reading measured value and sending setpoint) for proper operation it is important that the controller gets its setpoint from the right source. Setpoints may come from different sources: analog input, fieldbus interface or RS232 or may be overruled by close valve or open valve (purge) commands. Therefore it is important to know what is the setpoint source of the controller. This can be set by means of parameter controlmode (process 1, parameter 12). In some cases it is possible that the setpoints may come from 2 sources at the same time. The last send setpoint will be valid and send to the controller. This is the case in controlmode = 0, when setpoints may come through any fieldbus interface or RS232. However, there could be situations where control over the instrument seems impossible. This is the case when the instrument comes into a safe-state e.g. when fieldbus communication is disturbed or disconnected. Valve will be forced to a safe state automatically: closed (NC) or fully open (NO). In case you want to get control back via RS232 operation, you have to change the controlmode. When controlmode gets value 18, safe state will be overruled and sending setpoints via RS232 interface will have effect on the controller again. See also document nr. 9.17.023 for more detailed description about digital instrument parameters and their behaviour.

Page 226: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 25

5 Parameter information

FLOW-BUS is used for parameter value exchange between instruments and operation modules (keyboard or PC-interface). Parameter information consists of several properties for behaviour within the FLOW-BUS system. In the ‘parameter properties’ table you will find a list of parameters and their properties. In the ‘parameter values’ table values are described more detailed if necessary. These list consists mostly of parameters for mode settings. Property description in ‘parameter properties’ table: Item Description Parameter(DDE) unique parameter number (also used for DDE-communication : P(x)) Name parameter name (max. 10 characters)

used for parameter identification process process where parameter is used on FLOW-BUS module

used for communication directly through RS232 when filled in the table, this value has to be used (for parameters located in only 1 process) when empty in the table, process has to be determined from the FLOW-BUS system information (for parameters located in more than one process, f.i. setpoint, measure);

FBnr(parameter) parameter number in process on FLOW-BUS module used for communication directly through RS232

VarType variable type for information about amount of bytes c : (unsigned) char type; 1 byte; value 0..255 i : (unsigned) integer type; 2 bytes; value 0..65535 f : float type, 4 bytes, value +-1.18E-38..+-3.39E+38 (IEEE-floating point notation) l : (unsigned) long type, 4 bytes, value 0..4294967295 data types > 1 byte are MSB first.

VarLength variable length to indicate length of string of chars used in combination with VarType c for transportation of strings through FLOW-BUS: value 0..65535 VarLength indicates the amount of bytes for a parameter type -2: indicates that a string is zero-terminated, not defined for length X : indicates a string with a length of X bytes (characters) 0 : means no info required.

Min minimum value of parameter allowed when parameter is read/written via RS232, the value will be checked on this limit (error when out of limit)

Max maximum value of parameter allowed when parameter is read/written via RS232, the value will be checked on this limit (error when out of limit)

Read indication if parameter is allowed to be read via FLOW-BUS Write indication if parameter is allowed to be written via FLOW-BUS Poll indication if parameter should be polled continuously by RS232 application in order to

keep (changing) parameter information up to date Advanced indication if parameter is for advanced users only these are mainly parameters for

maintenance/service

Secured indication if parameter is secured for use through FLOW-BUS reading this parameter is possible, but changing it needs special handling

High security indication if parameter is highly secured (only few parameters) reading this parameter is possible, but changing it needs special handling

Description short description about meaning of parameter or what it is used for Parameter acceptance: Changing parameter values is possible when a parameter is not read-only and not secured. The range and type of parameters are described in the tables. When parameter values are out of range they will be either 'clipped' on the nearest value allowed or you will get an error message: 'parameter value error'.

Page 227: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 26

(DDE)Parameter numbers: All parameter information is referenced to the parameter number. This is a unique number for a parameter to avoid redundancy. These numbers are needed for DDE communication only. For communication with FLOW-BUS through other ways than DDE: directly via RS232 ASCII-strings or via C-libraries (DOS or Windows), use the parameter numbers for the FLOW-BUS modules (in column FBnr of table Parameter properties). Now you will always have to know the node-address of the instrument on the FLOW-BUS, the process number on the instrument and the parameter number on the instrument. Process nr could be read from the table or has to be determined, when nothing is filled-in. In most cases process number will be = 1. Node-address should be determined also. This is the node-address of the instrument on the FLOW-BUS. Newer RS232 protocols on multibus instruments accept node = 128. When sending messages to this node address, the message will be always accepted, unregarding the node-address of the instrument on the bus. NOTE: It is important to know that not all parameters are available on all FLOW-BUS/Multibus devices. For more details about parameters and their use see also document nr. 9.17.023 for description of digital instruments. If you have the program FLOWDDE, you can also get an overview of which parameters are available on which devices. In other cases ask your local sales representative or send an e-mail to [email protected]. Appendix 1 and 2 will give information about parameters, their properties and their possible values.

Page 228: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

BRONKHORST HIGH-TECH B.V.

9.17.027 Page 27

6 Troubleshooting • RS232 communication problems Check cables. Make sure correct cables are used for

specific purpose. Check address of interface (slave). Sending messages to node 128 will mostly be accepted by the interface. Try to reset the instrument and/or restart your PC/PLC. Make sure your messages are assembled according to FLOW-BUS protocol description. Make sure the parameter values you try to read/write are available and in the correct ranges (check tables). Controller doesn’t respond on setpoints: - Check control mode, when 0 and other fieldbus

gives error: safe state will be entered, resulting in safe setpoint. Can be overruled by making controlmode = 18 (RS232 only operation)

- Alarm or counter module in instrument forces setpoint to alarm setpoint. Reset alarm or counter and proceed.

- Setpoint slope could have very high value. New setpoints will be reached when this slope time has been elapsed. Make setpoint slope smaller.

- Control mode could have other value than 0 or 18. Check function when value is different.

- If measure doesn’t change check forward pressure and piping (evt. shut-off valves).

- Make sure setpoints are within allowed range: 0...32000 (= 0...100%).

- Make sure setpoints are send to proper instrument and process (mostly = 1) and parameter (FBnr for setpoint = 1), and type of data is correct (short integer = 2 bytes MSB first)

Contact local sales representative or service department.

• Other (FLOW-BUS) problems Contact Bronkhorst High-Tech local sales representative or send e-mail describing your problem to: help.flowbus@bronkhorst com

Page 229: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

APPENDIX 1

Parameter properties table

Page 230: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Parameter properties table

Parameternumber

(DDE)

Parametername

Group0

Group1

Group2

Processnumber

FBnr

(par)

VarType

VarLength

Minvalue

Maxvalue

Read Write Poll Secured Highly Secured

Default Value Description

2006-02-01 Page 1 of 5FlowDDE database version V3.49

1 identstrng 13 0 0 c -2 Yes Yes No No No 7SN999999 identnr.+softwareversion[+serialnr.]2 pna 1 0 1 c 0 128 Yes Yes No Yes Yes 0 primary node address: network parameter FLOW-BUS3 sna 1 0 2 c 0 128 Yes Yes No Yes Yes 0 secundary node address: network parameter FLOW-BUS4 nna 1 0 3 c 0 128 Yes Yes No No No 1 next node address: network parameter FLOW-BUS5 lna 1 0 4 c 0 128 Yes Yes No No No 32 last node address: network parameter FLOW-BUS6 arbitrage 1 0 5 c 0 255 Yes Yes No Yes Yes 67 FLOW-BUS arbitrage setting and/or automatic optimization7 initreset 12 0 10 c 0 255 Yes Yes No No No init and reset security key commands for network/parameter settings8 measure 2 0 i -23593 41942 Yes No Yes No No 0 measured value (100% = 32000)9 setpoint 2 18 1 i 0 32767 Yes Yes Yes No No 0 setpoint: wanted value (100% = 32000)

10 setpslope 18 2 i 0 30000 Yes Yes No No No 0 setpoint ramp signal 0..100 % in up to slope x 0.1 sec.11 analoginp 2 18 3 i -23593 41942 Yes No Yes No No 0 analog input signal, normally used for ext. setp. (100% = 32000)12 cntrlmode 18 4 c 0 255 Yes Yes No No No 0 control mode selection for instrument or module13 polycnst A 3 5 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0.0 polynomial constant A (offset)14 polycnst B 3 6 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 1.0 polynomial constant B (span]15 polycnst C 3 7 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0.0 polynomial constant C16 polycnst D 3 8 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0.0 polynomial constant D17 polycnst E 3 9 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0.0 polynomial constant E (offset) for setpoint or power value18 polycnst F 3 10 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 1.0 polynomial constant F (span) for setpoint or power value19 polycnst G 3 11 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0.0 polynomial constant G for setpoint or power value20 polycnst H 3 12 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0.0 polynomial constant H for setpoint or power value21 capacity 3 19 13 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 1.0 maximum value at 100% in sensor base units22 sensortype 3 14 c 0 255 Yes Yes No Yes No 3 sensor type information for actual reading and sensor/controller indication23 capunit 3 19 15 c 0 255 Yes Yes No Yes No 0 pointer to selected actual readout unit (index for list of readout units]24 fluidnr 3 16 c 0 8 Yes Yes No No No 0 fluid number: pointer to polynome, name and cap.25 fluidname 3 17 c 10 Yes Yes No Yes No AIR name of fluid26 claimnode 12 18 c 0 128 Yes Yes No Yes No 0 node address of module with operation rights27 modify 12 19 c 0 255 Yes Yes No No No 0 contains number(s) of changed par (0xXX par nr, 0xFF more than one par cha28 alarminfo 4 20 c 0 255 Yes No Yes No No 0 status information of several alarms/errors in the instrument29 chanamount 17 0 12 c 1 120 Yes Yes No No No 32 amount of channels which can be operated30 firstchan 17 0 13 c 1 120 Yes Yes No No No 1 first channel that can be operated31 lastchan 17 0 14 c 1 120 Yes Yes No No No 32 last channel that can be operated32 hostcontrl 5 9 1 c 0 1 Yes Yes No No No 0 operation by HOST computer enable flag33 alrmmsgTA 5 10 0 c 16 Yes No Yes No No alarm message string with unit type information34 alrmmsgnr 5 10 1 c 16 Yes No Yes No No alarm message string with unit number information35 relstatus 5 10 2 c 8 Yes No No No No status of relays/potential free contacts ('0' = not activated, '1' = activated)36 actualval 5 0 f 0 3.4028E+38 Yes No Yes No No 0 actual value of counter37 signinpsel 5 1 c 8 Yes Yes No No No signal input selection (' '=no value,'+'=pos value,'-'=neg value input)38 resinpsel 5 2 c 8 Yes Yes No No No external reset input enable/disable ('E'=enable,' '=disable)39 limit 5 3 f 0 3.4028E+38 Yes Yes No No No limit/batch for counter in sensor standard units40 delaytime 5 4 c 8 0 99235959 Yes Yes No No No 00000000 delay time string in days,hours,minutes,seconds41 duratntime 5 5 c 8 0 99235959 Yes Yes No No No 00000000 duration time string in days,hours,minutes,seconds42 vlvoutset 5 6 c 8 Yes Yes No No No 00000000 valve output setting ('0'=do nothing, '1'=close valve)43 reloutset 5 7 c 8 Yes Yes No No No LLLLLLLL relay output setting ('L'=low, 'H'=high, 'P'=pulse (1 sec.))44 opermodeTA 5 8 c 0 9 Yes Yes No No No 0 operation mode of T/A module45 readunit 5 9 c 7 Yes No No No No ln/min readout unit string46 readfact 5 10 f 1E-10 1E+10 Yes No No No No 1 readout factor matching readout unit string47 resetunit 5 12 c 0 1 No Yes No No No reset unit command (1=reset T/A unit)48 TdValveDn 6 9 f 0 3.4028E+38 Yes Yes No Yes No 0.1 valve output differentiation time constant downwards49 TdValveUp 6 10 f 0 3.4028E+38 Yes Yes No Yes No 0.1 valve output differentiation time constant upwards50 TdSensorDn 6 11 f 0 3.4028E+38 Yes Yes No Yes No 5.8 sensor signal differentiation time constant downwards51 TdSensorUp 6 12 f 0 3.4028E+38 Yes Yes No Yes No 5.6 sensor signal differentiation time constant upwards52 CycleTime 6 114 12 c 1 255 Yes Yes No Yes No 6 cycle time * 10 msec. main loop signal processing53 AnalogMode 10 115 3 c 0 255 Yes Yes No Yes No 0 analog mode selection for analog operation54 VrefOutput 10 116 6 i 0 65535 Yes Yes No Yes No reference voltage output signal for analog operation55 ValveOut 8 114 1 l 0 16777215 Yes Yes Yes No No 0 valve output signal (24-bit number in range 0…14.3Vdc/0…23.3Vdc)

Page 231: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Parameternumber

(DDE)

Parametername

Group0

Group1

Group2

Processnumber

FBnr

(par)

VarType

VarLength

Minvalue

Maxvalue

Read Write Poll Secured Highly Secured

Default Value Description

2006-02-01 Page 2 of 5FlowDDE database version V3.49

56 DynDispFct 6 117 1 f 0 1 Yes Yes No Yes No 0,001 dynamic display factor for display filter (0=max, 1=min goes with par 57)57 StaDispFct 6 117 2 f 0 1 Yes Yes No Yes No 0,000001 static display factor for display filter (0=max, 1=min goes with par 56)58 CalMode 7 115 1 c 0 255 Yes Yes No Yes No 0 calibration mode selection (not active until cntrlmode has been set to value 9)59 ValveOffst 8 116 7 i -32767 65535 Yes Yes No Yes No 61000 valve offset: amount of DAC steps within 1 potmeter step60 Monitor 2 115 2 c 0 255 Yes Yes No Yes No 7 monitor: output signal (measure) selection for bus and analog output61 AlarmReg1 4 114 2 c 8 Yes Yes No Yes No alarm register containing warning flags62 AlarmReg2 4 114 3 c 8 Yes Yes No Yes No alarm register containing critical error flags63 CalRegZS1 9 116 1 l 0 16777215 Yes Yes No Yes No 210A7D calibration register zero scale input 1 ADC64 CalRegFS1 9 116 2 l 0 16777215 Yes Yes No Yes No 52A513 calibration register full scale input 1 ADC65 CalRegZS2 9 116 3 l 0 16777215 Yes Yes No Yes No 210A7D calibration register zero scale input 2 ADC66 CalRegFS2 9 116 4 l 0 16777215 Yes Yes No Yes No 52A513 calibration register full scale input 2 ADC67 ADCcntrReg 9 114 4 l 0 4294967295 Yes Yes No Yes No 18904E ADC control register68 BridgePotm 9 116 5 c 0 255 Yes Yes No Yes No 0 sensor bridge zero potmeter setting69 AlarmEnble 4 115 4 c 0 255 Yes Yes No Yes No 1 broadcast alarm messsage enable flag70 TestMode 4 115 5 c 0 255 Yes Yes No Yes No 0 test mode selection (not active until cntrlmode has been set to value 5)71 ChanSelect 9 115 6 c 1 32 Yes Yes No Yes No 1 channel selection ADC72 ContrResp 8 114 5 c 0 255 Yes Yes No Yes No 0 controller response for normal steps (128=normal, <128=slower, >128=faster)73 ErrInFilCo 6 117 3 f 0 1 Yes Yes No Yes No 1.0 analog input filter constant (0=max, 1=min)74 ExpSmooCo 6 117 4 f 0 1 Yes Yes No Yes No 1.0 sensor input filter constant (0=max, 1=min)75 AnOutCorZS 10 21 i -32767 65535 Yes Yes No Yes No 32767 analog output correction factor zero scale (meas outp DSCM-A 0=0 other 327676 AnOutCorFS 10 22 i 0 65535 Yes Yes No Yes No 2000 analog output correction factor full scale (meas outp 2000 = 1 * multiplication)77 AnInpCorZS 10 23 i -32767 65535 Yes Yes No Yes No 32767 analog input correction factor zero scale (ext setp DSCM-A 0=0 other 32767=078 AnInpCorFS 10 24 i 0 65535 Yes Yes No Yes No 2000 analog input correction factor full scale (ext setp 2000 = 1 * multiplication)79 TuningMode 7 115 7 c 0 255 Yes Yes No Yes No 0 (auto)tuning mode selection (not active until cntrlmode has been set to value 680 DefVlvType 8 114 6 c 0 255 Yes Yes No Yes No 0 valve type (needed for controlling behaviour)81 GlobModify 12 0 19 c 0 255 Yes Yes No No No 0 contains number(s) of changed processes for indirect polling (0xXX / 0xFF)82 SpanCorr 8 114 7 f 0 1 Yes Yes No Yes No 0.1 correction factor valve curve ratio high/low area83 VlvCrvStps 8 114 8 c -2 Yes Yes No Yes No 20,80 Valve curve correction for controller (max. factor*0.1, flow where factor = 1)84 MemShipNor 8 114 9 c -2 Yes Yes No Yes No 0,5000,10,5000array with memberships for normal Fuzzy controller85 MemShipOp 8 114 10 c -2 Yes Yes No Yes No 0000,3750,2000array with memberships for 0-open Fuzzy controller86 IOStatus 12 20 114 11 c 0 255 Yes Yes No Yes No 4 IO status byte for jumper settings and LED signal modes87 FuzzStNeNo 8 114 13 c -2 Yes Yes No Yes No 30000,-500,-50array with neg nor output steps for Fuzzy contr.88 FuzzStPoNo 8 114 14 c -2 Yes Yes No Yes No 50,500,25000 array with pos nor output steps for Fuzzy contr.89 FuzzStOpen 8 114 15 c -2 Yes Yes No Yes No 90,180,12000 array with open at 0 output steps for Fuzzy contr.90 DeviceType 13 113 1 c 6 Yes No No No No DMFC (FLOW-BUS) device type information string91 ModelNum 13 113 2 c 14 Yes Yes No Yes No F201C-FA model number information string92 SerialNum 13 113 3 c 20 Yes Yes No Yes Yes SN999999A serial number information string (to be changed by Bronkhorst HT only)93 MfrConfig 11 113 4 c 16 Yes Yes No Yes No STANDARD manufacturing configuration information string94 BHT1 14 118 1 c -2 Yes Yes No Yes Yes 01,01,95 special BHT parameter (to be changed by Bronkhorst HT only)95 BHT2 14 118 2 i 0 65535 Yes No No No No 0 special BHT parameter96 BHT3 14 118 3 l -3000000000 3000000000 Yes No No No No 0 special BHT parameter97 BHT4 14 118 4 i 0 65535 Yes No No No No 0 special BHT parameter98 BHT5 14 118 5 c 0 255 Yes No No No No 0 special BHT parameter99 BHT6 14 118 6 c 0 255 Yes Yes No No No 0 special BHT parameter

100 BHT7 14 118 7 c 0 255 Yes No No No No 0 special BHT parameter101 BHT8 14 118 8 c 0 255 Yes No No No No 0 special BHT parameter102 BHT9 14 118 9 l -3000000000 3000000000 Yes No No No No 0 special BHT parameter103 BHT10 14 118 10 c 0 1 No Yes No Yes Yes 0 special BHT parameter (to be changed by Bronkhorst HT only)104 PulseHight 8 114 16 c 0 255 Yes Yes No Yes No 128 height of open at zero pulse train for valve105 Version 13 20 113 5 c 5 Yes No No No No VX.XX revision number of firmware106 PressSensr 20 115 9 c 0 255 Yes Yes No Yes No 0 type of pressure sensor107 BaroPress 20 116 8 f 0 1200 Yes Yes No No No 1013.25 mbar atmospheric (central) barometer pressure108 AnIn1CorZS 10 25 i -32767 65535 Yes Yes No Yes No 32767 analog sensor signal input corr. factor zero scale (DSCM-A 0=0 other 32767=0109 AnIn1CorFS 10 26 i 0 65535 Yes Yes No Yes No 2000 analog sensor signal input correction factor full scale (2000=1*multiplication)110 AnIn2CorZS 10 27 i -32767 65535 Yes Yes No Yes No 32767 analog Vref input correction factor zero scale (DSCM-A 0=0 other 32767=0)111 AnIn2CorFS 10 28 i 0 65535 Yes Yes No Yes No 2000 analog Vref input correction factor full scale (2000=1*multiplication)112 AnOu1CorZ 10 29 i -32767 65535 Yes Yes No Yes No 32767 analog setpoint output correction factor zero scale (DSCM-A 0=0 other 32767=113 AnOu1CorF 10 30 i 0 65535 Yes Yes No Yes No 2000 analog setpoint output correction factor full scale (2000=1*multiplication)114 Reset 12 115 8 c 0 255 No Yes No No No 0 reset facilities (program/alarm/batchcounter)115 UserTag 11 113 6 c -2 Yes Yes No Yes No USERTAG user definable alias string116 AlrmMaxLim 15 97 1 i 0 32767 Yes Yes No Yes No 0 maximum limit for sensor signal to trigger alarm situation

Page 232: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Parameternumber

(DDE)

Parametername

Group0

Group1

Group2

Processnumber

FBnr

(par)

VarType

VarLength

Minvalue

Maxvalue

Read Write Poll Secured Highly Secured

Default Value Description

2006-02-01 Page 3 of 5FlowDDE database version V3.49

117 AlrmMinLim 15 97 2 i 0 32767 Yes Yes No Yes No 0 minimum limit for sensor signal to trigger alarm situation118 AlrmMode 15 97 3 c 0 255 Yes Yes No Yes No 0 alarm mode119 AlrmOutMod 15 97 4 c 0 255 Yes Yes No Yes No 0 alarm relais activity mode during alarm situation120 AlrmStpMod 15 97 5 c 0 1 Yes Yes No Yes No 0 setpoint change enable during alarm situation121 AlrmNwSetp 15 97 6 i 0 32767 Yes Yes No Yes No 0 new/safe setpoint during alarm situation (until reset)122 CntrValue 16 104 1 f 0 9999999.99 Yes Yes Yes Yes No 0 actual counter value123 CntrUnit 16 104 2 c 0 31 Yes Yes No Yes No 0 counter unit124 CntrLimit 16 104 3 f 0 10000000 Yes Yes No Yes No 0 counter limit/batch125 CntrOutMod 16 104 4 c 0 255 Yes Yes No Yes No 0 counter relais activity mode when limit/batch has been reached126 CntrStpMod 16 104 5 c 0 1 Yes Yes No Yes No 0 setpoint change enable during counter limit/batch situation (until reset)127 CntrNwSetp 16 104 6 i 0 32767 Yes Yes No Yes No 0 new/safe setpoint at counter limit/batch situation (until reset) (normally = 0%)128 CntrUntstr 16 104 7 c 4 Yes No No No No ln readout string at counter (informative)129 capunitstr 3 19 31 c 7 Yes Yes No Yes No ln/min readout string at capunit (informative)130 CntrMode 16 104 8 c 0 255 Yes Yes No Yes No 0 counter mode131 HwRev 13 113 7 c 1 Yes No No No No VX.XX minimum required hardware revision level for firmware version132 RCreadfact 17 1 f 1E-10 1E+10 Yes No No No No 1.0 readout factor for direct reading (changes with readunit: local on module, R.O.)133 channumber 17 2 c 1 120 Yes Yes No No No 1 channel number for operation134 masterchan 17 3 c 0 120 Yes Yes No No No 0 master channel for master-slave operation135 RCslavefct 17 4 i 0 32000 Yes Yes No No No 32000 RC slave factor136 inputnode 17 5 c 0 128 Yes Yes No Yes No 3 physical node address for channel number137 inputproc 17 6 c 0 128 Yes Yes No Yes No 1 physical process for channel number138 RCreadunit 17 7 c 7 Yes No No No No ln/min readout unit for direct reading (local variable on module: read only)139 SlaveFact% 18 33 1 f 0 500 Yes Yes No No No 100.0 slave factor for master slave control (setp = master output * slave factor)140 VrefInput 18 33 2 i 0 65535 Yes No Yes No No 0 reference voltage input for setpoint signal141 RespStable 8 114 17 c 0 255 Yes Yes No Yes No 0 controller response when controller is stable: |measure-setpoint| < 2%142 temperatur 19 13 33 7 f -250 500 Yes Yes Yes No No 20 absolute temperature in degrees Celsius143 pressure 19 13 33 8 f -3.4028E+38 3.4028E+38 Yes Yes Yes No No 1013.25 absolute pressure in mbar144 time 19 33 9 f 0 3.4028E+38 Yes No Yes No No 0 time in milliseconds145 calvolume 19 33 10 f 0 3.4028E+38 Yes Yes No Yes No 50 calibrated volume in litres146 sensornr 19 16 c 0 4 Yes Yes Yes No No 0 pointer to sensor number in calibration tube (FPP)147 rangeselct 20 19 115 10 c 0 99 Yes Yes Yes No No 0 Piston Prover operation mode (write) and status information (read back)148 TimeOut 20 2 i 0 30000 Yes Yes No Yes No 0 maximum admitted duration time for specific procedure149 frequency 21 33 9 f 0 100000 Yes No Yes No No 0 frequency in Hz150 imp/m3 20 33 10 f 0 3.4028E+38 Yes Yes No Yes No 42773.4 For FRM and FTM imp/m3 and for FCM imp/kg151 RefVolFlow 19 33 5 f 0 3.4028E+38 Yes No No No No 0 volume flow referenced to normal conditions i.e. 0 °C, 1013.25 hPa(a) in ln/min152 volumeflow 19 33 6 f -3.4028E+38 3.4028E+38 Yes No No No No 0 volume flow at actual conditions in l/min153 delta-p 19 33 11 f -100000 100000 Yes No No No No 0 relative pressure between atmosphere and sensor position154 scalefact 21 33 13 i 1 10000 Yes No No No No 1 scaling factor (multiplication) for readout on display (for optimal resolution)155 sensorname 19 17 c 10 Yes Yes No Yes No SENSOR0 label with information about stopsensor156 RstAlarmEn 15 97 9 c 0 15 Yes Yes No Yes No 15 enable reset of alarm by: keyboard, external signal, FLOW-BUS, automatic157 RstCountEn 16 104 9 c 0 15 Yes Yes No Yes No 7 enable reset of counter by: keyboard, external signal, FLOW-BUS, automatic158 MasterNode 18 33 14 c 1 128 Yes Yes No No No 3 node number of master instrument output signal for a slave159 MasterProc 18 33 15 c 1 128 Yes Yes No No No 1 process number of master instrument output signal for a slave160 InstrNode 18 33 16 c 1 128 Yes Yes No Yes No 3 node number of instrument to be operated by another module (keyboard/displa161 InstrProc 18 33 17 c 1 128 Yes Yes No Yes No 1 process number of instrument to be operated by another module (keyboard/dis162 RangeMin 3 33 18 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0.0 minimum value at 0% for special user readout unit163 RangeMax 3 33 20 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 100.0 Maximum value at 100% for special user readout unit164 Relay/TTL 12 115 11 c 0 1 Yes Yes No Yes No 0 Relay/TTL output setting (disabled when used by alarm or counter)165 RespOpen0 8 114 18 c 0 255 Yes Yes No Yes No 0 Controller response when valve opens from zero166 ContrType 8 114 20 c 0 255 Yes Yes No Yes No 1 Controller settings for special purpose167 PIDKp 8 3 114 21 f 0 3.4028E+38 Yes Yes No Yes No 10 PID factor Kp168 PIDTi 8 114 22 f 0 3.4028E+38 Yes Yes No Yes No 0.05 PID factor Ki169 PIDTd 8 114 23 f 0 3.4028E+38 Yes Yes No Yes No 0 PID factor Kd170 Density 3 33 21 f 0 3.4028E+38 Yes Yes No Yes No 1.293 Density of selected fluid in kg/m3171 CalCertNr 13 3 113 8 c -2 Yes Yes No Yes Yes Number of calibration certificate (last basic calibration)172 CalDate 13 3 113 9 c 8 Yes Yes No Yes Yes 19991231 Date of last (basic) calibration173 ServiceNr 13 113 10 c 15 Yes Yes No Yes Yes 00000000 Servicenumber for repair/rebuilding/recalibration174 ServDate 13 113 11 c 8 Yes Yes No Yes Yes 19991231 Date of last service action175 IdentNr 13 113 12 c 0 255 Yes Yes No Yes Yes 7 Identification number (type) of instrument/device176 BHT11 14 118 11 c 0 255 No Yes No Yes Yes 0 special BHT parameter (to be changed by Bronkhorst HT only)177 PowerMode 12 115 12 c 0 50 Yes Yes No Yes No 0 power supply indication in Vdc

Page 233: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Parameternumber

(DDE)

Parametername

Group0

Group1

Group2

Processnumber

FBnr

(par)

VarType

VarLength

Minvalue

Maxvalue

Read Write Poll Secured Highly Secured

Default Value Description

2006-02-01 Page 4 of 5FlowDDE database version V3.49

178 Pupstream 13 3 113 13 f -100000 100000 Yes Yes No Yes No 3 upstream pressure of fluid in bara (for first fluidnr only)179 Pdownstrm 13 3 113 14 f -100000 100000 Yes Yes No Yes No 1 downstream pressure of fluid in bara (for first fluidnr only)180 Orifice 13 113 15 f 0 1000 Yes Yes No Yes No 1 orifice diameter in mm181 FluidTemp 13 3 113 16 f -273.15 3.4028E+38 Yes Yes No Yes No 20 temperature of fluid through instrument (for first fluidnr only)182 AlrmDelay 15 97 7 c 0 255 Yes Yes No Yes No 3 time alarm and reset action will be delayed when alarm limit has been exceede183 capacity0% 3 33 22 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 capacity of instrument at zero 0% in sensor base units (mostly equal to zero)184 NumOfChan 12 0 18 c 0 120 Yes No No No No 1 number of instrument channels available for this device185 DeviceFunc 12 0 20 c 0 255 Yes No No No No 5 function of device186 ScanChan 4 123 1 c 1 255 Yes Yes No No No 1 Channel number to scan with real time information (to be set once)187 ScanPar 4 123 3 c 0 255 Yes Yes No No No 8 Parameter number to scan with real time information (to be set once)188 ScanTime 4 123 4 i 0 65535 Yes Yes No No No 50 Scan interval time in msec between two samples (to be set once)189 ScanData 22 4 123 10 c -2 Yes No No No No Scanned data with time label (can be readout event by event)190 ValveOpen 8 114 24 f 0 24 Yes Yes No Yes No 0.04 First-step offset current/voltage for valve when opening from 0%191 NrOfRuns 20 115 13 c 0 255 Yes Yes No No No 1 Amount of runs of a piston prover (0 = stability check)192 MinProTime 20 115 14 c 0 255 Yes Yes No No No 10 Minimum process time of a piston prover in 0.1 seconds193 LeakRate 20 116 9 f 0 1 Yes Yes No Yes No 0.0001 Leak rate piston prover194 ModeInfReq 12 115 15 c 4 Yes Yes No Yes No Sets instr. in info mode for 1 read-cycle to check available parameter options195 ModeInfOpt 12 115 16 c 255 Yes No No No No Gives info about possible values of a mode in an array as result of ModeInfo re196 ModeInfDes 12 115 17 c 255 Yes No No No No Gives description about one of the mode options197 CalType 20 115 18 c 0 255 Yes Yes No Yes No 0 Enables/disables options for calibration device (8 bits for 8 options)198 MassFlow 20 33 4 f -3.4028E+38 3.4028E+38 Yes No Yes No No 0 Real mass flow in kg/min199 BusAddress 23 125 10 c 0 255 Yes Yes No Yes No 2 Station address for actual fieldbus system other than FLOW-BUS200 InterfConf 23 125 3 c 0 3 Yes Yes No No Yes 1 Configuration setting for interface to other bus-systems201 Baudrate 23 125 9 l 0 1E+10 Yes Yes No Yes No 12000000 Baudrate for actual fieldbus system other than FLOW-BUS202 BusDiagnos 23 125 20 c -2 Yes No No No No Bus diagnose string for actual fieldbus system other than FLOW-BUS203 NrOfVanes 20 115 22 c 0 255 Yes Yes No Yes No 10 Number of vanes for use in a rotor meter204 Fieldbus 23 125 21 c -2 Yes No No No No FLOW-BUS Fieldbus for which instrument has been equiped205 fMeasure 2 33 0 f -3.4028E+38 3.4028E+38 Yes No No No No 0 measured value for direct reading (in capunits, max.= capacity)206 fSetpoint 2 18 33 3 f -3.4028E+38 3.4028E+38 Yes Yes No No No 0 setpoint: wanted value for direct reading (in capunits, max.= capacity)207 Mass 20 33 23 f -3.4028E+38 3.4028E+38 Yes No Yes No No 0 Mass in g208 Mstatus 4 119 1 c 3 Yes No No No No Manufacturer Status register (1 byte diag code + 2 byte diag bits)209 Mwarning 4 119 2 c 3 Yes No No No No Manufacturer Warning register (1 byte diag code + 2 byte diag bits)210 Merror 4 119 3 c 3 Yes No No No No Manufacturer Error register (1 byte diag code + 2 byte diag bits)211 DiagHist 4 119 4 c -2 Yes Yes No No No Diagnostic history string (contains history of diag codes)212 DiagMode 4 119 5 c 0 255 Yes Yes No Yes No 0 Diagnostic mode (0 = diagnostics off, 1 = diagnostics on)213 MStatEnabl 4 119 6 c 0 255 No Yes No No No 0 Manufacturer Status enable (0-127 or 254 = disable all, 255 = enable all)214 AnOutZA 10 116 21 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 Analog measure output, zero adjust215 AnOutSA 10 116 22 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 1 Analog measure output, span adjust216 AnInZA 10 116 23 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 Analog setpoint input, zero adjust217 AnInSA 10 116 24 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 1 Analog setpoint input, span adjust218 SensInZA 10 116 25 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 Sensor input, zero adjust219 SensInSA 10 116 26 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 1 Sensor input, span adjust220 TempInZA 10 116 27 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 Sensor temperature input, zero adjust221 TempInSA 10 116 28 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 1 Sensor temperature input, span adjust222 ExpSmooAd 6 117 5 f 0 1 Yes Yes No Yes No 1.0 Sensor input filter adapt setting223 SlopeSetp 18 33 24 i 0 32000 Yes Yes No Yes No 32000 Slope setpoint step. Setpoint step for the given slopetime224 FilterLen 6 117 6 i 0 255 Yes Yes No Yes No 1 Number of samples for Average filter225 fAccuracy 2 33 25 f -3.4028E+38 3.4028E+38 Yes No No No No 0 Actual accuracy in current unit226 LookI 3 33 26 c 0 20 Yes Yes No No No 0 Lookup table for linearisation index (x and y direction)227 LookX 3 33 27 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 Lookup table for linearisation x228 LookY 3 33 28 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 Lookup table for linearisation y229 LookTempI 3 33 29 c 0 1 Yes Yes No No No 0 Lookup table for linearisation at certain temperature index (z direction)230 LookTemp 3 33 30 f -273.15 3.4028E+38 Yes Yes No Yes No 0 Lookup table for linearisation at certain temperature (z)231 ValveMax 8 114 25 f 0 24 Yes Yes No Yes No 0.2 Maximum current/voltage for valve232 ValveMode 8 114 26 c 0 255 Yes Yes No Yes No 1 Valve output mode selection (0 = voltage, 1 = current)233 VlvOpenCor 8 114 27 f 0 1.5 Yes Yes No Yes No 0.96 Valve open current/voltage correction (example: 0.96, Open = ValveOpen * 0.9234 VlvZeroHld 8 114 28 f 0 1 Yes Yes No Yes No 0 Valve hold current/voltage at %0 setp (example: 0.8, Hold = ValveOpen * 0.8)235 ValveSlope 8 114 29 f 0 50 Yes Yes No Yes No 0.009 Valve slope time (Seconds)236 IFIData 23 0 21 c -2 Yes Yes No No No 0 IFI data dump protocol communication string237 RangeUsed 20 115 20 c 0 99 Yes No Yes No No 0 Piston Prover information about used sensors238 FldSetProp 3 33 31 c 0 255 Yes Yes No Yes Yes 0 Fluidset properties

Page 234: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Parameternumber

(DDE)

Parametername

Group0

Group1

Group2

Processnumber

FBnr

(par)

VarType

VarLength

Minvalue

Maxvalue

Read Write Poll Secured Highly Secured

Default Value Description

2006-02-01 Page 5 of 5FlowDDE database version V3.49

239 LUnitType 3 33 12 c 0 255 Yes Yes No Yes Yes 0 Lookup table capacity unit type240 LUnTypNam 3 33 13 c 20 Yes Yes No Yes Yes Lookup table capacity unit type name (informative)241 LUnit 3 33 16 c 0 255 Yes Yes No Yes Yes 0 Lookup table capacity unit (unit LUTy)242 LUnitName 3 33 17 c 7 Yes Yes No Yes Yes kg/s Lookup table capacity unit name (informative)243 CUnitType 3 1 29 c 0 255 Yes Yes No Yes No 0 Output capacity unit type244 CUnTypNam 3 1 30 c 20 Yes Yes No Yes No Output capacity unit type name (informative)245 CUnTypTem 3 33 10 f -273.15 3.4028E+38 Yes Yes No Yes No 0 Output capacity unit type temperature (°C)246 CUnTypPres 3 33 11 f 0 3.4028E+38 Yes Yes No Yes No 1 Output capacity unit type pressure (bar (a))247 CapMin 3 1 27 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 Minimum capacity in output capacity units248 CapMax 3 1 28 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 1 Maximum capacity in output capacity units249 FormulaTyp 3 113 17 i 0 65535 Yes Yes No Yes No 0 Formula type needed for conversion250 HeatCap 3 113 18 f 0 3.4028E+38 Yes Yes No Yes No 0 Heat capacity (Cp)251 ThermCond 3 113 20 f 0 3.4028E+38 Yes Yes No Yes No 0 Thermal conductivity (lambda)252 Viscosity 3 113 21 f 0 3.4028E+38 Yes Yes No Yes No 0 Viscosity253 NormMasFlw 3 113 22 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 1 Normalized mass flow in ln/min air equivalent254 Kspeed 8 3 114 30 f 0 3.4028E+38 Yes Yes No Yes No 1 Controller speed factor (gain)255 SensorCode 13 113 23 i 0 65535 Yes Yes No Yes Yes 0 Sensor code256 SensorRevC 13 113 24 c 0 255 Yes Yes No Yes Yes 0 Sensor revision code257 RestrCode 13 113 25 i 0 65535 Yes Yes No Yes Yes 0 Restriction code258 RestrRevC 13 113 26 c 0 255 Yes Yes No Yes Yes 0 Restriction revision code259 RestrNxP 13 113 27 l 0 2147483648 Yes Yes No Yes Yes 0 Restriction NxP (proportional to air equivalent capacity of LFE)260 Seals 13 113 28 c 16 0 255 Yes Yes No Yes Yes V,V Seals information (1st byte = other, 2nd = plunger seal)261 ValveCode 13 113 29 i 0 65535 Yes Yes No Yes Yes 0 Valve code262 ValveRevC 13 113 30 c 0 255 Yes Yes No Yes Yes 0 Valve revision code263 InstrProp 13 113 31 l 0 2147483648 Yes Yes No Yes Yes 0 Instrument properties264 LookFreqI 3 116 10 c 0 1 Yes Yes No Yes No 0 Lookup table for frequency index265 LFFreq 3 116 11 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 Lookup table for frequency frequency266 LFTemp 3 116 12 f -273.15 3.4028E+38 Yes Yes No Yes No 0 Lookup table for frequency temperature267 LFDensity 3 116 13 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 Lookup table for frequency density268 LFSpanAdj 3 116 14 f -3.4028E+38 3.4028E+38 Yes Yes No Yes No 0 Lookup table for frequency span adjust269 0 0 0 0 0 No No No No No dummy parameter (for now)270 DensityAct 3 116 15 f -3.4028E+38 3.4028E+38 Yes No No No No 0 Actual density, measured by instrument

Page 235: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

APPENDIX 2

Parameter values table

Page 236: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Parameter values table

Parameternumber

(DDE)

Parametername

Filter Value Description

2006-02-01 Page 1 of 5FlowDDE database version V3.49

6 arbitrage temporary busmaster16 arbitrage always busmaster26 arbitrage automatic busmaster36 arbitrage auto busmaster and auto bus optimalization (fast token ring)67

12 cntrlmode setpoint = 100%712 cntrlmode (FPP) Manual start sensor select, automatic end sensor1512 cntrlmode (FPP) Range select mode1412 cntrlmode setpoint = keyboard OR FLOW-BUS setpoint1112 cntrlmode setpoint = master output(analog in) * slave factor(FLOW-BUS)1012 cntrlmode tuningmode enable (select subtject with par 79)612 cntrlmode purge valve (fully open)812 cntrlmode setpoint = RS232 setpoint1812 cntrlmode setpoint = master output(FLOW-BUS) * slave factor(FLOW-BUS)212 cntrlmode close valve312 cntrlmode setpoint idle (no reaction on changes in sensor signal)412 cntrlmode testmode enable (select subject with par 70)512 cntrlmode calibration mode enable (select subject with par 58)912 cntrlmode (FPP) Automatic start and end sensor1712 cntrlmode setpoint = analog input112 cntrlmode RS232 broadcast mode1912 cntrlmode valve stearing (valve = setpoint)2012 cntrlmode analog valve stearing (valve = analog setpoint)2112 cntrlmode setpoint = 0%1212 cntrlmode setpoint = master output(FLOW-BUS) * slave factor(analog in)1312 cntrlmode setpoint = BUS setpoint012 cntrlmode (FPP) Automatic start sensor select, manual end sensor1622 sensortype liquid/gas mass (sensor)13022 sensortype liquid volume (sensor)12922 sensortype pressure (sensor)12822 sensortype other sensor type (controller)422 sensortype liquid volume (controller)122 sensortype liquid/gas mass (controller)222 sensortype other sensor type (sensor)13222 sensortype pressure (controller)022 sensortype gas volume (controller)322 sensortype gas volume (sensor)13128 alarminfo &H01 at least 1 error message in alarm error status register128 alarminfo &H02 no warning message in alarm warning status register028 alarminfo &H04 no minimum alarm message (measure>minimum limit)028 alarminfo &H08 no maximum alarm message (measure<maximum limit)028 alarminfo &H10 batch counter has not reached its limit028 alarminfo &H20 response O.K. (setpoint-measure within limit)028 alarminfo &H80 hardware O.K.028 alarminfo &H02 at least 1 warning message in alarm warning status register128 alarminfo &H08 maximum alarm message for measured signal128 alarminfo &H20 response alarm message: setpoint-measure is too high128 alarminfo &H40 master output signal not received: check master instrument128 alarminfo &H80 hardware error message: check your hardware128 alarminfo &H10 batch counter has reached its limit128 alarminfo &H40 master output signal O.K. (or not used)028 alarminfo &H04 minimum alarm message for measured signal128 alarminfo &H01 no error message in alarm error status register044 opermodeTA A: MAX & RESP; T: DOWN FROM LIMIT344 opermodeTA A: MIN & RESP; T: DOWN AND REPEAT444 opermodeTA A: MAXIMUM ALARM; T: ALWAYS UP544 opermodeTA A: MINIMUM ALARM644 opermodeTA A: MAX & RESP AUTO; T: UP TO LIMIT144 opermodeTA A: RESPONSE ALARM744 opermodeTA A: MIN & RESP AUTO; T: UP AND REPEAT244 opermodeTA OFF053 AnalogMode &H3F 4...20 mA operation353 AnalogMode &H3F 0...20 mA operation253 AnalogMode &H3F 15...20 mA operation453 AnalogMode &H3F 0...5 Vdc operation053 AnalogMode &H80 Analog output disabled153 AnalogMode &H80 Analog output enabled053 AnalogMode &H40 Analog input disabled153 AnalogMode &H40 Analog input enabled053 AnalogMode &H3F 0...10 Vdc operation158 CalMode adjust Vref output by connecting it to analog in1058 CalMode adjust analog out by connecting it to analog in1158 CalMode zero sensor bridge circuit958 CalMode dmfc8

Page 237: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Parameternumber

(DDE)

Parametername

Filter Value Description

2006-02-01 Page 2 of 5FlowDDE database version V3.49

58 CalMode dmfc758 CalMode dmfc658 CalMode dmfc458 CalMode adjust valveoutput by connecting it to analog in1258 CalMode dmfc258 CalMode adc self calibration158 CalMode adjust heater balance1858 CalMode idle: no action058 CalMode dmfc358 CalMode analog output = 0 %1558 CalMode dmfc558 CalMode analog output = 50 %1758 CalMode dmfc1358 CalMode analog output = 100 %1658 CalMode dmfc1460 monitor analog input signal960 monitor (filtered) setpoint060 monitor mass flow in display unit (normally ln/min)1160 monitor mass flow in kg/min1960 monitor time in msec/frequency in Hz.1560 monitor atmospheric (barometer) pressure in mbara1860 monitor delta-P pressure in mbarg1760 monitor calibrated volume at actual sensor in ml1660 monitor normal sensor signal (Output)860 monitor power supply voltage1060 monitor controller error input signal160 monitor volume flow in l/min1260 monitor pressure absolute in mbara1460 monitor temperature in °C1360 monitor controller output signal to valve260 monitor differentiator output filtered760 monitor differentiator output660 monitor linearization output560 monitor sensor signal slow filtered460 monitor sensor signal slow361 AlarmReg1 &H8000000000000000 Diagnostics available in warning register161 AlarmReg1 &H8000000000000000 No diagnostics available in warning register062 AlarmReg2 &H8000000000000000 No diagnostics available in error register062 AlarmReg2 &H8000000000000000 Diagnostics available in error register167 ADCcntrReg &H1C0000 ADC gain = 8x367 ADCcntrReg &H020000 ADC input channel 1 selection067 ADCcntrReg &H010000 ADC no power down mode (normal)067 ADCcntrReg &H1C0000 ADC gain = 64x667 ADCcntrReg &H1C0000 ADC gain = 16x467 ADCcntrReg &H020000 ADC input channel 2 selection167 ADCcntrReg &H1C0000 ADC gain = 4x267 ADCcntrReg &H1C0000 ADC gain = 2x167 ADCcntrReg &H1C0000 ADC gain = 1x067 ADCcntrReg &HE00000 ADC read/write FS calibration coefficients on sel. channel767 ADCcntrReg &HE00000 ADC read/write ZS calibration coefficients on sel. channel667 ADCcntrReg &HE00000 ADC activate background calibration on selected channel567 ADCcntrReg &HE00000 ADC activate system offset calibration on selected channel467 ADCcntrReg &HE00000 ADC activate system calibration FS on selected channel367 ADCcntrReg &HE00000 ADC activate self calibration on selected channel167 ADCcntrReg &HE00000 ADC normal (sampling) mode067 ADCcntrReg &H010000 ADC power down mode167 ADCcntrReg &H1C0000 ADC gain = 128x767 ADCcntrReg &HE00000 ADC activate system calibration ZS on selected channel267 ADCcntrReg &H001000 ADC unipolar mode167 ADCcntrReg &H008000 ADC 24-bit word length167 ADCcntrReg &H004000 ADC output compensation current off067 ADCcntrReg &H004000 ADC output compensation current on167 ADCcntrReg &H002000 ADC burn-out current off067 ADCcntrReg &H002000 ADC burn-out current on167 ADCcntrReg &H001000 ADC bipolar mode067 ADCcntrReg &H008000 ADC 16-bit word length067 ADCcntrReg &H1C0000 ADC gain = 32x569 AlarmEnble enable169 AlarmEnble disable070 TestMode IO270 TestMode FRAM470 TestMode RAM370 TestMode keyboard1270 TestMode uProcessor170 TestMode ADC570 TestMode sensor770 TestMode FLOW-BUS1070 TestMode DAC6

Page 238: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Parameternumber

(DDE)

Parametername

Filter Value Description

2006-02-01 Page 3 of 5FlowDDE database version V3.49

70 TestMode Vref970 TestMode valve drive circuit870 TestMode calibration1170 TestMode idle; no action071 ChanSelect AD channel 1171 ChanSelect AD channel 2279 TuningMode Fuzzy controller open at zero479 TuningMode Fuzzy controller normal operation379 TuningMode sensor179 TuningMode idle; no action079 TuningMode valve279 TuningMode PID controller580 DefVlvType normally opened180 DefVlvType normally closed inverse controlled280 DefVlvType normally opened inverse controlled380 DefVlvType remain position480 DefVlvType normally closed086 IOStatus &H01 don't read diagnostic jumper (no diagnostics, read/write)186 IOStatus &H40 analog jumper set (read only)186 IOStatus &H80 micro switch pressed (read only)186 IOStatus &H10 diagnostic jumper set (read only)186 IOStatus &H08 don't read micro switch (always off, read/write)186 IOStatus &H03 don't read analog jumper (use cntrlmode, read/write)186 IOStatus &H03 Red LED blinking fast386 IOStatus &H03 Red LED off086 IOStatus &H20 initialization jumper set (read only)186 IOStatus &H02 not used1

106 PressSensr absolute pressure 800-1100 mbar3106 PressSensr delta-P 0...10" W.C.1106 PressSensr delta-P 0...1 PSI7106 PressSensr absolute pressure 800-1200 mbar2106 PressSensr delta-P -10...+10 "W.C.6106 PressSensr delta-P -10...0 "W.C.5106 PressSensr delta-P -5...0 "W.C.4106 PressSensr delta-P 0..5" W.C.0106 PressSensr delta-P -1...0 PSI8114 Reset restart batch counter3114 Reset reset counter value (counter off)4114 Reset reset alarm2114 Reset reset counter value (no mode change) or common reset1114 Reset Reset module (soft reset)5114 Reset no reset0118 AlrmMode off0118 AlrmMode alarm on absolute limits1118 AlrmMode alarm on limits related to setpoint (response alarm)2118 AlrmMode alarm when instrument powers-up (eg. after power-down)3119 AlrmOutMod no relais activity at alarm0119 AlrmOutMod relais activated until reset2119 AlrmOutMod relais pulses until reset1120 AlrmStpMod no setpoint change at alarm0120 AlrmStpMod new/safe setpoint at alarm enabled (set at par 121)1125 CntrOutMod relais activated after reaching batch limit until reset2125 CntrOutMod relais pulses after reaching batch limit until reset1125 CntrOutMod no relais activity at batch limit0126 CntrStpMod setpoint change at batch limit disabled0126 CntrStpMod setpoint change at batch limit enabled1130 CntrMode off0130 CntrMode counting up to limit (batchcounter)2130 CntrMode counting upwards continuously1147 rangeselct run calibration with automatic range selection9147 rangeselct calibration ready/stop0147 rangeselct run calibration until stopsensor 1/select range 11147 rangeselct run calibration until stopsensor 2/select range 22147 rangeselct run calibration until stopsensor 3/select range 33147 rangeselct run calibration and select range 55147 rangeselct run until stopsensor 1 until 3 values between limit19147 rangeselct run until stopsensor 2 until 3 values between limit29147 rangeselct run until stopsensor 3 until 3 values between limit39147 rangeselct run until stopsensor 4 until 3 values between limit49147 rangeselct run and select range 5 until 3 values between limit59147 rangeselct run with auto-select + 3 values between limit99147 rangeselct run calibration until stopsensor 4/select range 44156 RstAlarmEn reset: automatic or keyboard9156 RstAlarmEn reset: automatic or keyboard or external11156 RstAlarmEn no reset possible0156 RstAlarmEn reset: automatic or FLOW-BUS or keyboard or external15156 RstAlarmEn reset: automatic or FLOW-BUS or external14156 RstAlarmEn reset: automatic or FLOW-BUS12

Page 239: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Parameternumber

(DDE)

Parametername

Filter Value Description

2006-02-01 Page 4 of 5FlowDDE database version V3.49

156 RstAlarmEn reset: automatic or external10156 RstAlarmEn reset: FLOW-BUS or keyboard or external7156 RstAlarmEn reset: automatic8156 RstAlarmEn reset: FLOW-BUS or external6156 RstAlarmEn reset: FLOW-BUS or keyboard5156 RstAlarmEn reset: FLOW-BUS4156 RstAlarmEn reset: keyboard or external3156 RstAlarmEn reset: external2156 RstAlarmEn reset: keyboard1156 RstAlarmEn reset: automatic or FLOW-BUS or keyboard13157 RstCountEn reset: automatic or FLOW-BUS or keyboard13157 RstCountEn reset: automatic8157 RstCountEn reset: automatic or FLOW-BUS or external14157 RstCountEn reset: automatic or FLOW-BUS12157 RstCountEn reset: automatic or keyboard or external11157 RstCountEn reset: automatic or external10157 RstCountEn reset: automatic or keyboard9157 RstCountEn reset: automatic or FLOW-BUS or keyboard or external15157 RstCountEn reset: keyboard1157 RstCountEn reset: external2157 RstCountEn reset: keyboard or external3157 RstCountEn reset: FLOW-BUS or external6157 RstCountEn reset: FLOW-BUS4157 RstCountEn reset: FLOW-BUS or keyboard or external7157 RstCountEn no reset possible0157 RstCountEn reset: FLOW-BUS or keyboard5166 ContrType &H40 controller special mode (valve output steps) turned on1166 ContrType &H08 voltage drift compensation for valve output turned off1166 ContrType &H40 controller special mode (valve output steps) turned off0166 ContrType &H20 voltage drift compensation for valve output turned off1166 ContrType &H04 monitor output changed at setpoint steps1166 ContrType &H20 voltage drift compensation for valve output turned on0166 ContrType &H04 fixed monitor output signal0166 ContrType &H02 open from zero with ramp output to valve1166 ContrType &H02 open from zero with PID output to valve0166 ContrType &H01 valve in safe position after startup1166 ContrType &H01 valve in normal position after startup0166 ContrType &H10 auto slope enabled for pilot valves1166 ContrType &H10 auto slope disabled0166 ContrType &H08 voltage drift compensation for valve output turned on0175 IdentNr FLOW-BUS Balance Interface26175 IdentNr FLOW-BUS Switch Interface32175 IdentNr Keithley FLOW-BUS Interface31175 IdentNr Instrument FLOW-BUS Interface30175 IdentNr FLOW-BUS Interface Climate Control29175 IdentNr CoriFlow Controller27175 IdentNr T/A-module5175 IdentNr FLOW-BUS Coriolis Meter25175 IdentNr Profibus-DP/FLOW-BUS interface module24175 IdentNr CoriFlow Meter28175 IdentNr DSCM-A: digital single channel module for analog instruments14175 IdentNr RS232/FLOW-BUS interface1175 IdentNr DSCM-E: evaporator controller module (single channel)20175 IdentNr DSCM-C: digital single channel module for calibrators21175 IdentNr DDCM-A: digital dual channel module for analog instruments22175 IdentNr DMCM-D: digital multi channel module for digital instruments23175 IdentNr F/A-module: special version of T/A-module19175 IdentNr DEPM: digital electronic pressure meter10175 IdentNr FPP: FLOW-BUS piston prover/tube (calibration-instrument)18175 IdentNr FTM: FLOW-BUS turbine meter (calibration-instrument)17175 IdentNr ADDA4 (4 channels)3175 IdentNr DSCM-D: digital single channel module for digital instr.15175 IdentNr PC(ISA) interface2175 IdentNr DLFM: digital liquid flow meter13175 IdentNr DLFC: digital liquid flow controller12175 IdentNr ACT: single actuator11175 IdentNr DEPC: digital electronic pressure controller9175 IdentNr DMFM: digital mass flow meter8175 IdentNr DMFC: digital mass flow controller7175 IdentNr ADDA1: 1 channel ADDA converter module6175 IdentNr R/C-module, 32 channels4175 IdentNr FRM: FLOW-BUS rotor meter (calibration-instrument)16185 DeviceFunc Meter6185 DeviceFunc Unknown0185 DeviceFunc (Protocol) converter8185 DeviceFunc Operator3185 DeviceFunc ADDA2185 DeviceFunc Interface1

Page 240: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

Parameternumber

(DDE)

Parametername

Filter Value Description

2006-02-01 Page 5 of 5FlowDDE database version V3.49

185 DeviceFunc Supervisor (totalizer/alarm)4185 DeviceFunc Controller5185 DeviceFunc Special7197 CalType &H01 Automatic capacity setting for optimal resolution0197 CalType &H01 Manual capacity setting for optimal resolution1197 CalType &H02 Barometer value input via parameter 107: BaroPress0197 CalType &H02 Barometer is master; input automatically from master1200 InterfConf Configuration B: 14 ch. Standard parms with fixed chan list1200 InterfConf Configuration A: 14 ch. Standard parms. with network scan0200 InterfConf Configuration C: 7 ch. Extended parms with fixed chan list2200 InterfConf Configuration D: 11 ch. Extended parms with network scan3208 Mstatus &H800000 No diagnostics available in manufacturer status register0208 Mstatus &H800000 Diagnostics available in manufacturer status register1209 Mwarning &H800000 No diagnostics available in manufacturer warning register0209 Mwarning &H800000 Diagnostics available in manufacturer warning register1210 Merror &H800000 No diagnostics available in manufacturer error register0210 Merror &H800000 Diagnostics available in manufacturer error register1212 DiagMode Debug mode on1212 DiagMode Debug mode off0213 MStatEnabl clear all status bits254213 MStatEnabl set status bit (range 0…127)127213 MStatEnabl set status bit (range 0…127)0213 MStatEnabl set all status bits255232 ValveMode voltage drive mode0232 ValveMode current drive mode1238 FldSetProp &H01 Fluidset enabled1238 FldSetProp &H04 Fluidset is not actual calibrated0238 FldSetProp &H02 Fluidset is not set by Bronkhorst High-Tech0238 FldSetProp &H01 Fluidset is disabled0238 FldSetProp &H02 Fluidset is set by Bronkhorst High-Tech2238 FldSetProp &H04 Fluidset is actual calibrated4263 InstrProp &H04 Instrument is not multi-range multi-fluid capable0263 InstrProp &H01 Instrument has polynomial1263 InstrProp &H02 Instrument has lookup table for linearization2263 InstrProp &H04 Instrument is multi-range multi-fluid capable3263 InstrProp &H01 Instrument has no polynomial0263 InstrProp &H02 Instrument has no lookup table for linearization0

Page 241: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

1

Interface Design DocumentFlow-Bus DLL FOR WIN32

Interface Design Document Project: BHT934.2Author: G. Binnenmars Title: Interface Design Document

FlowBus DLL FOR WIN 32Approved: Revision: P1D

Date: 1999-03-04Filename: IDDFLD32.DOC

Page 242: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

1

1 SCOPE 2

1.1 Identification 2

1.2 System Overview 2

1.3 Document overview 2

1.4 Document history 2

2 APPLICABLE DOCUMENTS 3

3 APPLICATION INTERFACE DESIGN 4

3.1 Introduction 4

3.2 Reference 43.2.1 Data-structures 43.2.2 API - functions 43.2.3 Error values 12

3.3 Procedures 143.3.1 Using the DLL 143.3.2 Open and Closing communication 143.3.3 Configuring communication 143.3.4 Sending / Receiving data 153.3.5 Database functions 16

4 PHYSICAL INTERFACE DESIGN 17

A. EXAMPLE APPLICATION PROGRAM 18

Page 243: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

2

1 SCOPE

1.1 IDENTIFICATIONThis document describes the design of the interface between the Flow-Bus communicationDLL and applications using this DLL.

1.2 SYSTEM OVERVIEWThe systems E6000 and E7000 of Bronkhorst allow the control and the security of differentflow-systems. A communication network (3T-NET) connects the modules in these systems.The systems can be controlled from the PC. There are several levels at which the control canoccur. At a low level there is a RS232 interface to the system. Above it is a Windows DLL thatallows different applications to communicate with the system. At the top is a Windows DDEwhich also allows different application to communicate with the system, but then lessknowledge about the internals of the system (the PROPAR modal) is required.

The overview of the Flow-Bus DDE and the various parts is given in the next figure.

application

Flowbus

DDE DLL

3T-Net

RS232

network

Host

application

application

Figure 1 System overview

1.3 DOCUMENT OVERVIEWThis document contains the following parts:• chapter 2 gives a reference of applicable documents• chapter 3 gives the interface design• chapter 4 gives the interface to the lower layers• appendix A shows a programming example

1.4 DOCUMENT HISTORYRevision Author DescriptionP1A G. Binnenmars Initial versionP1B G.,Binnenmars Update after implementationP1C G. Binnenmars Final release

Page 244: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

3

2 APPLICABLE DOCUMENTS

[1] Title:

Author:Doc.no:Revision:

Software Design DocumentPROPAR DLL (in Dutch)G. BinnenmarsRAP\121BHT.R10P1A

[2] Title:

Author:Doc.no:Revision:

Interface Design DocumentRS232 Protocol between PCand FlowBus host and DPMprotocol between PC and PCISA card.W. KlarenIDDFBRS.DOCP1B

[3] Title:

Author:Doc.no:Revision:

Instruction Manual DigitalReadout and Control System E-6000 serie.-Preliminary version 28-11-1991

[4] Title:

Author:Doc. No:Revision:

Software Design DocumentFlow-Bus DLL FOR WIN32G. BinnenmarsSDDFLD32_B.DOCP1B

Page 245: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

4

3 Application interface design

3.1 INTRODUCTIONThe interface from the PC to the DLL is based on several “C-functions” exported by the DLL.The data exchanged between application and DLL consists of minimal PROPAR informationand on application identification. See [3] for a definition of the PROPAR protocol.

3.2 REFERENCE

3.2.1 Data-structures

Several data-types used by the DLL and available for the applications are given below. Thefollowing conversion is used:• char, 1 byte• int, 2 bytes• float, 4 bytes• long, 4 bytes

Type Description RemarksHWND Windows typedef used for

handle of a windowsize is long

typedef int APPL_ID Unique applicationidentification number

size is int

typedef struct{int NrPorts,int PortNameLen,bool bInUse,char *szPortName…..} PORT_INFO

Gives an overview of thenumber of ports in the PC, andfor each port, the length of theport name, an in use indicationand the port name.

Size is varying

3.2.2 API - functions

The following functions are exported by the DLL.

Function Description Parameters Returnint OpenDLL(HWND hWnd)

Makes the applicationknown to the DLL.

hWnd - window handleof main windowapplication

0, on error>0, APPL_ID whichshould be used in almostevery function

void CloseDLL(APPL_ID id)

Tells the DLL that theapplication closes

id - applicationidentification

none

PORT_INFO *GetAvail-ableInterfaces()

Returns info about thephysical ports in thePC

none pointer to a varying sizestructure with port info(always valid)

int OpenCommunication(char *pszName)

Tries to open thespecified network.

pszName - name ofdevice port to beopened

return values: 0, on success > 0 in case of error (oneof the FBE_ errors )

Page 246: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

5

Function Description Parameters Returnint CloseCommunication(APPL_ID id)

Tries to close theopened network.

id - applicationidentification

return values:0, on success> 0 in case of error (oneof the FBE_ errors)

int ConfigureRS232( char *pszName, unsigned int iBaud)

Configures the RS232baudrate and reopensthe port if RS232already open.

pszName - name of comport

iBaud - preferredbaudrate

return values: 0, on success > 0, on error (port isclosed)

int ConfigureT_NET( char cNode, char cSecNode, char cNextNode, char cLastNode, char cArbiter, char cTxBuf, char cRxBuf, char *pszName)

Configures theFlowBus settings andreopens the port withthe new settings. Usedfor both configuring thePC_ISA parameters ona PC_ISA Host and forthe PC_ISAparameters of theRS232 Host

cNode - node numbercard

cSecNode- secondarynode number

cNextNode - next nodenumber

cLastNode - last nodenumber

cArbiter - arbitration modecRxBuf - number of

receive bufferscTxBuf - number of

transmit bufferpszName - name of ISA

device port

return values: 0, on success > 0, on error

void GetRS232Config( char *pszName, unsigned int *piBaud)

Determines currentCom port settings

piBaud - storage forbaudrate

pszName - name of comport

none

void GetTNetConfig(char *pcNode, char *pcSecNode, char *pcNextNode, char *pcLastNode, char *pcArbiter, char *pcTxBuf, char *pcRxBuf, char *pszName)

Determines the currentFlowBus settings.

pcNode - storage for nodenumber

pcSecNode- storage forsecondary nodenumber

pcNextNode - storage fornext node number

pcLastNode – storage forlast node numberin network

pcArbiter - storagefor arbitrationmode

pcRxBuf -storagefor number ofreceive buffers

pcTxBuf - storagefor number oftransmit buffer

pszName - name ofISA port

none

void ConfigureChaining( bool bProc, bool bParm)

Sets usage ofchaining. Parametersare used immediately

bProc enable processchaining

bParm enable parameterchaining

none

void GetDLLVersion(char *pszVersion)

Determines the versionof the DLL

pszVersion Version ofthe DLL, if lessthan 5.0 theinterface is notvalid.

none

Page 247: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

6

Function Description Parameters Returnint ReadChar(APPL_ID id, HWND hWnd, char cNode, char cProcNr, char cParmNr, int iMsgId)

Adds a parameter readrequest of type char tothe interface buffer ofthe DLL

id - applicationidentification

hWnd - notify windowhandle (NULLindicates polling)

cNode - destinationnode number

cProcNr - processnumber

cParmNr -parameternumber

iMsgId - messageidentificationused and filled inby application

return values: 0, on success >0, on error

int GetChar(APPL_ID id,char cNode,char cProcNr,char cParmNr,char *pcDest, int *piMsgId)

Retrieves theparameter that isreceived by the DLL.

id - applicationidentification

cNode - destinationnode number

cProcNr - processnumber

cParmNr - parameternumber

pcDest - pointer to charbuffer wheredata can bestored

piMsgId - pointer tomessage id.

return values:0, on success>0, on error

int ReadInt() equal as read_char()int GetInt() equal as get_char() piDest - pointer to int

buffer wheredata can bestored

int ReadFloat() equal as read_char()int GetFloat() equal as get_char() pfDest - pointer to float

buffer wheredata can bestored

int ReadLong() equal as read_char()int GetLong() equal as get_char() plDest - pointer to long

buffer wheredata can bestored

Page 248: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

7

Function Description Parameters Returnint ReadString((APPL_ID id, HWND hWnd, char cNode, char cProcNr, char cParmNr, char cExpLen, int iMsgId)

Equal as read_char(),if cExpLen is 0 anASCII response stringis expected

id - applicationidentification

hWnd - notify windowhandle (NULLindicates polling)

cNode - destinationnode number

cProcNr - processnumber

cParmNr -parameternumber

cExpLen- expected stringlength or 0

iMsgId - messageidentificationused and filled inby application

return values: 0, on success >0, on error

int GetString(APPL_ID id, char cNode, char cProcNr, char cParmNr, int *piMsgId,char *pszDest,char *pcLen)

Retrieves the stringparameter that isreceived by the DLL.

id - applicationidentification

cNode - destinationnode number

cProcNr - processnumber

cParmNr - parameternumber

piMsgId - pointer tomessage id.

pszDest - pointer to charbuffer for datastorage

pcLen - char pointer forstorage of stringlength (in case ofASCII stringtrailing zeroincluded)

return values:0, on success>0, on error

int GetRealTimeChar(APPL_ID id,char cNode,char cProcNr,char cParmNr,char *pcDest,long *plTime, int *piMsgId)

Retrieves theparameter that isreceived by the DLL.

id - applicationidentification

cNode - destinationnode number

cProcNr - processnumber

cParmNr - parameternumber

pcDest - pointer to charbuffer wheredata can bestored

plTime - timestamppiMsgId - pointer to

message id.

return values:FBE_NO_ERROR, onsuccess

FBE_NO_ANSWER_-FOUND, on error

FBE_NO_EVENT, whenno event present onrealtime channel

int GetRealTimeInt() equal asGetRealTimeChar()

int GetRealTimeLong() equal asGetRealTimeChar()

int GetRealTimeFloat() equal asGetRealTimeChar()

Page 249: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

8

Function Description Parameters Returnint WriteChar(APPL_ID id, HWND hWnd, char cNode, char cProcNr, char cParmNr, unsigned char ucPar, int iMsgId)

Adds a parametersend request of typechar to the interfacebuffer of the DLL

id - applicationidentification

hWnd - notify windowhandle (NULLindicates polling)

cNode - destinationnode number

cProcNr - processnumber

cParmNr - parameternumber

ucPar - parametervalue

IMsgId - messageidentificationused and filled inby application

return values:0, on success>0, on error

This function will alsotrigger the different tasksin the DLL to do someaction.

int WriteInt() equal as write_char() uiPar - parameter valueint WriteFloat() equal as write_char(0 fPar - parameter valueint WriteLong() equal as write_char() lPar - parameter valueint WriteString(APPL_ID id, HWND hWnd, char cNode, char cProcNr, char cParmNr, char cLen, char *pszBuf, int iMsgId)

Adds a parametersend request of typestring to the interfacebuffer of the DLL

id - applicationidentification

hWnd - notify windowhandle (NULLindicates polling)

cNode - destinationnode number

cProcNr - processnumber

cParmNr -parameternumber

cLen - length of string(0 for ASCIIstrings)

pszBuf - pointer to stringiMsgId - message

identificationused and filled inby application

return values: 0, onsuccess 1, on error

int GetStatus(APPL_ID id, char cNode, char cProcNr, char cParmNr, char *pcStatus, int *piMsgId)

Retrieves the statusthat the DLL receivedon one of the write_xxxcommands.

id - applicationidentification

cNode - destinationnode number

cProcNr - processnumber

cParmNr -parameternumber

pcStatus - pointerto integer bufferwhere status canbe stored

piMsgId- message id.

return values: 0, onsuccessFBE_XXXX (1 .. 30), onerror

Page 250: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

9

Function Description Parameters Returnint GetError() Indicates if a network

error occurred andclears the possibleerror.

None return value:0, no error occurredIE_BADID (-1) Thedevice identifier is invalidor unsupported or lack ofmemory IE_OPEN (-2)

The device isalready open. IE_NOPEN (-3)

The device is notopen. IE_MEMORY (-4)

The functioncannot allocate thequeues. IE_DEFAULT (-5)

The defaultparameters are in error. IE_HARDWARE (-10)

The hardware isnot available(is locked by anotherdevice).IE_BYTESIZE (-11)

The specified bytesize is invalid. IE_BAUDRATE (-12)

The device's baudrate is unsupported.FBE_PROTOCOLL_ERROR, error in received dataFBE_SEND_ERROR,error sending dataFBE_OPEN_COMM, forPC-ISA in case com portnot openedFBE_CLOSE_COMM, forthe PC-ISA card in casenetwork not openedFBE_HOST_OVERFLOW, for PC-ISA in case tomany messages send toHost

Page 251: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

10

Function Description Parameters Returnint CheckReceivedMsg( APPL_ID id, char *pcNode, char *pcProc, char *pcParm, char *pMType, char *pcType, int *piMsgId)

Indicates if a messageis available for theapplication. If so, thennode, process,parameter, type andmsg id. are filled.

Id - applicationidentification

pcNode - destinationnode number

pcProc - processnumber

pcParm - parameternumber

pMType - indicates type ofmessage(send/ask)

pcType - indicates theanswer is on aReadXxx() or ona WriteXxx()request.

piMsgId- message id.

return value:0, on success>0, on error (no messageavailable)

If no answer is availableand time since the last callto this function is morethen 10 msec, the internalstate-machine istriggered. This is used forpolling in case the ISAcard is used.

int ClaimCommand(APPL_ID id, HWND hWnd, char cNode, char cProcNr, int iMsgId);

Adds a claim processmessage to the DLL

id - applicationidentification

pcNode - destinationnode number

pcProc - processnumber

piMsgId- message id.

return value:0, on success>0, on error

int UnClaimCommand(APPL_ID id, HWND hWnd, char cNode, char cProcNr, int iMsgId);

Adds an unclaimprocess message tothe DLL

id - applicationidentification

pcNode - destinationnode number

pcProc - processnumber

piMsgId- message id.

return value:0, on success>0, on error

int GetClaimStatus(APPL_ID id, char cNode, char cprocNr, char *pcStatus, int *piMsgId);

Determines the answeron the claim request

id - applicationidentification

cNode - destinationnode number

cProcNr - processnumber

pcStatus statuspiMsgId- message id.

return value:0, on success>0, on error

int StartBroadcast(APPL_ID id, HWND hWnd, char cNode, char cProcNr, char cRepTime, int iMsgId);

Adds an startbroadcast processmessage to the DLL

id - applicationidentification

cNode - destinationnode number

cProcNr - processnumber

cRepTime repetitiontime in 10 msec.

iMsgId - message id.

return value,0, on success>0, on error

intGetStartBroadcastStatus(APPL_ID id, char cNode, char cProcNr, char *pcStatus, int *piMsgId)

Determines the answeron the start broadcastrequest

id - applicationidentification

cNode - destinationnode number

cProcNr - processnumber

pcStatus statuspiMsgId- message id.

return value:0, on success>0, on error

Page 252: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

11

Function Description Parameters Returnvoid RemoveMsg( APPL_ID id, char cNode, char cProc, char cParm)

Deletes a read answerfrom the DLL

id application ident.cNode desti. node nrcProc process numbercParm parameter

number.

None

void GetInterfaceType(char *pszName)

Indicates the networkcurrently used. Defaultis COM1.

pszName - name ofdevice currentlyused

none

int GetCommunication() Indication if theconnection with theHost is correct.

none return value:0, no connection1, connection ok

intGetNrPendingMessages(APPL_ID id)

Determines thenumber of outstandingrequests of theapplication.

Id - application ident. return value: number ofrequests

void SetSystemLNA(int iNode)

Sets the last nodeaddress in the network(default 125). Has tobe called in front ofReadSystemConfig

iNode - last nodenumber

none

int GetSystemLNA(void) Returns last nodeaddress.

None last node address

int ReadSystemConfig(int iNode)

Reads the systemconfiguration andbuilds the channeldatabase.

iNode - last node toscan ( 0 meansstop scan inprogress)

return value:0, on success1, communication notopen2, scan already inprogress3, busy with open/close orchange communicationaction

int FindFirstFreeNode(int iStartNode)

Scans the network forthe first node addressnot in use

iStartNode - address ofnode wheresearch shouldstart (0 meanscancel previoussearch)

return value:0, on error(communication closed,busy with other action,already searching node)> 0 node found

char GetProgress() Gives an indication ofthe progress of theReadSystemConfigand FindFirstFreeNodefunctions

none progress of action as apercentage

int GetChannel(int iNode,int iProc)

Determines thechannel correspondingwith the node andprocess

iNode - node addressiProc - process number

return value:0, on error> 0 channel number

bool GetNodeProc(int iChannel,int *piNode,int *piProc)

Gets node andprocess from achannel

iChannel - channelnumber

piNode - storage for nodepiProc - storage for

process

return value,false (0), channel notfoundtrue, channel found

int GetModuleType(int iNode)

Determines moduletype on node address

iNode - node address return value:0, on error> 0 module type

void GetModuleNumber(int iNode,char *pszIDNumber)

Determines themodule serial numberon node address

iNode - node addresspszIDNumber - storage

for serial number

none

Page 253: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

12

Function Description Parameters Returnint GetModuleDevType(int iNode)

Determines themodule functionalgroup

iNode - node address return value,module function type

int GetMaxChannel() Retrieves maximumchannel number

none maximum channel value

int GetMaxNode() Retrieves maximumnode number

none maximum node addressfound

Notes:1. MsgId. is an identification number applied by the application. It is not used inside the DLL.

The DLL just copies it back in the answer. The application can use this message id. forown purposes. For example, root the answer back to a specific part of the program.

2. APPL_ID is an identification number of the application. It is assigned by the DLL when anapplication calls OpenCommunication. This identification is used in WIN16 by the DLL toconnect the received answers back to the correct application. In WIN 32 it can be used toidentify threads in an application.

3.2.3 Error values

The following table gives an overview of possible error values.

Name Value DescriptionFBE_NO_ERROR 0 No errorFBE_PROCESS_CLAIM 1 STATUS RESPONSE MODULE, this process

cannot be operated by this module */

FBE_COMMAND 2 STATUS RESPONSE MODUL, no suchcommand possible for this module

FBE_PROCESS 3 STATUS RESPONSE MODULE, no suchprocess at this module

FBE_PARM_NUMBER 4 STATUS RESPONSE MODULE, no suchparameter at this process

FBE_PARM_TYPE 5 STATUS RESPONSE MODULE, type ofparameter sent differs from type on module

FBE_PARM_VALUE 6 DLL ERROR, wrong value for this parameter ornot accepted

FBE_NETWORK_NOT_ACTIVE

7 HOST ERROR, no communication activity onFLOW-BUS detected

FBE_TIME_OUT_START_CHAR

8 HOST ERROR, start character serialcommunication failed

FBE_TIME_OUT_SERIAL_LINE

9 HOST ERROR, serial communication failed

FBE_MODULE_HARDWARE_MEM

10 memory on FLOW-BUS module failed

FBE_NODE_ADDRESS 11 wrong node numberFBE_COMMUNICATION 12 HOST ERROR, general communication error

with FLOW-BUSDLL_ERROR, retires expired

FBE_READ_ONLY_PARM 13 this parameter value can only be read

Page 254: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

13

Name Value DescriptionFBE_PC_COMMUNI-CATION

14 there is no communication between PC andFLOW-BUS

FBE_RS232_CONNECTION 15 HOST_ERROR, no/bad connection betweenPC and a RS232-module

FBE_PC_MEMORY 16 DLL ERROR, not enough memory in your PCfor communication structure

FBE_WRITE_ONLY_PARM 17 this parameter value can only be send

FBE_SYS_CONFIG_UNKNOWN

18 FLOW-BUS system configuration is unknown

FBE_NO_FREE_NODE_ADDR

19 FLOW-BUS system reached maximum size (32nodes)

FBE_WRONG_INTERFACE_TYPE

20 need other type of interface for this option

FBE_BUILD_DCB 21 DLL_ERROR, error building device controlblock serial port

FBE_OPEN_COMM 22 DLL ERROR, open communication went wrong

FBE_COMM_STATE 23 DLL ERROR, communication status error

FBE_INTERFACE_BUSMASTER

24 interface tries to start communication (alone insystem)

FBE_TIMEOUT_ON_RX_ANSWER

25 time out on rx answer

FBE_NO_START_CHAR 26 HOST ERROR, no ':' on start of message

FBE_FIRST_DIGIT 27 HOST ERROR, error in first digit

FBE_HOST_OVERFLOW 28 HOST ERROR, buffer overflow in host

FBE_BUFFER_OVERFLOW 29 DLL ERROR, buffer overflow in DLL

FBE_NO_ANSWER_FOUND

30 DLL ERROR, requested answer not found

FBE_CLOSE_COMM 31 DLL ERROR, closing communication error

FBE_SYNCHRON_ERROR 32 DLL ERROR, other application performs action

FBE_SEND_ERROR 33 DLL ERROR, requested msg. not send

FBE_PROTOCOL_ERROR 34 DLL ERROR, error in received data

FBE_NO_EVENT 35 DLL ERROR, no event present on realtime-channel

Page 255: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

14

3.3 PROCEDURES

3.3.1 Using the DLLThis paragraph explains the minimal steps necessary to use the DLL.1. First an application opens the DLL and gets an application id. (Function OpenDLL). The

DLL start the internal threads. Default the DLL sets the RS232 connection as the activenetwork.

2. The application should check the software version. (Function GetDLLVersion)3. The application should set the chaining attributes. Default the DLL supports both process

and parameter chaining. Process chaining is not supported on older FlowBus modules.Therefor process chaining should be disabled. (Function ConfigureChaining should becalled with the parameters (false, true))

4. The application should determine a free network it wants to use. First the number of portsshould be determines (Function GetNrPorts), then for each port the name and an in-useindication should be determined (Function GetPort).

3 The application should configure the network (port) it wants to use.• In case the application wants to use an ISA card it configures the specified card

(Function ConfigureTNet with device name, node number, secondary node, next nodeand arbitration mode (only device name and arbitrage are used internally)).

• In case the application wants to use a RS232 host it should configure both the nameand baudrate of the com port and also the ISA settings the RS232 host should use.From the ISA settings only the arbitrage will be used and then only for old host types.(Functions ConfigureTNet and ConfigureRS232). See also 3.3.3

5. The application opens the communication on a specified port. (FunctionOpenCommunication)

6. The application performs some communication task actions.7. The application closes the communication (Function CloseCommunication)8. The application ends the connection with the DLL, the application tells the DLL is closes

and the DLL closes all threads (Function CloseDLL)

3.3.2 Open and Closing communicationThis paragraph explains how communication can be opened and closed.1. After the application has obtained an application id. It should determine which physical

network is available, if any. (Function GetAvailableInterfaces or GetNrPorts + GetPort).2. Then the application opens the communication (Function OpenComm ) with a free port

returned in 1.3. If the communication is already open, it is closed automatically. All messages that are in

the DLL buffer that still have to be send are flushed. The physical port is opened.4. In case of an RS232 host it is checked if this node is already installed on a node number

(only true for new host types), if so this node number will be used.5. In contrast, old RS232 hosts and all ISA hosts are started by the DLL on node 0. In this

case the DLL searches for a free node number. If a node is found the host is installed tothis free node number.

6. The DLL checks if the host takes part in the network arbitrage scheme for a maximum of20 seconds.

7. When the application closes the communication, (Function CloseCommunication) the DLLfirst waits till an answer is received on pending messages. Afterwards the physical port isclosed and messages that still have to be send, are flushed

8. If the application closes it is not necessary to close the communication. The DLL will closethe communication when the application calls CloseDLL() or if the DLLEntryPoint functionis called with PROCESS_DETACH (the DLL is unloaded from memory).

9. The communication can be checked (Function GetCommunication) which indicates if theconnection with the Host is correct (or at least the DLL thinks this connection is correct).

3.3.3 Configuring communication

Page 256: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

15

1. First there is a FlowBus configuration for the Host. The current configuration can bedetermined (Function GetTNetConfig). The configuration can be changed (FunctionConfigureTNet). These functions apply both to the settings of the PC-ISA card and to theFlowBus settings of the RS232 Host.Only if the function ConfigureTNet is called when a port is open the host will use all theISA settings. The physical port is claimed (wait till there are no more messages pending tothe modules). Then the port is closed and reopened with the new settings.

2. Second there is the RS232 configuration. The current configuration can be determined(Function GetRS232Config) The settings can be changed (Function ConfigureRS232). Ifthe RS232 port is opened and ConfigureRS232 is called, the port is claimed, than closedand then reopened with the new settings.

3. If an application calls ConfigureTNet and ConfigureRS232 at the same time. The last callis only used to store the settings internally. This can happen with two threads in oneapplication.

The following table lists the internal usage of the FlowBus settings:

Port Open Host Type FlowBus SettingsUsed

No new RS232 (withauto-install)

none

No old RS232 secondary node +arbitration

No ISA host device name +arbitration

Yes new RS232 all settings except devicename

Yes old RS232 all settings except devicename

Yes ISA host all settings

Table 1 Usage of ConfigureTNet settings.

3.3.4 Sending / Receiving data• First an application opens the DLL and gets an application id. See 3.3.1• Next the DLL opens a physical network. See 3.3.2• An application can now start placing messages in the Interface-Buffer (Functions

‘ReadXxx’ or ‘WriteXxx’).• If the application passes a valid Window Handle the DLL will notify the application

when an answer is received, otherwise the DLL has to poll the DLL (FunctionCheckReceivedMsg. )

• If an answer is received, the application should first check if a network error occurred(Function GetError).

• Parameters returned with CheckReceivedMsg are node, process, parameter andrequest-type for which an answer is received. The following steps are dependent of themessage type:- parameter send: determine the status of the answer (GetStatus).

This can be a status response from the Host or an internal error value from the DLL.- parameter ask: determine the status of the answer (GetStatus) to check for error responses. If no error occurred, call one of the GetXxx functions to determine the received parameter value- claim: determine the status of the answer (GetClaimStatus)

to check for errors.- unclaim: determine the status of the answer (GetClaimStatus)

to check for errors

Page 257: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

16

- broadcast: determine the status of the answer(GetStartBroadcastStatus) to check for errors

• The application can now remove the message data from the DLL buffer (FunctionRemoveMsg)

To prevent the application places too many requests in the DLL (with a corresponding longperiod between request and response) the application can ask for the number of outstandingrequest (Function GetNrPendingMessages).

To get a better throughput of requests (performance) the following notes give some ideas:1. Place requests on a timer interval and continue with requests while

GetNrPendingMessages is still smaller than 100 messages2. Try to place several requests for the same node at the same time (to make use of the

chaining of request)3. Try to place requests for different nodes at the same time (the hosts support at this

moment concurrent requests for 5 different nodes)4. Maintain a start point, at this point the application should wait till all pending requests are

handled. This should prevent that the interface buffer gets filled with one kind of slowrequest. An overflow because some kind of request to some kind of node takes more timethan the other kind of requests.

3.3.5 Database functionsInternally the DLL maintains a database of FlowBus Channels. Each node at least as onechannel assigned to it. A channel represents a single process in a node. Nodes with severalinputs can have more than one channel. This database is available after the application callsReadSystemConfig. This function takes as parameter the number of nodes to scan, startingfrom 1. This parameter should be filled in based on system knowledge. The maximum nodevalue supported is 125. The channel database is sorted. Controller modules come in front ofoperator and interface modules.

Page 258: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

17

4 Physical Interface design

There are three lower level interfaces:1. serial interface with RS232 host, described in [2]2. DPM interface with ISA host on Win95 operating system, described in [2]3. DeviceIOControl function interface with ISA Device Driver on Win NT4.0 operating system

Page 259: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

18

A. Example application program

This appendix gives a short programming example.

1. Initialisation

char pszPortName[MAX_PORT_LEN];bool chain_proc;bool chain_parm;NETWORK_TYPE net;int idTimer;HWND NotifyHandler;int polling_period;char Version[10];APPL_ID AppId;

GetDLLVersion(Version);// check version, only continue if appropriate…// determine current configurationAppId = OpenDLL(NULL);strcpy(pszPortName, "COM1");if (GetCommunication())

{ GetInterfaceType(pszPortName); if (strncmp(pszPortName, "COM", 3) == 0) net = RS232;

else net = T_NET;

if (net == T_NET){

idTimer = SetTimer(1, polling_period); // NotifyHandler = NULL;

}else

{ NotifyHandler = this->HWindow; } }

chain_proc = false; chain_parm = true; ConfigureChaining(chain_proc, chain_parm);

2. Open RS232 portRS232_SET set;

TNET_SET set_tnet; char pszPort[MAX_PORT_LEN];

char szName[MAX_PORT_LEN];int iRes;

GetRS232Config(pszPort, (unsigned short *)&set.baudrate);GetTNetConfig(&set_tnet.cNode, &set_tnet.cSecNode,

&set_tnet.cNextNode, &set_tnet.cLastNode, &set_tnet.cArbiter, &set_tnet.cTxRetries, &set_tnet.cRxRetries, szName);

// change settings as necessarysprintf(pszPort, “COM1”);iRes = ConfigureTNet(set_tnet.cNode, set_tnet.cSecNode,

set_tnet.cNextNode, set_tnet.cLastNode, set_tnet.cArbiter, set_tnet.cTxRetries, set_tnet.cRxRetries, szName);

iRes = ConfigureRS232(pszPort, set.baudrate);

Page 260: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

19

iRes = OpenCommunication(pszPort);

3. Send some request and check answers

char buffer[125];char cNode;char cParm;char cProc;char cStatus;char mType;char cType;int iError;short iMsgId;

float fDest;long lDest;int msg_rec = 0;

int error_rec = 0;

if (GetNrPendingMessages(AppId) <= pInputScript->GetCyclusSize()){

// number of pending messages smaller than max. number of messages that // can be send in a cyclus

bRes = pInputScript->HandleNext();// e.giRes = WriteChar(AppId, NotifyHandler, 1, 0, 3, 125, MsgId++);iRes = ReadInt(AppId, NotifyHandler, 1, 1, 1, MsgId++);

}while (CheckReceivedMsg(AppId, &cNode, &cProc, &cParm, &mType, &cType,

&iMsgId) == FBE_NO_ERROR){

// answer availableiError = GetError(); //get info about network errorif (iError == FBE_NO_ERROR){ switch (mType)

{ case PARM_SEND_TYPE:

// get info about error or status responseiError = GetStatus(AppId, cNode, cProc, cParm, &cStatus,

&iMsgId);if (cStatus <= FBE_PARM_VALUE){

ReportStatus(AppId, cNode, cProc, cParm, cStatus);}else{

ReportError(AppId, cNode, cProc, cParm, cStatus);}

break; case PARM_ASK_TYPE:

// get info about error or status responseGetStatus(AppId, cNode, cProc, cParm, &cStatus, &iMsgId);if (cStatus == FBE_NO_ERROR){

switch (cType){case PARM_CHAR:

if (GetChar(AppId, cNode, cProc, cParm, (char *)&lDest, &iMsgId) ==

FBE_NO_ERROR)

Page 261: Disseny d’un programa amb C++ Builder per el control d’un ...deeea.urv.cat › public › PROPOSTES › pub › pdf › 956pub.pdf · Introducció 5 1. Introducció 1.1. Antecedents

IDDFLD32_D.doc - P1Drev. date: 1999-12-21

20

ReportParm(AppId, cNode, cProc, cParm, PARM_CHAR, (char)lDest);

elseReportError(AppId, cNode, cProc,

cParm, FBE_NO_ANSWER_FOUND);break;

default:// handle other parm types…break;

}}else

// handle errorbreak;

default:// handle other message typesbreak;

}}else{

// handle error}RemoveMsg(AppId, cNode, cProc, cParm);

}

4. TerminateiRes = CloseCommunication(); // not really necessaryCloseDLL(AppId); // required