基于VxWorks系统的MiniGUI图形界面开发_明芳

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

基于Vx W orks系统的M i n i G U I图形界面开发*
明 芳1) 徐 凌2) 王 刚1)
(中船重工第709研究所系统软件部1) 武汉 430074) (武汉理工大学2) 武汉 430070)
摘 要 M ini GU I是一个非常适合于实时嵌入式产品的高效、可靠、可定制、小巧灵活的图形用户界面支持系统,能支持多种不同的嵌入式操作系统,包括L i nux、V x W orks以及W i n32等平台,概述M ini G U I的技术特点和优势,介绍基于M i n i G U I嵌入式系统的软件体系结构,M i n i G U I在V x W orks下的程序开发方法。

关键词 M ini GU I 图像用户基面 V x W orks
中图分类号 TP391.41
1 引言
M i n i G U I是根据嵌入式系统应用特点量身定做的图形支持系统。

它源自一个自由软件项目,现由北京飞漫软件技术有限公司维护并开展后续开发。

M i n i G U I项目的最初目标是为基于L i n ux的实时嵌入式系统提供一个轻量级的图形用户界面。

经过近8年的开发和应用,已非常成熟和稳定,广泛应用于手持信息终端、机顶盒、工业控制系统及工业仪表、彩票机、金融终端等产品和领域。

2 M i ni G U I的特点及应用
M i n i G U I为实时嵌入式操作系统提供了非常完善的图形及图形用户界面支持。

M i n i G U I本身的可移植性设计,使得不论在哪个硬件平台、哪种操作系统上运行,M i n i G U I均能为上层应用程序提供一致的应用程序编程接口(API)。

2.1 M i n i G U I的功能特色
作为操作系统和应用程序之间的中间件, M i n i G U I将底层操作系统及硬件平台差别隐藏起来,并对上层应用程序提供一致的功能特性,这些功能特性包括:
(1)完备的多窗口机制和消息传递机制。

(2)常用的控件类,包括静态文本框、按钮、单行和多行编辑框、列表框、组合框、进度条、属性页、工具栏、拖动条、树型控件、月历控件等。

(3)对话框和消息框支持以及其它GU I元素,包括菜单、加速键、插入符、定时器等。

界面皮肤支持。

用户可通过皮肤支持获得外观非常华丽的图形界面。

(4)各种流行图像文件的支持,包括J PEG、
G I F、PNG、TGA、B M P等等。

(5)多字符集、多字体和简体中文(GB2312)输入法支持。

2.2 M i n i G U I的技术优势
和其它针对嵌入式产品的图形系统相比, M i n i G U I具有如下几大技术优势:
1.2.1 轻型、占用资源少
M i n i G U I本身的占用空间非常小。

M ini G U I的典型存储空间占用情况如下:
M ini G U I支持库:500K~700K(由编译选项确定)
M ni G U I字体、位图等资源:400K(由应用程序确定,可缩小到200K以内)
GB2312输入法码表:200K(不是必需的,由应用程序确定)
应用程序:1M~2M(由应用程序决定)
1.2.2 高性能、高可靠性
M i n i G U I良好的体系结构及优化的图形接口,可确保最快的图形绘制速度。

针对多窗口环境下的图形绘制开展了大量的研究及开发,优化了M i n i G U I的图形绘制性能及资源占有。

M ini G U I在工业控制系统的大量应用,证明M i n i G U I具有非常好的性能。

1.2.3 可配置
为满足嵌入式系统千变万化的需求,必须要求
189
第35卷(2007)第7期 计算机与数字工程 *收到本文时间:2006年2月20日
作者简介:明芳,女,助理工程师,研究方向:指控系统软件研发。

徐凌,男,硕士研究生,研究方向:嵌入式系统。

王刚,男,助理工程师,研究方向:指控系统硬件研发。

GU I 系统是可配置的。

