Export translations
Views
Special page
From OpenSCADAWiki
Jump to:
navigation
,
search
Settings
Group
About
Documents
Documents/API
Documents/DAQ
Documents/FAQ
Documents/How to
Documents/How to/Build from source
Documents/How to/Crash report
Documents/How to/Create module
Documents/How to/Create multi language project
Documents/How to/Cyclic programming
Documents/How to/Debug
Documents/How to/Install
Documents/How to/Live disk
Documents/How to/Release
Documents/How to/Transferring project configuration
Documents/How to/Violations, alarms and notifications
Documents/Program manual
Documents/Quick start
Documents/Release 0.8.0
Documents/Release 0.8.0/Update10
Documents/Release 0.8.0/Update11
Documents/Release 0.8.0/Update12
Documents/Release 0.8.0/Update13
Documents/Release 0.8.0/Update14
Documents/Release 0.8.0/Update15
Documents/Release 0.8.0/Update16
Documents/Release 0.8.0/Update17
Documents/Release 0.8.0/Update18
Documents/Release 0.8.0/Update19
Documents/Release 0.8.0/Update20
Documents/Release 0.8.0/Update3
Documents/Release 0.8.0/Update4
Documents/Release 0.8.0/Update5
Documents/Release 0.8.0/Update6
Documents/Release 0.8.0/Update7
Documents/Release 0.8.0/Update8
Documents/Release 0.8.0/Update9
Documents/Release 0.9
Documents/Release 0.9/Update 7
Documents/Release 0.9/Update1
Documents/Release 0.9/Update2
Documents/Release 0.9/Update3
Documents/Release 0.9/Update4
Documents/Release 0.9/Update5
Documents/Release 0.9/Update6
Documents/Release 0.9/Updating 0.8.0 LTS
Documents/Terms
Documents/User API
Functions and demands
Home
Libs
Libs/Devices
Libs/Documents
Libs/Electrical elements
Libs/Generic list
Libs/LowLevelDevices
Libs/Main
Libs/Main graphical elements
Libs/Mnemo elements
Libs/Prescriptions
Libs/Regulation elements
Libs/Service procedures
Libs/Technological apparatuses
Modules
Modules/BFN
Modules/BlockCalc
Modules/Comedi
Modules/DAQGate
Modules/DBArch
Modules/DBF
Modules/DBGate
Modules/DCON
Modules/DiamondBoards
Modules/FireBird
Modules/FLibComplex1
Modules/FLibMath
Modules/FLibSYS
Modules/FSArch
Modules/GPIO
Modules/HTTP
Modules/ICP DAS
Modules/JavaLikeCalc
Modules/LDAP
Modules/LogicLev
Modules/ModBus
Modules/MySQL
Modules/OPC UA
Modules/PostgreSQL
Modules/QTCfg
Modules/QTStarter
Modules/SelfSystem
Modules/Serial
Modules/Siemens
Modules/SMH2Gi
Modules/SNMP
Modules/Sockets
Modules/SoundCard
Modules/SQLite
Modules/SSL
Modules/System
Modules/SystemTests
Modules/UserProtocol
Modules/VCAEngine
Modules/Vision
Modules/WebCfg
Modules/WebCfgD
Modules/WebUser
Modules/WebVision
Sub-projects
Sub-projects/Automatic Builder of OpenSCADA
Sub-projects/Automation Linux distributive
Sub-projects/Embedding and PLC
Sub-projects/Server
Sub-projects/VCA
User:RomanSavochenko
Using
Using/HouseSpirit
Using/Kramatorsk Ball Mills
Using/Kramatorsk Water
Using/Model AGLKS
Using/Model Boiler
Using/OpenWrt TELEOFIS RTU968
Using/Yaroslavskij broiler
Works
Works/Road map
Works/Technical Support
Works/Technical Support/Agreement
Works/To do
Language
aa - Afar
ab - Abkhazian
ace - Achinese
ady - Adyghe
ady-cyrl - адыгабзэ
aeb - Tunisian Arabic
aeb-arab - تونسي
aeb-latn - Tûnsî
af - Afrikaans
ak - Akan
aln - Gheg Albanian
am - Amharic
an - Aragonese
ang - Old English
anp - Angika
ar - Arabic
arc - Aramaic
arn - Mapuche
arq - Algerian Arabic
ary - Moroccan Arabic
arz - Egyptian Arabic
as - Assamese
ase - American Sign Language
ast - Asturian
av - Avaric
avk - Kotava
awa - Awadhi
ay - Aymara
az - Azerbaijani
azb - تۆرکجه
ba - Bashkir
bar - Bavarian
bbc - Batak Toba
bbc-latn - Batak Toba
bcc - Southern Balochi
bcl - Bikol Central
be - Belarusian
be-tarask - Belarusian (Taraškievica orthography)
bg - Bulgarian
bgn - Western Balochi
bho - Bhojpuri
bi - Bislama
bjn - Banjar
bm - Bambara
bn - Bengali
bo - Tibetan
bpy - Bishnupriya
bqi - Bakhtiari
br - Breton
brh - Brahui
bs - Bosnian
bto - Iriga Bicolano
bug - Buginese
bxr - буряад
ca - Catalan
cbk-zam - Chavacano de Zamboanga
cdo - Min Dong Chinese
ce - Chechen
ceb - Cebuano
ch - Chamorro
cho - Choctaw
chr - Cherokee
chy - Cheyenne
ckb - Central Kurdish
co - Corsican
cps - Capiznon
cr - Cree
crh - Crimean Turkish
crh-cyrl - Crimean Turkish (Cyrillic script)
crh-latn - Crimean Turkish (Latin script)
cs - Czech
csb - Kashubian
cu - Church Slavic
cv - Chuvash
cy - Welsh
da - Danish
de - German
de-at - Austrian German
de-ch - Swiss High German
de-formal - German (formal address)
diq - Zazaki
dsb - Lower Sorbian
dtp - Central Dusun
dty - डोटेली
dv - Divehi
dz - Dzongkha
ee - Ewe
egl - Emilian
el - Greek
eml - Emiliano-Romagnolo
en - English
en-ca - Canadian English
en-gb - British English
eo - Esperanto
es - Spanish
et - Estonian
eu - Basque
ext - Extremaduran
fa - Persian
ff - Fulah
fi - Finnish
fit - Tornedalen Finnish
fj - Fijian
fo - Faroese
fr - French
frc - Cajun French
frp - Arpitan
frr - Northern Frisian
fur - Friulian
fy - Western Frisian
ga - Irish
gag - Gagauz
gan - Gan Chinese
gan-hans - Simplified Gan script
gan-hant - Traditional Gan script
gd - Scottish Gaelic
gl - Galician
glk - Gilaki
gn - Guarani
gom - Goan Konkani
gom-deva - Goan Konkani (Devanagari script)
gom-latn - Goan Konkani (Latin script)
got - Gothic
grc - Ancient Greek
gsw - Swiss German
gu - Gujarati
gv - Manx
ha - Hausa
hak - Hakka Chinese
haw - Hawaiian
he - Hebrew
hi - Hindi
hif - Fiji Hindi
hif-latn - Fiji Hindi (Latin script)
hil - Hiligaynon
ho - Hiri Motu
hr - Croatian
hrx - Hunsrik
hsb - Upper Sorbian
ht - Haitian Creole
hu - Hungarian
hy - Armenian
hz - Herero
ia - Interlingua
id - Indonesian
ie - Interlingue
ig - Igbo
ii - Sichuan Yi
ik - Inupiaq
ike-cans - Eastern Canadian (Aboriginal syllabics)
ike-latn - Eastern Canadian (Latin script)
ilo - Iloko
inh - Ingush
io - Ido
is - Icelandic
it - Italian
iu - Inuktitut
ja - Japanese
jam - Jamaican Creole English
jbo - Lojban
jut - Jutish
jv - Javanese
ka - Georgian
kaa - Kara-Kalpak
kab - Kabyle
kbd - Kabardian
kbd-cyrl - Адыгэбзэ
kg - Kongo
khw - Khowar
ki - Kikuyu
kiu - Kirmanjki
kj - Kuanyama
kk - Kazakh
kk-arab - Kazakh (Arabic script)
kk-cn - Kazakh (China)
kk-cyrl - Kazakh (Cyrillic script)
kk-kz - Kazakh (Kazakhstan)
kk-latn - Kazakh (Latin script)
kk-tr - Kazakh (Turkey)
kl - Kalaallisut
km - Khmer
kn - Kannada
ko - Korean
ko-kp - 한국어 (조선)
koi - Komi-Permyak
kr - Kanuri
krc - Karachay-Balkar
kri - Krio
krj - Kinaray-a
ks - Kashmiri
ks-arab - Kashmiri (Arabic script)
ks-deva - Kashmiri (Devanagari script)
ksh - Colognian
ku - Kurdish
ku-arab - كوردي (عەرەبی)
ku-latn - Kurdish (Latin script)
kv - Komi
kw - Cornish
ky - Kyrgyz
la - Latin
lad - Ladino
lb - Luxembourgish
lbe - лакку
lez - Lezghian
lfn - Lingua Franca Nova
lg - Ganda
li - Limburgish
lij - Ligurian
liv - Livonian
lmo - Lombard
ln - Lingala
lo - Lao
loz - Lozi
lrc - Northern Luri
lt - Lithuanian
ltg - Latgalian
lus - Mizo
luz - Southern Luri
lv - Latvian
lzh - Literary Chinese
lzz - Laz
mai - Maithili
map-bms - Basa Banyumasan
mdf - Moksha
mg - Malagasy
mh - Marshallese
mhr - Eastern Mari
mi - Maori
min - Minangkabau
mk - Macedonian
ml - Malayalam
mn - Mongolian
mo - молдовеняскэ
mr - Marathi
mrj - Western Mari
ms - Malay
mt - Maltese
mus - Creek
mwl - Mirandese
my - Burmese
myv - Erzya
mzn - Mazanderani
na - Nauru
nah - Nāhuatl
nan - Min Nan Chinese
nap - Neapolitan
nb - Norwegian Bokmål
nds - Low German
nds-nl - Low Saxon
ne - Nepali
new - Newari
ng - Ndonga
niu - Niuean
nl - Dutch
nl-informal - Nederlands (informeel)
nn - Norwegian Nynorsk
nov - Novial
nrm - Nouormand
nso - Northern Sotho
nv - Navajo
ny - Nyanja
oc - Occitan
olo - Livvi-Karelian
om - Oromo
or - Oriya
os - Ossetic
pa - Punjabi
pag - Pangasinan
pam - Pampanga
pap - Papiamento
pcd - Picard
pdc - Pennsylvania German
pdt - Plautdietsch
pfl - Palatine German
pi - Pali
pih - Norfuk / Pitkern
pl - Polish
pms - Piedmontese
pnb - Western Punjabi
pnt - Pontic
prg - Prussian
ps - Pashto
pt - Portuguese
pt-br - Brazilian Portuguese
qu - Quechua
qug - Chimborazo Highland Quichua
rgn - Romagnol
rif - Riffian
rm - Romansh
rmy - Romani
rn - Rundi
ro - Romanian
roa-tara - tarandíne
ru - Russian
rue - Rusyn
rup - Aromanian
ruq - Megleno-Romanian
ruq-cyrl - Megleno-Romanian (Cyrillic script)
ruq-latn - Megleno-Romanian (Latin script)
rw - Kinyarwanda
sa - Sanskrit
sah - Sakha
sat - Santali
sc - Sardinian
scn - Sicilian
sco - Scots
sd - Sindhi
sdc - Sassarese Sardinian
sdh - Southern Kurdish
se - Northern Sami
sei - Seri
ses - Koyraboro Senni
sg - Sango
sgs - Samogitian
sh - Serbo-Croatian
shi - Tachelhit
shi-latn - Tašlḥiyt
shi-tfng - ⵜⴰⵛⵍⵃⵉⵜ
si - Sinhala
sk - Slovak
sl - Slovenian
sli - Lower Silesian
sm - Samoan
sma - Southern Sami
sn - Shona
so - Somali
sq - Albanian
sr - Serbian
sr-ec - Serbian (Cyrillic script)
sr-el - Serbian (Latin script)
srn - Sranan Tongo
ss - Swati
st - Southern Sotho
stq - Saterland Frisian
su - Sundanese
sv - Swedish
sw - Swahili
szl - Silesian
ta - Tamil
tcy - Tulu
te - Telugu
tet - Tetum
tg - Tajik
tg-cyrl - Tajik (Cyrillic script)
tg-latn - Tajik (Latin script)
th - Thai
ti - Tigrinya
tk - Turkmen
tl - Tagalog
tly - Talysh
tn - Tswana
to - Tongan
tokipona - Toki Pona
tpi - Tok Pisin
tr - Turkish
tru - Turoyo
ts - Tsonga
tt - Tatar
tt-cyrl - Tatar (Cyrillic script)
tt-latn - Tatar (Latin script)
tum - Tumbuka
tw - Twi
ty - Tahitian
tyv - Tuvinian
tzm - Central Atlas Tamazight
udm - Udmurt
ug - Uyghur
ug-arab - Uyghur (Arabic script)
ug-latn - Uyghur (Latin script)
uk - Ukrainian
ur - Urdu
uz - Uzbek
uz-cyrl - ўзбекча
uz-latn - oʻzbekcha
ve - Venda
vec - Venetian
vep - Veps
vi - Vietnamese
vls - West Flemish
vmf - Main-Franconian
vo - Volapük
vot - Votic
vro - Võro
wa - Walloon
war - Waray
wo - Wolof
wuu - Wu Chinese
xal - Kalmyk
xh - Xhosa
xmf - Mingrelian
yi - Yiddish
yo - Yoruba
yue - Cantonese
za - Zhuang
zea - Zeelandic
zh - Chinese
zh-cn - Chinese (China)
zh-hans - Simplified Chinese
zh-hant - Traditional Chinese
zh-hk - Chinese (Hong Kong)
zh-mo - 中文(澳門)
zh-my - 中文(马来西亚)
zh-sg - Chinese (Singapore)
zh-tw - Chinese (Taiwan)
zu - Zulu
qqq - Message documentation
Format
Export for off-line translation
Export in native format
{{DISPLAYTITLE:Документация/Как/Создать модуль}}<languages/> {{Info| * '''Автор:''' [[User:RomanSavochenko|Роман Савоченко]] * '''Спонсировано, полную ревизию на 1.8 {{CtxDetails|ЧД|человеко-дней, 1ЧД — 10 часов}}:''' SINGE SOFTWARE * '''Изначально создано:''' в [http://wiki.oscada.org/Doc/ModuleBuild старой Wiki] }} This manual is made to help in building the modules for OpenSCADA. The module creation may be required if you wish to add the support for new data source or other extension to OpenSCADA. Since OpenSCADA is an extremely modular system, all interfaces of interaction with the external environment are implemented by expanding it with modules of following types: * databases; * communication interfaces, transports; * protocols of the communication interfaces; * data sources and data acquisition; * archives-history (messages and values); * user interfaces (GUI, TUI, WebGUI, speech, signal ...); * additional modules, special. [[File:at.png]] To create modules for OpenSCADA you need to have some experience in C/C++ programming language, the build system [http://en.wikipedia.org/wiki/GNU_build_system AutoTools], as well as basic knowledge of Linux and the distribution you are using. In order to post the developed module to the [http://oscada.org/websvn/listing.php?repname=OpenSCADA OpenSCADA source tree repository], you must do the following and comply with the following requirements: * be the copyright holder or the author of the module code and distribute it under any free license, GPL preferred; * prepare and store the module code as a separated archive of the module folder for any module subsystem of OpenSCADA with demands to the content: ** the source texts of the module at the beginning of each file must include correct copyrights information, be written and formatted according to some system where preference should be given to the [[Special:MyLanguage/Documents/API#CodeDesign|formatting style of the main OpenSCADA modules]]; ** the localisation files of the module must be also correct, actual and proper formed. * write a short information page of the module for placing it to [[Special:MyLanguage/Modules|the OpenSCADA Wiki]] in way like to the other ones there; * for placing of this module, write a direct request in the forum topic "[http://oscada.org/en/forum/topics/openscada_development/ OpenSCADA development]", including proof of functionality from the OpenSCADA developer or a short demonstration video. == Creating a New Module == Modules in OpenSCADA are the shared libraries, which are dynamically connected to the OpenSCADA core at startup or during the program operation. Many of the modules can be disabled, connected and updated during the operation from the [[Special:MyLanguage/Documents/Program_manual#CfgModSched|module scheduler]]. Modules can be also builtin-included into the OpenSCADA core during building by an argument '''-enable-{ModName}=incl''' to the '''configure''' configuration script, what you can learn from the [[Special:MyLanguage/Documents/How_to/Build_from_source|building manual]]. The OpenSCADA modules can be of seven types according to the presented [[Special:MyLanguage/Documents/Program_manual#Modularity|modular subsystems]]. For now the modules to OpenSCADA are written in the "'''C++'''" programming language, although bindings for other languages may appear in the future. In the tree of the source texts, in the branch of each subsystem, to simplify the creation of new modules, the folder "=Tmpl=" with the module template of the corresponding subsystem is provided. The developer of the new module can take this folder and copy it with the name of his new module, although he can also always use as a sample any real working module if his new one is close in structure. You can create modules in the OpenSCADA sources tree or as an independent project of the external module for OpenSCADA. === Creation in the sources tree of the OpenSCADA project === It makes sense to create new modules in the sources tree of OpenSCADA project in case of further plans for the transfer of the new module to the OpenSCADA project. Since the module should not be contrary to the spirit of the open source project and license on the basis of which [http://oscada.org/en/main/about-the-project/licenses/ OpenSCADA is developed and distributed], license of the new module obviously should be one of the free licenses. The procedure for creating a new module with inclusion in the source text tree based on a template is generally simpler than the procedure for an external module and includes the following steps: :1. Get the source tree of the OpenSCADA project for: :* ''the Work branch:'' :: {{InLineCode|<nowiki>svn co svn://oscada.org/trunk/OpenSCADA</nowiki>}} :* ''the stable release branch — NOT RECOMMENDED, as only patches are accepted for stable LTS releases and this instruction requires version 0.9 or higher:'' :: {{InLineCode|<nowiki>svn co svn://oscada.org/tags/openscada_0.9</nowiki>}} :2. Copy the template folder with the "NewMod" name of the new module, for example, for the "DB" subsystem: :: {{InLineCode|<nowiki>cd OpenSCADA/src/moduls/bd; cp -r =Tmpl= NewMod; cd NewMod; rm -f configure.ac</nowiki>}} ::: ''for the "DAQ" subsystem the path is'' — "OpenSCADA/src/moduls/'''daq'''" ::: ''for the "Archive-History" subsystem the path is'' — "OpenSCADA/src/moduls/'''arhiv'''" ::: ''for the "Transport" subsystem the path is'' — "OpenSCADA/src/moduls/'''transport'''" ::: ''for the "Transport protocol" subsystem the path is'' — "OpenSCADA/src/moduls/'''protocol'''" ::: ''for the "UI" subsystem the path is'' — "OpenSCADA/src/moduls/'''ui'''" ::: ''for the "Special" subsystem the path is'' — "OpenSCADA/src/moduls/'''special'''" :3. Edit the "module.cpp" file for:'' ::: ''also can do that automatically by:'' {{InLineCode|<nowiki>sed -i "s/Tmpl/NewMod/g" *.{cpp,h}</nowiki>}} :* ''changing the name of the builtin-inclusion functions of the module according to the name of the new module'': :: "TModule::SAt '''bd_Tmpl_module'''( int n_mod )" —> "TModule::SAt '''bd_NewMod_module'''( int n_mod )" :: "TModule *'''bd_Tmpl_attach'''( const TModule::SAt &AtMod, const string &source )" —> "TModule *'''bd_NewMod_attach'''( const TModule::SAt &AtMod, const string &source )" :* ''information about the module in the "module.cpp" file, namely the section:'' <syntaxhighlight lang="CPP" style="margin-left: 45px"> //************************************************ //* Modul info! * #define MOD_ID "NewMod" #define MOD_NAME _("DB NewMod") #define MOD_TYPE SDB_ID #define VER_TYPE SDB_VER #define MOD_VER "0.0.1" #define AUTHORS _("MyName MyFamily") #define DESCRIPTION _("BD NewMod description.") #define MOD_LICENSE "GPL2" </syntaxhighlight> :4. Edit the module's building configuration in the "Makefile.am" file to: ::: ''also can do that automatically by:'' {{InLineCode|<nowiki>sed -i "s/Tmpl/NewMod/g" Makefile.am</nowiki>}} <pre style="white-space: pre-wrap; margin-left: 30px"> EXTRA_DIST = *.h po/* if NewModIncl noinst_LTLIBRARIES = db_NewMod.la db_NewMod_la_CXXFLAGS = -DMOD_INCL -fpic db_NewMod_la_LIBTOOLFLAGS = --tag=disable-shared db_NewMod_la_LDFLAGS = -module else oscd_modul_LTLIBRARIES = db_NewMod.la db_NewMod_la_CXXFLAGS = db_NewMod_la_LIBTOOLFLAGS = --tag=disable-static db_NewMod_la_LDFLAGS = -module -avoid-version $(top_builddir)/src/liboscada.la endif db_NewMod_la_CXXFLAGS += $(NewMod_CFLAGS) db_NewMod_la_LDFLAGS += $(NewMod_LDLAGS) db_NewMod_la_SOURCES = module.cpp I18N_mod = $(oscd_modulpref)NewMod include ../../../../I18N.mk </pre> :5. Add an entry of the new module to the end of the subsystem's section of the OpenSCADA building system configuration file "OpenSCADA/configure.ac": :* ''to the section "DB modules" end for the "DB" subsystem:'' <pre style="white-space: pre-wrap; margin-left: 30px"> AX_MOD_DB_EN(NewMod, [disable or enable[=incl] compilation module DB.NewMod], disable, incl, [ # The code for external libraries of the module check ]) </pre> :* ''to the section "DAQ modules" end for the "DAQ" subsystem:'' <pre style="white-space: pre-wrap; margin-left: 30px"> AX_MOD_DAQ_EN(NewMod, [disable or enable[=incl] compilation module DAQ.NewMod], disable, incl, [ # The code for external libraries of the module check ]) </pre> :* ''to the section "Archive modules" end for the "Archive-History" subsystem:'' <pre style="white-space: pre-wrap; margin-left: 30px"> AX_MOD_Archive_EN(NewMod, [disable or enable[=incl] compilation module Archive.NewMod], disable, incl, [ # The code for external libraries of the module check ]) </pre> :* ''to the section "Transport modules" end for the "Transport" subsystem:'' <pre style="white-space: pre-wrap; margin-left: 30px"> AX_MOD_Transport_EN(NewMod, [disable or enable[=incl] compilation module Transport.NewMod], disable, incl, [ # The code for external libraries of the module check ]) </pre> :* ''to the section "Transport protocol modules" end for the "Transport protocol" subsystem:'' <pre style="white-space: pre-wrap; margin-left: 30px"> AX_MOD_TrProt_EN(NewMod, [disable or enable[=incl] compilation module Protocol.NewMod], disable, incl, [ # The code for external libraries of the module check ]) </pre> :* ''to the section "UI modules" end for the "UI" subsystem:'' <pre style="white-space: pre-wrap; margin-left: 30px"> AX_MOD_UI_EN(NewMod, [disable or enable[=incl] compilation module UI.NewMod], disable, incl, [ # The code for external libraries of the module check ]) </pre> :* ''to the section "Special modules" end for the "Special" subsystem:'' <pre style="white-space: pre-wrap; margin-left: 30px"> AX_MOD_Special_EN(NewMod, [disable or enable[=incl] compilation module Special.NewMod], disable, incl, [ # The code for external libraries of the module check ]) </pre> :6. Now the new module can be built in OpenSCADA after the reorganisation of the building system: :: {{InLineCode|<nowiki>autoreconf -if; ./configure --enable-NewMod; make</nowiki>}} :7. Publication — form a patch with your module and send it to the OpenSCADA developers: :: {{InLineCode|<nowiki>cd OpenSCADA; make distclean; rm -rf src/moduls/bd/NewMod/{Makefile.in,.deps}</nowiki>}} :: {{InLineCode|<nowiki>svn add src/moduls/bd/NewMod; svn diff > NewMod.patch</nowiki>}} === Creation an external module to OpenSCADA === Creation an external module to OpenSCADA may make sense in the case of the development the integration interface with business (commercial) systems that require proprietary interaction code, as well as in the case of other commercial interfaces implementations in which the module for the OpenSCADA acquire the status of the separate project, that is distributed and maintained independently often in the form of binary buildings for a specific platform and version of OpenSCADA. The license of such modules, respectively, can be arbitrary. The procedure for creation a new external module based on the template is largely similar to the previous procedure and includes the following steps: :1. Get the source texts of the OpenSCADA project — for an external module as a source of the template you can use any OpenSCADA source files of version more than 0.9, because it is necessary to copy only the "=Tmpl=" directory and several files for build. :2. Copy the template directory with the "NewMod" name of the new module, for example, for the "DB" subsystem; and in that directory already create and copy the necessary files of the external module. Further, the information files of the project "COPYING", "NEWS", "README", "AUTHORS" and "ChangeLog" must be filled accordingly to the nature of the new module. :: {{InLineCode|<nowiki>cp -r OpenSCADA/src/moduls/bd/=Tmpl= NewMod; touch NewMod/{NEWS,README,AUTHORS,ChangeLog}; cp OpenSCADA/I18N.mk NewMod/</nowiki>}} ::: ''for the "DAQ" subsystem the path is'' — "OpenSCADA/src/moduls/'''daq'''/=Tmpl=" ::: ''for the "Archive-History" subsystem the path is'' — "OpenSCADA/src/moduls/'''arhiv'''/=Tmpl=" ::: ''for the "Transport" subsystem the path is'' — "OpenSCADA/src/moduls/'''transport'''/=Tmpl=" ::: ''for the "Transport protocol" subsystem the path is'' — "OpenSCADA/src/moduls/'''protocol'''/=Tmpl=" ::: ''for the "UI" subsystem the path is'' — "OpenSCADA/src/moduls/'''ui'''/=Tmpl=" ::: ''for the "Special" subsystem the path is'' — "OpenSCADA/src/moduls/'''special'''/=Tmpl=" :3. Edit the module information in the "module.cpp" file similarly to the appropriate item in the previous section. :4. Edit the module building configuration in the "Makefile.am" file similarly to the appropriate item in the previous section, excepts: :* instead "db_NewMod_la_LDFLAGS = -module -avoid-version '''$(top_builddir)/src/liboscada.la'''" write "db_NewMod_la_LDFLAGS = -module -avoid-version", that is remove "$(top_builddir)/src/liboscada.la" :* instead "include '''../../../../'''I18N.mk" write "include I18N.mk", that is remove the path "../../../../" :5. Edit the build system configuration file "configure.ac" for: ::: ''also can do that automatically by:'' {{InLineCode|<nowiki>sed -i "s/Tmpl/NewMod/g" configure.ac</nowiki>}} :* "AC_INIT(['''Tmpl'''],['''0.0.1'''],['''my@email.org'''])" — information about the module: name, version and EMail of the project :* "AM_CONDITIONAL(['''TmplIncl'''],[test])" — "AM_CONDITIONAL(['''NewModIncl'''],[test])" :6. Install the OpenSCADA development package "openscada-dev" or "openscada-devel" — because the module is an external one and the OpenSCADA source files are needed only at the first stage of the module creation, you need to install the OpenSCADA development package, which contains the header files and libraries. :7. Now you can build the new module, after formation of the building system :: {{InLineCode|<nowiki>autoreconf -if; ./configure; make</nowiki>}} == API of the module == OpenSCADA API for the developer of OpenSCADA and modules to it is described in the document "[[Special:MyLanguage/Documents/API|OpenSCADA API]]", which should always be on hand at development for OpenSCADA. This document focuses on the detailed explanation of the main points of the modular API. {{#lst:Documents/API/en|ModAPI}} For the convenience of direct addressing to the root object of the module from any object lower in the hierarchy, it is recommended to define the global variable "mod" in the namespace of the module, with its initialization in the constructor of the root object. Also, for transparent translation of the text messages of the module, it is recommended to define the function templates of the module message translation call "'''_({Message})'''" and "'''trS({Message})'''" as: <syntaxhighlight lang="CPP"> #undef _ #define _(mess) mod->I18N(mess).c_str() #undef trS #define trS(mess) mod->I18N(mess,mess_PreSave) </syntaxhighlight> In the constructor of the root module's object inherited from the '''TModule''' it is necessary to set the main information of the module by call the function '''void modInfoMainSet({Name}, {Type}, {Version}, {Authors}, {Description}, {License}, {Source})''' after init the fast link "mod" to the root object of the module. Further receiving of the translation template file "po/oscd_NewMod.pot" of the text messages "'''_({Message})'''" and "'''trS({Message})'''", as well as updating-actualising the files of already existing translations "po/{uk|de|ru|...}.po" is carried out by the command {{InLineCode|make messages}} in the module folder. During solve the tasks of the new module, it may be necessary to expand the configuration parameters, which is carried out in the virtual function '''void cntrCmdProc( XMLNode *req );'''. The content of this function, which adds properties, in the [[Special:MyLanguage/Modules/SQLite|SQLite module]] looks like this: <syntaxhighlight lang="CPP"> void MBD::cntrCmdProc( XMLNode *opt ) { //Getting the page info if(opt->name() == "info") { TBD::cntrCmdProc(opt); ctrMkNode("fld",opt,-1,"/prm/cfg/ADDR",EVAL_STR,enableStat()?R_R___:RWRW__,"root",SDB_ID,3, "dest","sel_ed","select","/prm/cfg/dbFsList","help", _("SQLite DB address must be written as: \"{FileDBPath}\".\n" "Where:\n" " FileDBPath - full path to DB file (./oscada/Main.db).\n" " Use the empty path to create a temporary database on the disk.\n" " Use \":memory:\" to create a temporary database in memory.")); if(reqCnt) ctrMkNode("comm",opt,-1,"/prm/st/end_tr",_("Close opened transaction"),RWRW__,"root",SDB_ID); } //Processing for commands to the page string a_path = opt->attr("path"); if(a_path == "/prm/cfg/dbFsList" && ctrChkNode(opt)) { opt->childAdd("el")->setText(":memory:"); TSYS::ctrListFS(opt, addr(), "db;"); } else if(a_path == "/prm/st/end_tr" && ctrChkNode(opt,"set",RWRW__,"root",SDB_ID,SEC_WR) && reqCnt) transCommit(); else TBD::cntrCmdProc(opt); } </syntaxhighlight> The first half of this function serves the "info" information requests with the list and properties of the configuration fields. The second half serves all the other commands on getting, setting value, and others. The '''TBD::cntrCmdProc(opt);''' call is used to obtain the inherited interface. More details on appointment of the used functions are in the [[Special:MyLanguage/Documents/API#CntrNode|control interface]], as well as in the source code of existing modules. The '''TCntrNode''' object, in addition to the control interface function, provides unified control mechanisms for modifying the object's configuration, loading, saving, and deleting configuration duplicates in the storage. You can use the '''modif()''' and '''modifG()''' functions to set the object data modification flag, and the module-specific loading and saving actions can be placed in virtual functions: * ''void load_( TConfig *cfg );'', ''void load_( );'' — loading the object from a storage. * ''void save_( );'' — saving the object to a storage. Configuration actions typically occur through the [[Special:MyLanguage/Documents/API#TConfig|TConfig]] object, which contains a set of defined properties with structure and values. To directly reflect the properties of a module object, it inherits from '''TConfig''', and new properties are added with the command: <syntaxhighlight lang="CPP"> fldAdd(new TFld("MOD_PRMS",trS("Module addition parameters"),TFld::String,TFld::FullText|TCfg::NoVal,"100000"));</syntaxhighlight> Loading/saving/deleting of the properties specified in the '''TConfig''' object, from/to/in the storage, is made with the following commands: <syntaxhighlight lang="CPP"> TBDS::dataGet(fullDB(), owner().nodePath()+tbl(), *this); TBDS::dataSet(fullDB(), owner().nodePath()+tbl(), *this); TBDS::dataDel(fullDB(flag&NodeRemoveOnlyStor), owner().nodePath()+tbl(), *this, TBDS::UseAllKeys); </syntaxhighlight> Where: * ''fullDB()'' — the full name of the storage in the [[Special:MyLanguage/Documents/API#DataConcept|common form]]; * ''owner().nodePath()+tbl()'' — the common path, represented as the table, to the object node in the configuration file; * ''*this'' — this object, inherited from '''TConfig'''. To generate the debug messages [[Special:MyLanguage/Documents/Program_manual#Config|according the common debugging concept]], you need to use the function '''mess_debug()''' with call it conditionally at the program source part: * the rarely invoked part — direct call to the function {{InLineCode|<nowiki>mess_debug(...);</nowiki>}}; * the often invoked part — conditional call {{InLineCode|<nowiki>if(mess_lev() == TMess::Debug) mess_debug(...);</nowiki>}}; * the critical to performance code part — wrapping to definition '''OSC_DEBUG''': <syntaxhighlight lang="CPP"> #ifdef OSC_DEBUG mess_debug(...); #endif </syntaxhighlight>
Navigation menu
OpenSCADA
Site
Download
Old Wiki
OpenSCADA Wiki
Home
About OpenSCADA
Functions and demands
Tasks
Using
Fund
Recent changes
Random page
Search
Tools
Special pages
Printable version
MediaWiki
Help
Personal tools
English
Log in