Professional Documents
Culture Documents
Anexo2:main.ncl
<?xmlversion="1.0"encoding="ISO88591"?>
<nclid="DeportesAbierto"xmlns="http://www.ncl.org.br/NCL3.0/EDTVProfile">
<head>
<importedDocumentBase>
<importNCLalias="introNCL"documentURI="inicio.ncl"/>
</importedDocumentBase>
<ruleBase>
<rulecomparator="eq"id="DespliegueRule"value="Despliegue"
var="stage"/>
<rulecomparator="eq"id="menurule"value="menu"var="stage"/>
<rulecomparator="eq"id="interactivityRule"value="ON"
var="interactivity"/>
</ruleBase>
<regionBase>
<regionheight="100%"id="bgReg"left="0%"top="0%"
width="100%"zIndex="0"/>
<regionheight="100%"id="videoReg"left="0%"top="0%"
width="100%"zIndex="1"/>
<regionheight="37"id="infoReg"left="590"top="430"width="37"
zIndex="2"/>
<regionheight="205"id="MenuReg"left="0"top="275"
width="100%"zIndex="2"/>
<regionheight="275"id="DespliegueReg"left="0"top="0"
width="260"zIndex="2"/>
</regionBase>
<descriptorBase>
<descriptorid="backgroundDesc"region="bgReg"/>
<descriptorid="videoDesc"region="videoReg"/>
<descriptorid="infoDescriptor"region="infoReg"/>
<descriptorid="menuDesc"region="menuReg"/>
<descriptorid="despliegueDesc"region="despliegueReg"/>
</descriptorBase>
<connectorBase>
<causalConnectorid="onKeySelectionStopSetStart">
<connectorParamname="keyCode"/>
<connectorParamname="var"/>
<simpleConditionkey="$keyCode"role="onSelection"/>
<compoundActionoperator="seq">
<simpleActionmax="unbounded"qualifier="seq"
role="stop"/>
<simpleActionmax="unbounded"qualifier="seq"
role="set"value="$var"/>
<simpleActionmax="unbounded"qualifier="seq"
role="start"/>
</compoundAction>
</causalConnector>
<causalConnectorid="onBeginStopSetStart">
<connectorParamname="keyCode"/>
<connectorParamname="var"/>
<simpleConditionkey="$keyCode"role="onBegin"/>
<compoundActionoperator="seq">
<simpleActionmax="unbounded"qualifier="seq"
role="stop"/>
<simpleActionmax="unbounded"qualifier="seq"
role="set"value="$var"/>
<simpleActionmax="unbounded"qualifier="seq"
role="start"/>
</compoundAction>
</causalConnector>
<causalConnectorid="onKeySelectionSet">
<connectorParamname="keyCode"/>
<connectorParamname="varSet"/>
<simpleConditionkey="$keyCode"role="onSelection"/>
<simpleActionrole="set"value="$varSet"/>
</causalConnector>
<causalConnectorid="onEndAttributionStopSetStart">
<connectorParamname="var"/>
<simpleConditionrole="onEndAttribution"/>
<compoundActionoperator="seq">
<simpleActionmax="unbounded"qualifier="par"
role="stop"/>
<simpleActionrole="set"value="$var"/>
<simpleActionmax="unbounded"qualifier="par"
role="start"/>
</compoundAction>
</causalConnector>
<causalConnectorid="onEndStopStart">
<simpleConditionrole="onEnd"/>
<compoundActionoperator="seq">
<simpleActionmax="unbounded"role="stop"
qualifier="seq"/>
<simpleActionmax="unbounded"role="start"
qualifier="seq"/>
</compoundAction>
</causalConnector>
</connectorBase>
</head>
<body>
<portcomponent="video"id="entryVideo"/>
<portcomponent="info"id="entry"/>
<mediadescriptor="backgroundDesc"id="background"
src="resources/images/background.jpg"/>
<mediadescriptor="videoDesc"id="video"
src="resources/video/video.mp4">
<propertyname="bounds"/>
<areabegin="360s"id="startMenu"/>
</media>
<linkxconnector="onEndStopStart">
<bindrole="onEnd"component="video"/>
<bindrole="stop"component="video"/>
<bindrole="start"component="video"/>
</link>
<mediadescriptor="infoDescriptor"id="info"
src="resources/images/info.png"/>
<mediaid="settings"type="application/xgingasettings">
<propertyname="stage"value="intro"/>
<propertyname="interactivity"value="OFF"/>
<propertyname="service.currentKeyMaster"value="1"/>
</media>
<switchid="interactivity">
<bindRuleconstituent="startInteractivity"
rule="interactivityRule"/>
<switchid="startInteractivity">
<bindRuleconstituent="introContext"rule="introRule"/>
<bindRuleconstituent="menuContext"rule="menurule"/>
<contextid="introContext"refer="introNCL#body"/>
<contextid="menuContext">
<portid="p0"component="application"/>
<portid="p1"component="menu"/>
<portid="p2"component="despliegue"/>
<mediaid="application"src="main.lua"
type="application/xgingaNCLua">
<propertyname="buttonPressed"/>
<propertyname="menuChange"/>
<propertyname="despliegueChange"/>
</media>
<linkxconnector="onEndAttributionStopSetStart">
<bindcomponent="application"
interface="menuChange"role="onEndAttribution"/>
<bindcomponent="menu"role="stop"/>
<bindcomponent="application"
interface="menuChange"role="getValue"/>
<linkParamname="var"value="$getValue"/>
<bindcomponent="menu"interface="src"
role="set"/>
<bindcomponent="menu"role="start"/>
</link>
<linkxconnector="onEndAttributionStopSetStart">
<bindcomponent="application"
interface="delpliegueChange"role="onEndAttribution"/>
<bindcomponent="despliegue"role="stop"/>
<bindcomponent="application"
interface="despliegueChange"role="getValue"/>
<linkParamname="var"value="$getValue"/>
<bindcomponent="despliegue"interface="src"
role="set"/>
<bindcomponent="despliegue"role="start"/>
</link>
<linkxconnector="onKeySelectionSet">
<bindcomponent="application"
role="onSelection">
<bindParamname="keyCode"
value="CURSOR_RIGHT"/>
</link>
<linkxconnector="onKeySelectionSet">
<bindcomponent="application"
role="onSelection">
<bindParamname="keyCode"
value="CURSOR_LEFT"/>
</bind>
<bindcomponent="application"
interface="buttonPressed"role="set">
<bindParamname="varSet"
value="CURSOR_LEFT"/>
</bind>
</link>
<linkxconnector="onKeySelectionSet">
<bindcomponent="application"
role="onSelection">
<bindParamname="keyCode"
<linkxconnector="onKeySelectionSet">
<bindcomponent="application"
role="onSelection">
<bindParamname="keyCode"
value="CURSOR_DOWN"/>
</bind>
<bindcomponent="application"
interface="buttonPressed"role="set">
<bindParamname="varSet"
value="CURSOR_DOWN"/>
</bind>
</link>
</context>
</switch>
</switch>
<linkxconnector="onBeginStopSetStart">
<bindcomponent="video"interface="startMenu"role="onBegin"/>
<bindcomponent="interactivity"role="stop"/>
<bindcomponent="settings"interface="stage"role="set">
<bindParamname="var"value="menu"/>
</bind>
<bindcomponent="interactivity"role="start"/>
</link>
<linkxconnector="onKeySelectionStopSetStart">
<bindcomponent="background"role="onSelection">
<bindParamname="keyCode"value="ENTER"/>
</bind>
<bindcomponent="video"interface="bounds"role="set">
<bindParamname="var"value="0%,0%,100%,100%"/>
</bind>
<bindcomponent="settings"interface="interactivity"role="set">
<bindParamname="var"value="OFF"/>
</bind>
<bindcomponent="info"role="start"/>
</link>
<linkxconnector="onKeySelectionStopSetStart">
<bindcomponent="info"role="onSelection">
<bindParamname="keyCode"value="ENTER"/>
</bind>
<bindcomponent="info"role="stop"/>
<bindcomponent="video"interface="bounds"role="set">
<bindParamname="var"value="42%,3%,55%,55%"/>
</bind>
<bindcomponent="settings"interface="interactivity"role="set">
<bindParamname="var"value="ON"/>
</bind>
<bindcomponent="background"role="start"/>
<bindcomponent="interactivity"role="start"/>
</link>
</body>
</ncl>
Anexo3main.lua
localmenuIndex=0
localdespliegueIndex=0
functionhandler(evt)
ifevt.type=='attribution'andevt.name=='buttonPressed'then
ifevt.value=="UP"anddespliegueIndex~=0then
despliegueIndex=(despliegueIndex1)%3
dispatchEvent("despliegueChange",(despliegueIndex+1)..".png")
end
ifevt.value=="DOWN"anddespliegueIndex~=2then
despliegueIndex=(despliegueIndex+1)%3
dispatchEvent("despliegueChange",(despliegueIndex+1)..".png")
end
ifevt.value=="LEFT"andmenuIndex~=0then
menuIndex=(menuIndex1)%4
dispatchEvent("menuChange",(menuIndex+1)..".png")
end
ifevt.value=="RIGHT"andmenuIndex~=3then
menuIndex=(menuIndex+1)%4
dispatchEvent("menuChange",(menuIndex+1)..".png")
end
end
end
functionattributionEventDispatch(action,property,value)
return event.post('out',{class="ncl",type="attribution",name=property,
action=action,value=value})
end
functiondispatchEvent(property,value)
attributionEventDispatch('start',property,value)
attributionEventDispatch('stop',property,value)
end
event.register(handler)
CAPITULOIV
AnexoIClaseTCP
- - - Li br er a par a conexi n TCP
- - Fuent e: <a hr ef =" ht t p: / / www. t el emi di a. puc-
r i o. br / ~f r anci sco/ ncl ua/ i ndex. ht ml " >Tut or i al de NCLua</ a>
- - Decl ar aci n de mdul os, f unci ones gl obal es, y const ant es
l ocal _G, cor out i ne, event , asser t , pai r s, t ype, pr i nt
= _G, cor out i ne, event , asser t , pai r s, t ype, pr i nt
l ocal s_sub = st r i ng. sub
modul e ' t cp'
- uso de conexi ones ml t i pl es y manej o de l as mi smas
l ocal CONNECTI ONS = {}
l ocal cur r ent = f unct i on ( )
r et ur n asser t ( CONNECTI ONS[ asser t ( cor out i ne. r unni ng( ) ) ] )
end
l ocal r esume = f unct i on ( co, . . . )
asser t ( cor out i ne. st at us( co) == ' suspended' )
asser t ( cor out i ne. r esume( co, . . . ) )
i f cor out i ne. st at us( co) == ' dead' t hen
CONNECTI ONS[ co] = ni l
end
end
f unct i on handl er ( evt )
i f evt . cl ass ~= ' t cp' t hen r et ur n end
i f evt . t ype == ' connect ' t hen
f or co, t i n pai r s( CONNECTI ONS) do
i f ( t . wai t i ng == ' connect ' ) and
( t . host == evt . host ) and ( t . por t == evt . por t )
t hen
t . connect i on = evt . connect i on
t . wai t i ng = ni l
r esume( co)
br eak
end
end
r et ur n
end
i f evt . t ype == ' di sconnect ' t hen
f or co, t i n pai r s( CONNECTI ONS) do
i f t . wai t i ng and
( t . connect i on == evt . connect i on) t hen
t . wai t i ng = ni l
r esume( co, ni l , ' di sconnect ed' )
end
end
r et ur n
end
i f evt . t ype == ' dat a' t hen
f or co, t i n pai r s( CONNECTI ONS) do
i f ( t . wai t i ng == ' dat a' ) and
( t . connect i on == evt . connect i on) t hen
r esume( co, evt . val ue)
end
end
r et ur n
end
end
event . r egi st er ( handl er )
f unct i on execut e ( f , . . . )
r esume( cor out i ne. cr eat e( f ) , . . . )
pr i nt ( " f i nal i zado t cp. execut e" )
end
f unct i on connect ( host , por t )
l ocal t = {
host = host ,
por t = por t ,
wai t i ng = ' connect '
}
CONNECTI ONS[ cor out i ne. r unni ng( ) ] = t
event . post {
cl ass = ' t cp' ,
t ype = ' connect ' ,
host = host ,
por t = por t ,
}
r et ur n cor out i ne. yi el d( )
end
f unct i on di sconnect ( )
l ocal t = cur r ent ( )
event . post {
cl ass = ' t cp' ,
t ype = ' di sconnect ' ,
connect i on = asser t ( t . connect i on) ,
}
end
f unct i on send ( val ue)
l ocal t = cur r ent ( )
event . post {
cl ass = ' t cp' ,
t ype = ' dat a' ,
connect i on = asser t ( t . connect i on) ,
val ue = val ue,
}
end
f unct i on r ecei ve ( pat t er n)
pat t er n = pat t er n or ' ' - - TODO: ' *l ' / number
l ocal t = cur r ent ( )
t . wai t i ng = ' dat a'
t . pat t er n = pat t er n
i f s_sub( pat t er n, 1, 2) ~= ' *a' t hen
r et ur n cor out i ne. yi el d( )
end
l ocal al l = ' '
whi l e t r ue do
l ocal r et = cor out i ne. yi el d( )
i f r et t hen
al l = al l . . r et
el se
r et ur n al l
end
end
end