M i n i G U I 实现了大量的编译配置选项,通过这些选项可指定M i n i G U I 库中包括
哪些功能而同时不包括哪些功能。

大体说来,可以在如下几个方面对M ini G U I 进行定制配置: M ini G U I 要运行的操作系统,是普通嵌入式L i n ux 、e Cos 还是Vx W o r ks 。

生成基于线程的M i n i G U I-Threads 运行模式还是基于进程的M ini G U I-L ite 运行模式,或者只是最简单的M ini G U I-Standalone 运行模式。

需要支持的GAL(显示)引擎和I A L (输入)引擎,以及引擎相关选项。

需要支持的字体类型、字符集、图像文件格式、控件类、控件的整体风格等。

1.2.4 跨操作系统支持
理论上,M i n i G U I 可支持任意一个多任务嵌入式操作系统;实际已支持Linux /uC linux 、e Cos 、uC /OS-II 、Vx W or ks 等嵌入式操作系统。

同时,在不同操作系统上的M ini G U I ,提供完全兼容的API 接口。

3 基于M i n i G U I 的嵌入式系统软件
结构
M i n i G U I 具有良好的软件架构,通过抽象层将M i n i G U I 上层和底层操作系统隔离开来。

如图1所示,基于M i n i G U I 的应用程序一般通过ANSI C 库以及M i n i G U I 自身提供的API 来实现自己的功能;M i n i G U I 中的 可移植层!可将特定操作系统及底层硬件的细节隐藏起来,而上层应用程序则无需
关心底层的硬件平台输出和输入设备。

图1 M ini G U I 和嵌入式操作系统的关系
4 基于M i n i G U I 的程序开发方法
下面结合一个简单实例介绍M i n i G U I 的基本编程方法。

程序功能是在窗口中打印字符串 H e l l o W orl d !。

为了介绍方便,程序在一个源文件he l l o world .c 里实现。

4.1 包含必要的头文件
he llo w orld .c 的开始所包括的四个头文件<
m inigu i/co mm on .h >、<m i n i g ui/m i n igu.i h >、<
m inigu i/gd.i h>和<m i n igu i/w indo w.h>是所有的M i n i G U I 应用程序都必须包括的头文件:
4.2 程序入口点
一个C 程序的入口点为m ain 函数,而一个M i n i G U I 程序的入口点为M i n i G U I M a i n ,该函数原型如下:i n t M i n i G U I M ain (i n t argc ,const char *ar gv[])。

下面是M ini G U M i a i n 函数的实现。

i nt M ini GU I M a i n (int arg c ,const char *argv[])
{M S G M sg ;H W ND h M ai n W nd ;
M A I NW I NCRE AT E C reate Info ;
CreateInfo .d wSty le =W S _V ISIBLE |W S _BORDER |W S_CA PT ION;
CreateInfo .d wExS t y le =W S_EX _NONE ;CreateInfo .spCapti on ="H e llo ,w orld !";CreateInfo .h M enu =0;
CreateInfo .h Curso r =G etSyste mCursor(0);CreateInfo .hIcon =0;
CreateInfo .M a i n W i ndowP roc =H ell o W i nP ro c ;CreateInfo .l x =0;CreateInfo .ty =0;CreateInfo .rx =320;CreateInfo .by =240;
CreateInfo .i BkCo lor =COLOR _ligh t w hite ;CreateInfo .d wA dd D ata =0;
CreateInfo .h H o sti ng =HW ND _DESKTOP ;h M ain W nd =C reate M a i n W i ndo w (&C reate Info);if (h M a i n W nd ==HWND _I NVAL ID )re t urn -1;
Show W i ndow (h M a i n W nd ,S W _S HOW NOR M AL );wh ile (G eM t essage(&M sg ,h M ain W nd)){T ransl a te M essage(&M sg );D ispa tch M essage(&M sg);}
M a i n W i ndo wT hread C leanup (h M a i n W nd);re t urn 0;}
(1)创建和显示窗口
h M ain W nd =Create M a i n W i n do w (&C r eateI nfo);每个M i n i G U I 应用程序的初始界面一般都是一个主
窗口,你可以通过调用Create M a i n W i n do w 函数来创建一个主窗口,其参数是一个指向MA I N W I N C RE ATE 结构的指针,本例中就是CreateI nfo ,返回值为所创建主窗口的句柄。

