📄 4.2.4 事件方式.htm
字号:
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312
size=4>get_locator(x,y)<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN lang=EN-US><FONT
face=楷体_GB2312
size=4>下述的一段程序是用await_event、get_locator命令从1号工作站的图形输入板上输入一个点集,并用直线段连接这些点:<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN lang=EN-US><FONT
face=楷体_GB2312 size=4><SPAN style="mso-tab-count: 1">
</SPAN>set_stroke_mode(1,2,event);<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN lang=EN-US><FONT
face=楷体_GB2312 size=4><SPAN style="mso-tab-count: 1">
</SPAN>if(device_class==stroke) {<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN lang=EN-US><FONT
face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 2">
</SPAN>await_event(60,device_class,ws,device_code);<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN lang=EN-US><FONT
face=楷体_GB2312 size=4><SPAN style="mso-tab-count: 1">
</SPAN>}<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN lang=EN-US><FONT
face=楷体_GB2312 size=4><SPAN style="mso-tab-count: 1">
</SPAN>get_stroke(n,xa,ya);<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN lang=EN-US><FONT
face=楷体_GB2312 size=4><SPAN style="mso-tab-count: 1">
</SPAN>polyline(n,xa,ya);<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN
style="mso-fareast-language: ZH-CN"><FONT face=楷体_GB2312 size=4>这里<SPAN
lang=EN-US>IF条件循环为了把从其它设备来的在队列中的数据滤掉;设置的等待时间为1分钟,以保证输入数据接收完毕。当然在事件方式下,若只有这台图形输入板处于激活状态,那么这个IF条件循环就不要了。<o:p></o:p></SPAN></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN style="mso-fareast-language: ZH-CN"><FONT
face=楷体_GB2312
size=4>在事件方式下,同时可应用多台输入设备以加快交互处理。下面的程序是从键盘输入属性和从图形输入板输入数据画折线。<SPAN
lang=EN-US><o:p></o:p></SPAN></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312
size=4>set_ployline_index(1);<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312
size=4>set_stroke_mode(1,2,event);(把图形输入板设成笔划设备)<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312
size=4>set_choice_mode(1,7,event);(把键盘设成选择设备)<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4>do
{<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 2">
</SPAN>await_event(60,device_class,ws,device_code);<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 2">
</SPAN>if(device_class==choice) then {<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 3">
</SPAN>get_choice(option);<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 3">
</SPAN>set_polyline_index(option);<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 2">
</SPAN>}<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 2"> </SPAN>else
<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 3">
</SPAN>if(device_class==stroke) then {<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 4">
</SPAN>get_stroke(n,xa,ya);<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 4">
</SPAN>polyline(n,xa,ya);<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><SPAN
style="mso-tab-count: 3">
</SPAN>}<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN lang=EN-US><FONT
face=楷体_GB2312 size=4><SPAN style="mso-tab-count: 1"> </SPAN>}
while(device_class)<o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent><SPAN style="mso-fareast-language: ZH-CN"><FONT
face=楷体_GB2312 size=4>在此例中通过将<SPAN
lang=EN-US>device_class设成空来终止此过程。若等待1分钟后,还没有新事件进入事件队列,即会发生终止的情况。在事件方式下,还需应用其它一些命令,如清事件队列等。<o:p></o:p></SPAN></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><FONT face=楷体_GB2312 size=4><!--[if gte vml 1]><v:shapetype id=_x0000_t202 coordsize = "21600,21600"
o:spt = "202" path = " m0,0 l0,21600,21600,21600,21600,0 xe"><v:stroke joinstyle
= "miter"></v:stroke><v:path gradientshapeok = "t" o:connecttype =
"rect"></v:path></v:shapetype><v:shape id=_x0000_s1026
style="MARGIN-TOP: 171.6pt; Z-INDEX: 1; LEFT: 0px; MARGIN-LEFT: 0px; WIDTH: 162pt; POSITION: absolute; HEIGHT: 39pt; TEXT-ALIGN: left; mso-position-horizontal: left; mso-position-vertical: absolute"
type = "#_x0000_t202" coordsize = "21600,21600" stroked = "f"><v:textbox
style="MARGIN-TOP: 4.187pt; LEFT: auto; MARGIN-LEFT: 7.937pt; WIDTH: 147.625pt; TOP: auto; HEIGHT: 31.812pt"><![if !mso]>
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD><![endif]>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">图</SPAN><SPAN
lang=EN-US style="FONT-SIZE: 9pt"> 4.2.3 </SPAN><SPAN
style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">事件方式的输入过程</SPAN></P></DIV><![if !mso]></TD></TR></TBODY></TABLE><![endif]></v:textbox><w:wrap
type = "square"></w:wrap></v:shape><![endif]--><![if !vml]><![endif]><SPAN
lang=EN-US style="FONT-SIZE: 10pt; mso-fareast-language: ZH-CN"><!--[if gte vml 1]><v:shapetype
id=_x0000_t75 coordsize = "21600,21600" o:preferrelative = "t" o:spt = "75"
filled = "f" stroked = "f" path = " m@4@5 l@4@11@9@11@9@5 xe"><v:stroke
joinstyle = "miter"></v:stroke><v:formulas><v:f eqn =
"if lineDrawn pixelLineWidth 0 "></v:f><v:f eqn = "sum @0 1 0 "></v:f><v:f eqn =
"sum 0 0 @1 "></v:f><v:f eqn = "prod @2 1 2 "></v:f><v:f eqn =
"prod @3 21600 pixelWidth "></v:f><v:f eqn =
"prod @3 21600 pixelHeight "></v:f><v:f eqn = "sum @0 0 1 "></v:f><v:f eqn =
"prod @6 1 2 "></v:f><v:f eqn = "prod @7 21600 pixelWidth "></v:f><v:f eqn =
"sum @8 21600 0 "></v:f><v:f eqn = "prod @7 21600 pixelHeight "></v:f><v:f eqn =
"sum @10 21600 0 "></v:f></v:formulas><v:path o:extrusionok = "f"
gradientshapeok = "t" o:connecttype = "rect"></v:path><o:lock aspectratio="t"
v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025
style="WIDTH: 345pt; HEIGHT: 169.5pt" type = "#_x0000_t75" coordsize =
"21600,21600"><v:imagedata o:title="4-2-3" src =
"./les424.files/image003.gif"></v:imagedata></v:shape><![endif]--><![if !vml]><img width=460 height=226 src="les424.files/image003.gif" v:shapes="_x0000_i1025"><![endif]><o:p></o:p></SPAN></FONT></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN lang=EN-US
style="mso-fareast-language: ZH-CN"><FONT face=楷体_GB2312 size=4><![if !supportEmptyParas]> </FONT></SPAN><FONT face=楷体_GB2312
size=4><IMG height=54 alt="文本框: 图 4.2.3 事件方式的输入过程" hspace=12
src="4.2.4 事件方式.files/image001.gif" width=218 align=left
v:shapes="_x0000_s1026"></FONT><SPAN lang=EN-US
style="mso-fareast-language: ZH-CN"><FONT face=楷体_GB2312
size=4><![endif]><o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm"><SPAN lang=EN-US
style="mso-fareast-language: ZH-CN"><FONT face=楷体_GB2312 size=4><![if !supportEmptyParas]><![endif]> <o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent style="TEXT-INDENT: 0cm; TEXT-ALIGN: center"
align=center><SPAN lang=EN-US style="mso-fareast-language: ZH-CN"><FONT
face=楷体_GB2312
size=4><![if !supportEmptyParas]><![endif]> <o:p></o:p></FONT></SPAN></P>
<P class=MsoBodyTextIndent></P>
<P class=MsoBodyTextIndent><SPAN style="mso-fareast-language: ZH-CN"><FONT
face=楷体_GB2312 size=4>事件方式的输入过程见图<SPAN
lang=EN-US>4.2.3所示。在事件模式数据输入过程中,输入设备和程序分别各自运行。输入设备所产生的数据被组织成事件结点,排入事件队列中等待程序的处理。程序运行到事件处理语句时,就从事件队列中取出队首事件予以处理。如果事件队空,程序则等待一定的时间片,等待事件的发生。</SPAN></FONT></SPAN><FONT
face=楷体_GB2312 size=4><SPAN lang=EN-US
style="FONT-SIZE: 10pt; mso-fareast-language: ZH-CN"><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><SPAN lang=EN-US><FONT face=楷体_GB2312 size=4><![if !supportEmptyParas]><![endif]> <o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><A
href="http://www.ekany.com/wdg98/cg/contents/chapter4/les423.htm"><FONT
face=楷体_GB2312 size=4><<SPAN
style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">上一节</SPAN>> </FONT></A><FONT
face=楷体_GB2312 size=4> <A
href="http://www.ekany.com/wdg98/cg/contents/chapter4/les425.htm"><<SPAN
style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">下一节</SPAN>>
</A> <A
href="http://www.ekany.com/wdg98/cg/tutorial/chapter4/lesson4-2.htm"><</A></FONT></SPAN><FONT
face=楷体_GB2312 size=4><A
href="http://www.ekany.com/wdg98/cg/tutorial/chapter4/lesson4-2.htm"><SPAN
style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">返回</SPAN><SPAN
lang=EN-US>></SPAN></A></FONT></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -