1 Introduction
Cette section donne la procédure suivie pas à pas pour cloner le module OWIS.
2 Clonage de l'interface CORBA
Il s'agit d'un fichier de spécification écrit en IDL.
Afin de procéder pas à pas, nous ne détaillons pas cette étape et
l'incluons dans la section suivante.
3 Clonage du serveur CORBA
Il s'agit d'un serveur écrit en C++.
- Duppliquer le module owis :
$ cd ~/cvs
$ cvs co owis
$ mkdir ~/src
$ cp -fr ~/cvs/owis ~/src/.
$ cd ~/src/owis
$ find . -type d -name CVS -exec rm -fr {} \;
- Modifier le fichier Makefile :
...
menage:
@rmdir bin lib out stub Owis Owis__POA
- compiler :
$ make 2>/dev/null && echo "no soucis"
omniidl ... -Cstub idl/Owis.idl
g++ ... -c src/Controller.C -o out/Controller.o
g++ ... -c stub/OwisSK.cc -c -o out/OwisSK.o
g++ ... -o bin/Controller
g++ ... -c src/GPIBController.C -o out/GPIBController.o
g++ ... -o bin/GPIBController
$ make clean menage
$ make
- nouveau fichier C++ :
$ cp src/Controller.C src/ctrlSecurity.C
$ sed -i.sav -e 's|^\(PROGRAMS = .*\)|\1 ctrlSecurity|' Makefile
$ sed -i.sav -e 's|^\(SOURCES = .*\)|\1 ctrlSecurity|' Makefile
$ make
g++ ... -c src/ctrlSecurity.C -o out/ctrlSecurity.o
g++ ... -o bin/ctrlSecurity
- nouveau header C++ :
$ cp include/Controller.hh include/ctrlSecurity.hh
$ sed -i.sav -e 's|^#include "Controller.hh"|#include "ctrlSecurity.hh"|' src/ctrlSecurity.C
$ make
g++ ... -c src/ctrlSecurity.C -o out/ctrlSecurity.o
g++ ... -o bin/ctrlSecurity
- modification du Makefile :
MODULE = Owis
PROGRAMS = ctrlSecurity
SOURCES = ctrlSecurity
NONROOTPROGRAMS =
LINKROOT = on
LIB = none
#DEPS.owis = HSbase HSevent
#LIBS.GPIBController = gpib
USE_LIBS = dash monitor
#NODICT = 1
#INCLUDES = sash/HESSArray
include ${HESSROOT}/dash/Makefile.dash
menage:
@rmdir bin lib out stub Owis__POA Owis
- nouveau fichier IDL :
$ cp idl/Owis.idl idl/Security.idl
$ sed -i.sav -e 's|OWIS|SECURITY|g' include/ctrlSecurity.hh src/ctrlSecurity.C
$ sed -i.sav -e 's|Owis|Security|g' include/ctrlSecurity.hh src/ctrlSecurity.C
$ sed -i.sav -e 's|^MODULE = Owis|MODULE = Security|' Makefile
$ make
erreur: monitor/ctrlSecurityEvent.hh : Aucun fichier ou répertoire de ce type
Il faut commenter les lignes relatives à ctrlSecurityEvent dans src/ctrlSecurity.C.
erreur: ‘POA_ctrlSecurity’ has not been declared
$ sed -i.sav -e 's|OWIS|SECURITY|g' idl/Security.idl
$ sed -i.sav -e 's|Owis|Security|g' idl/Security.idl
$ make
g++ ... -c src/ctrlSecurity.C -o out/ctrlSecurity.o
g++ ... -o bin/ctrlSecurity
erreur: invalid use of undefined type ‘struct Monitor::SecurityEvent
Il faut commenter les lignes contenant fEvent-> .
4 Clonage du client non graphique CORBA
Il s'agit d'un client écrit en PYTHON.
- Duppliquer le fichier :
$ cd ~/src/owis/scripts
$ cp connect_controller.py clientSecurity.py
$ sed -i.sav -e 's|Owis|Security|g' clientSecurity.py
$ python clientSecurity.py
ImportError: No module named Security
Ajuster le chemin aux modules PYTHON générés via IDL
#sys.path.append(os.environ["HESSROOT"]+"/owis")
sys.path.append(os.environ["HOME"]+"/src/owis")
Contexte :
$ ./ctrlSecurity
...
Server: Bind name ctrlSecurity ...
...
$ nameclt list roche
ctrlSecurity
$ nameclt unbind roche/ctrlSecurity
$ nameclt remove_context roche
fichier python/clientSecurity.py
#!/usr/bin/python
import os
os.environ["LC_ALL"] = "C"
import sys
import thread
import time
sys.path.append(os.environ["HESSROOT"]+"/dash")
sys.path.append(os.environ["HESSROOT"]+"/dbgui")
sys.path.append(os.environ["HOME"]+"/src/owis")
from db import *
from omniORB import CORBA
import CosNaming
import Security,Security__POA
import Dash
global orb
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
poa = orb.resolve_initial_references("RootPOA")
rootContext=orb.resolve_initial_references("NameService")._narrow(CosNaming.NamingContext)
poaManager = poa._get_the_POAManager()
poaManager.activate()
name = []
name.insert(0,CosNaming.NameComponent("ctrlSecurity", ""))
name.insert(0,CosNaming.NameComponent("roche", ""))
obj=rootContext.resolve(name)
controller = obj._narrow(Security.Controller)
if controller.GetState() == Dash.StateController.Safe:
controller.Configure()
print "Position 1:",controller.GetPosition(1)
5 Clonage de l'interface graphique CORBA
Il s'agit d'un client graphique écrit en PYTHON.
- Duppliquer le fichier :
$ cd ~/src/owis/gui
$ cp GUI.py guiSecurity.py
$ sed -i.sav -e 's|Owis|Security|g' guiSecurity.py
$ python guiSecurity.py
ImportError: No module named Security
Ajuster le chemin aux modules PYTHON générés via IDL
#sys.path.append(os.environ["HESSROOT"]+"/owis")
sys.path.append(os.environ["HOME"]+"/src/owis")
- Nouveau nom CORBA :
$ nameclt list roche/Security
GUI
|