MAI N W I N C REATE 结构描述一个主窗口的属性,在使用C reateI nfo 创建主窗口之前,需要设置它的各项属性。

创建完主窗口之后,还需要调用Sho wW indo w
190
明 芳等:基于V x W orks 系统的M i n i G U I 图形界面开发 第35卷
函数才能把所创建的窗口显示在屏幕上。

Sho w W i n do w的第一个参数为所要显示的窗口句柄,第二个参数指明显示窗口的方式(显示还是隐藏), S W_SHO WNORMAL说明要显示主窗口,并把它置为顶层窗口。

(2)消息循环
M i n i G U I为每一个M i n i G U I程序维护一个消息队列。

在发生事件之后,M i n i G U I将事件转换为一个消息,并将消息放入目标程序的消息队列之中。

应用程序现在的任务就是执行如下的消息循环代码,不断地从消息队列中取出消息,进行处理: w hile(G e M t essage(&M sg,h M a i n W nd)){
T ransl a te M essage(&M sg);
D ispatch M essage(&M sg);
}
GeM t essage函数从应用程序的消息队列中取出一个消息,T ranslate M essage函数把击键消息转换为MSG_C HAR消息,D ispatch M essage函数最终把消息发往该消息的目标窗口的过程,让其进行处理,处理完后返回到D ispatch M essage,在从D is patch M essage中返回到应用程序中,应用程序又从下一个GeM t essage函数调用开始消息循环。

4.3 窗口过程函数
窗口过程函数是M i n i G U I程序的主体部分,应用程序实际所做的工作大部分都发生在窗口过程函数中,因为GU I程序的主要任务就是接收和处理窗口收到的各种消息。

在he llo w orld.c程序中,窗口过程是名为H ello W i n Proc的函数。

C reate M a i n W i n do w函数根据MA I N W I N C RE ATE结构类型的参数中指定的窗口过程创建主窗口。

窗口过程函数总是定义为如下形式:
sta ti c i n t H ell o W i nP roc(HW ND h W nd,i nt m essage, W PARAM wP ara m,LPARAM l Para m){
HDC hdc;
s w itch(m essage){
case M SG_PA I NT:
hdc=Beg inPa i nt(h W nd);
T ex t O ut(hdc,100,100,H ell o W o rl d!!);
EndP ai n t(h W nd,hdc);
re t urn0;
case M SG_CLO SE:
Destroy M ain W i ndow(h W nd);
Post Q uiM t essag e(h W nd);
re t urn0;}
re t urn D efaulM t a i n W i nP roc(h W nd,m essag e,wP aram, l P ara m);
}
程序通常不直接调用窗口过程函数,而是由M i n i G U I进行调用;也就是说,它是一个回调函数。

窗口过程函数不予处理的消息应该传给De faulM t a
i n W i n Pr oc函数进行缺省处理。

4.4 在Tornado下编译M i n i G U I程序
首先从飞漫公司的网站上下载运行于PC平台的Vx W orks操作系统的M i n i G U I V1.6.x开发包∀∀∀m inigu i-dev-1.6.9-vx w orks.zi p!,解压后可以得到li b m gex.t a li b m inigu.i a等文件,然后按照以下步骤编写测试程序:
(1)在Tor nado新建工作空间tes.t wsp,在工作空间tes.t w sp下建立工程projec.t wp,j并在pr o jec.t wp j 下建立bootable vx W orks m i age,选择PIII环境的BSP。

