-
Notifications
You must be signed in to change notification settings - Fork 0
Tut1 Example2
Sung-June, Lim edited this page Oct 2, 2016
·
15 revisions
_tutorials
_tutorial1
example1
example2apps
HelloCyhub.py
blocks
MainWindow.py
Cone.py
cyapp.py
cyapp_cfg.py
cymgr.py
cymgr_cfg.py
cycoord.py
cycoord_cfg.py
아래와 같이 app_spec 파일의 각 항목들을 지정하여 다양한 Block 활용이 가능한 App을 구성 할 수 있습니다.
- t(title) : Application Title은 'Hello Cyhub'으로 사용
- B(Block) : 'MainWindow'의 별칭을 'main'으로, 'Cone'의 별칭을 'cone_view'으로 사용
- C(Connectivity) : -
- D(Data) : -
- R(Reference) : 'main' Block에서 'cone_view' Block을 'view' 라는 별칭으로 사용
- S(Slot) : -
def app_spec():
t = 'Hello Cyhub'
B = [('main', 'MainWindow', [], {}),
('cone_view', 'Cone', [], {})
]
C = []
D = dict()
R = [
('main', 'view', 'cone_view')
]
S = [
]
return t, B, C, D, R, S- 모든 Block Class는 metaclass로 Block_meta를 사용
- Main Block Class는 QtWidgets의 QMainWindow를 상속
- Block Class의
initialize()method는 app composition을 마친 후에 호출
즉,self.cone과 같은 R(reference)는initialize()가 호출 되는 시점부터 사용 가능 - Qt Layout, Widget을 활용하여 MainFrame을 구성
from PyQt5 import QtWidgets
from cyhub.block import Block_meta
class MainWindow(QtWidgets.QMainWindow, metaclass=Block_meta):
def __init__(self, *args, **kwds):
super().__init__(*args, **kwds)
def initialize(self):
"""
this method is called at end of 'compose_app'
thus, R(reference) like 'self.cone' are available from now (not available in __init__(..))
"""
# Organize layout.
cw = QtWidgets.QWidget()
self.setCentralWidget(cw)
cw.setLayout(QtWidgets.QVBoxLayout())
cw.layout().addWidget(self.view.as_widget())
# Show.
self.show()- 모든 Block Class는 metaclass로 Block_meta를 사용
- VTK를 활용한 Remote Rendering 지원을 위해서는 Vtk_image_holder를 상속
- Vtk_image_holder의 Renderer에 VTK Actor를 연결하여 VTK 파이프라인을 구성
from cyhub import cy_vtk
from cyhub.block import Block_meta
class Cone(cy_vtk.Vtk_image_holder, metaclass=Block_meta):
def __init__(self, *args, **kwds):
super().__init__(*args, **kwds)
self.cone = cy_vtk.actor_cone()
self.ren.AddActor(self.cone)- coord, mgr는 None으로 지정
-
cycode_prefix는 Tutorial 예제가 포함되어 있는 경로를 지정 ('/' 대신 '.'으로 디렉토리 구분) -
app은 실행 할 app_spec의 이름을 지정하고 전달할 arguments('[]')와 keywords('{}')를 지정
# cyapp configure
coord_addr = None
mgr_addr = None
conn_trace_message = True
cycode_prefix = '_tutorials._tutorial1.example2'
# Specify this for running manager.
cyres_path = '_cyres'
app = 'HelloCyhub', [], {}- cyapp.py 파일을 실행

Cloud 기반의 Application을 구성하기 위하여 2대의 Machine 환경이 필요합니다.
하나의 Machine에서는 Coordinator를 실행할 것이며, 다른 하나의 Machine에서는 Application을 실행 할 것입니다.
따라서, 2대의 Machine 환경에서 실행 가능하도록 환경이 구축되어 있어야 합니다.
(하지만, 편의상 Tutorial 시연을 위해 하나의 Machine에서 Coordinator와 Application 모두 실행 가능)
- coordinator로 사용 되고 있는 현재 Machine의 IP와 사용 가능한 Port를
server_addr에 입력
ex)server_addr = ('211.106.178.85', 8080) -
run_mgr는 True로 설정하여 Coordinator에서 Manager를 생성 -
cycode_prefix는 Tutorial 예제가 포함되어 있는 경로 지정 ('/' 대신 '.'으로 디렉토리 구분)
# cycoord configure
server_addr = ('xxx.xxx.xxx.xxx', 8080)
conn_trace_message = True
run_mgr = True
# Specify these for running manager.
cycode_prefix = '_tutorials._tutorial1.example2'
cyres_path = '_cyres'- 위에서 설정한 coordinator machine의 접속 정보를
coord_addr에 입력
ex)coord_addr = ('211.106.178.85', 8080) -
cycode_prefix는 Tutorial 예제가 포함되어 있는 경로 지정 ('/' 대신 '.'으로 디렉토리 구분) -
app은 실행 할 app_spec의 이름을 지정하고 전달할 arguments('[]')와 keywords('{}')를 지정
#####cyapp_cfg.py
# cyapp configure
coord_addr = ('xxx.xxx.xxx.xxx', 8080)
mgr_addr = None
conn_trace_message = True
cycode_prefix = '_tutorials._tutorial1.example2'
# Specify this for running manager.
cyres_path = '_cyres'
app = 'HelloCyhub', [], {}- coordinator가 위치한 machine에서 cycoord.py 파일을 실행 합니다.
- application이 위치한 machine에서 cyapp.py 파일을 실행 합니다.
- Remote Rendering이 되고 있는 Block은 좌측 상단에 'R'이 표시 됩니다.