(2)添加库lib m gex.t a li b m i n i g u.i a。

(3)将M ini G U I下的i n clude文件夹拷贝到Tornado2.2\tar get\h下。

(4)将hello wo r d.c添加到pro jec.t wp j中。

(5)将hell o word.c中的入口函数M i n i G U I M ain 添加到usr Appini.t c中,然后进行编译。

将生成的vx W or ks(应用程序)下载到目标机中,可看到实验结果如图2所示。

图2 实验结果截图
4 结语
M i n i G U I现在已发
展成为一个比较成熟的
图形用户界面支持系
统,它可以运行于i386、
ARM、M I PS、Po w er PC、Cold-fire等多种硬件平台上。

能较好的支持包括Vx W orks、linux在内的多种嵌入式操作系统。

在Vx W orks系统下采用M ini G U I,可以比较快捷的完成相应的图形用户信息交互界面的开发,是Vx W orks 下一种较好的图形用户界面解决方案。

参考文献
[1]北京飞漫技术有限公司.M i ni GU I用户手册V2.0.3/1.
6.9[EB/OL].[2006-06].http://www.m i n i gu.i com/
do w nload/ci ndex.sht m l
[2]北京飞漫技术有限公司.M i n i G U I技术白皮书for V2.0.
3/1.6.9[EB/OL].[2005-09-9].http://www.
m i nigu.i com/down l oad/c i ndex.sht m l
[3]北京飞漫技术有限公司.D atasheet for M i n i G U I V2.0.3/
1.6.9[EB/OL].[2006-06].h ttp://www.m inigu.i
com/down l oad/c i ndex.sht m l
[4]北京飞漫技术有限公司.M i n i G U I编程指南V2.0.3/1.
6.9[EB/OL].[2006-06].http://www.m i n i gu.i com/
do w nload/ci ndex.sht m l
191
第35卷(2007)第7期 计算机与数字工程
Com puter and D ig ita l Eng ineer i n g I ndex(Vo.l35No.7)
stud ied,the hardwa re inte rface is designed and a com m un i c a tion prog ra m be t ween PC and DSP is deve loped. Th roug h a concre te instance,it ind i c a tes tha t the me th od p resented i n th is paper is sm i p l e,e ffective,and s a t isfy the dem and o f th is contro l system.
K ey word s m icro-d isp lace m en t actua to r,contro l sys tem,DSP,se rial co mm un ication(Page:172)
Design&I mp le m ent of Physica lly B ased S m oke An i m ati on
by Z i L i ng ling Abstrac t F lu i d S m i u l a t i o n such as s m ock,wate r,fire, e tc.is no t on ly d ifficu lt but a lso attractive in com puter g raph ics.Th is pape r rea lizes s mock sm i u l a tion and an i m ation using com putat i o na l fl u id dyna m ics and com puter g raph ics.It g i v es s m ock physical m ode l se t and se ttle e qua tions by way o f Navier-Stocks equat i o n and sem i-lag rang ian me thod.F inally s mock density filed da ta w ill be done and it w ill be changed sc reen m i age using vo l um e rende ring.
K ey word s p hysica lm ode l,s m ock,vo lume rende ring.
(Page:175) S earch Engine of Po w er Syste m Docu m en ts
by L iang D ic hen Abstrac t Fu ll-text retrieva l system is a so rt o f compu t e r in for m at i o n retr i e va l too.l I n th is pape r,it p ropose a text retr i e va l system o f design p roposa,l and introduce index database and fu ll tex t database founda tion,initial iza tion p rob l e m,p rob l e m o f de si g n search function,de s i g n o f resu ltan t page,and so on.
K ey word s reca ll rate,p rec ision ra te,sea rch function
(Page:177)
App lication for TwoW ork P lace Q i an Port i on s E lectron ic Con trol Syste m by Chen X iaozhu Abstrac t Th is a rticle m a i n ly introduce s the desi g n thought o f M itsub ish i FX2N PLC app lying for two wo rk p lace q ian po rt i o n o f the e lectron i c contro l system.It g ives a deta iled sta temen t on the co m ponents o f the system hardware and de si g n o f so ft wa re.Espec i a lly for b il a te r a l automa tic we l d ing m ethods made m o re deta iled descr i p tion o f prog ra mm ing ideas.F l o o r debugg ing showed:the e l e ctrica l con tro l system to comp l e te ly s a t isfy the requ ire m en ts o f con tro.l Th is has g rea tly en hanced the e fficiency of p roduction machine too ls.
K ey words PLC,t wo wo rk p lace q i a n portions,STL,p ro g ra mm ing i d eas(Page:180)
S i m p le Anal yzed Con ten t-based M u lti m ed i a R etrieval T echnology by Chen F ang Abstrac t C onten t-based mu ltm i ed ia retrieva l techno l o gy m anage m u ltm i ed i a in for m at i o n in a new way.It i n c ludes structured o rganiz ing and b row sing the video m ed i a and p rocessing o f m i age and aud io singa.l By u sing th is techno l o gy,w i d e ly access o f in f o r m ation is possib l e.Th is pape r ana lys is the techno logy、cha racter ist i c s and me thods o f conten t-based m u ltm i ed i a retriev a.l A t the end,the pape r po ints ou t som e p rob le m s wh i c h needs mend ing,such as fea tu re extraction、se m at i c know ledge acqusit i o n、con ten t-based cod ing and so on.
K ey words m u ltm i ed i a,conten t-based,re trieva l
(Page:183)
Create and Extraction of the B l ock#s Attribute of Auto CAD by H uang W ei Abstract The b lock#s a ttr i b u te o f Au toCAD,by w h i c h word in for m at i o n or data in fo r m at i o n can be added on b lock,is a va ri a b le characte r a rea.Th is m ethod can a vo i d ove rabundance o f i n e fficacious in for m at i o n and comp lexity in the p rocess o f extr act i n g and trea ting.The m e thod can assu re that in fo r m at i o n it extracted is nee ded list in fo r ma tion.The list estab lishing by th is m e thod has un ifor m m ode,is easy to be managed i n Au toCAD and can mee t the requ irem ent o f fil e standard iza tion in en te rp rise.
K ey words com pute r a i d ed des i g n,b lock#s attribu te,i tem list,da ta extraction(Page:187)
Develop m ent of M i n i GUI G raph ical In terface B ased on Vx W ork s by M ing Fang Abstract M in i G U I is an em bedded g raph ics suppo rt system fo r rea l tm i e em bedded p roducts w ith h i g h e ffi c iency,re li a b ility,sca l a b ility,and con fi g u rab ility,can suppo rt fo r m any d ifferen t rea ltm i e embedded ope r a ting system s,includ i n g L inux,Vx W o rks,W in32p l a tfo r m and so on,Th is pape r describes b rie fl y the techn ica l f eatures o f M in i G U I and its advan tages,then d iscusse s the so ft wa re a rch itectu re o f em bedded syste m s based on M in i G U.I F ina lly introduces p rog ra mm ing m e thod s o f M in i G U I based on Vx W o rks.
K ey words M in i G U,I GU,I Vx W orks(Page:189)
B rief i n troduc ti on on an ti-i n terference i n PLC∃s app lica tion by M a J ie yu Abstract th is pape r ma in ly introduces the app lication o f p rog ra mmab le contro ller in industr i a l con tro l fie l d and a num ber o f p rob l e m s on ensuring its no r m al ope r a tion du ring app lication p rocess of PLC,a t the same tm i e,it g ive s out som e w ise p roposa l s.
K ey word s PLC,industri a l contro,l an ti-in ter f e rence, w ir i n g,ground ing,p ropo s a l(Page:192)
8。

相关文档
最新文档