2015.01.异构网仿真代码前30后3_第1页
2015.01.异构网仿真代码前30后3_第2页
2015.01.异构网仿真代码前30后3_第3页
2015.01.异构网仿真代码前30后3_第4页
2015.01.异构网仿真代码前30后3_第5页
免费预览已结束,剩余55页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、ackage import import java.awt.Graphics; import java.awt.geom.Po 2D;class Area extends * protected Color * 是否画出package import import java.awt.Graphics; import java.awt.geom.Po 2D;class Area extends * protected Color * 是否画出边 drawBorder = public public number, String name, String brief, Color super(num

2、ber,name,this.borderColor = * Po 2D.Double * Po 2D.Double 如果该区域由多个小区域组成,那么在坐标点 点趋近于小区域的中所在的小区域中找出一个随机点,该随Po 2D.Double get_Adjacent_Core_Coordinate(Po 2D.Double po * 用户在该区域返回 true,否则返回 * in_Area(Po 2D.Double param g 画笔(在哪个面板中画void draw_(Graphics -etBorderColor() return void setBorderColor(Color borde

3、rColor) in_Area(Po 2D.Double param g 画笔(在哪个面板中画void draw_(Graphics -etBorderColor() return void setBorderColor(Color borderColor) this.borderColor = isDrawBorder() return public void drawBorder) this.drawBorder = -package import import java.awt.Graphics; importjava.awt.geom.Po 2D; importjava.util.Ra

4、ndom; public class CircleArea extends * protected Po 2D.Double * 半protected double public ic Random ran = new public protected Po 2D.Double * 半protected double public ic Random ran = new public number, String name, String Color borderColor, double x, double y, R)super(number, name, brief, centre=new

5、Po 2D.Double(x,y); this.R = R;-public Po 2D.Double get_Ran_Coordinate() /TODOAuto-generatedmethodstub double x;double double angle = x = centre.getX() + Math.sqrt(ran.nextDouble()*R*Math.cos(angle); y = centre.getY() + Math.sqrt(ran.nextDouble()*R*Math.sin(angle); Po 2D.Double coordinate = new Po 2D

6、.Double(x, y);return public Po 2D.Double get_Core_Coordinate() / TODO Auto-generated method /System.out.pr doublex; double double angle = x = centre.getX() + ran.nextDouble()*R*Math.cos(angle); y = centre.getY() + ran.nextDouble()*R*Math.sin(angle); Po 2D.Double coordinate = new Po 2D.Double(x, y);

7、returncoordinate;public Po 2D.Double get_Adjacent_Core_Coordinate(Po /TODOAuto-generatedmethodstub return get_Core_Coordinate();po ) in_Area(Po 2D.Double po /TODOAuto-generatedmethodif(po .distance(centre) = R) return true;return in_Area(Po 2D.Double po /TODOAuto-generatedmethodif(po .distance(centr

8、e) = x1 & po .x = y1 & po .y - public String get_Whole_Brief() / TODO Auto-generated method stub String brief = super.get_Whole_Brief();brief += Identity.getBriefWithLinefeed(top left corner: + x1 + , + y1); brief += Identity.getBriefWithLinefeed(lower right corner: + x2 + , +public String get_Whole

9、_Brief() / TODO Auto-generated method stub String brief = super.get_Whole_Brief();brief += Identity.getBriefWithLinefeed(top left corner: + x1 + , + y1); brief += Identity.getBriefWithLinefeed(lower right corner: + x2 + , + y2); returnbrief;public String return package import importjava.awt.geom.Po

10、2D.Double; importjava.util.List;import public class xtends RectArea implements public number, String name, String brief, Color super(number, name, brief, borderColor, x1, y1, x2, - reversal_(Double po ) /TODOAuto-generatedmethodwhile(!in_Area(po .x po .x -= (x2 - .x po .y -= (y2 - if(po .y po .y +=

11、(y2 - return reversal_(MobileTerminal /TODOAuto-generatedmethodif(po .y = (splitSpace-2) | e.getY() = (splitSpace-2) | e.getY() = (splitSpace-2) | e.getX() = (splitSpace-2) | e.getY() = (splitSpace-2) | e.getX() = public class AreaAdd extends public void get_Number() / TODO Auto-generated method num

12、ber = ;public void get_Number() / TODO Auto-generated method number = ;import ;* This code was enerated using CloudGardens * SWT/Swing GUI Builder, which is free mer * use. If Jiglooimport ;* This code was enerated using CloudGardens * SWT/Swing GUI Builder, which is free mer * use. If Jigloo is bei

13、ng used commer lly (ie, by a * company or business for any e whatever) then * should purchase a license for each developer using * Please for * Use of Jigloo imp s acceptance of these licensing * A L LICENSE HAS NOT BEEN PURCHASED * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE * LEGALLY FOR ANY CO

14、RPORATE OR L class AreaQuery extends private JScrollPane private JButton private JPanel private JComboBox private JButton private JButton private JButton private JTable ;VectorVector tableColumn = new Table 元素Vector =s ic AreaQuery public System.out.pr VectorVector tableColumn = new Table 元素Vector =

15、s ic AreaQuery public System.out.pr s ic AreaQuery if(areaQuery = areaQuery = new return void launchFrame() this.setSize(600, jScrollPane1 = new jScrollPane1.setBounds(213, 43, 335, = new jTable1 = new jScrollPane1.setBounds(213, 43, 335, = new jTable1 = new 设置jButton1 = new jButton1.setBounds(21, 1

16、54, 62, jButton1.setSize(70, jButton2 = new jButton2.setBounds(104, 154, 62, jButton2.setSize(70, jButton3 = new jButton3.setBounds(21, 207, 62, jButton2.setBounds(104, 154, 62, jButton2.setSize(70, jButton3 = new jButton3.setBounds(21, 207, 62, jButton3.setSize(70, jButton4 = new jButton4.setBounds

17、(104, 207, 62, jButton4.setSize(70, jPanel1 = new GridLayout jPanel1Layout = new jPanel1.setBounds(21, 61, 153, =(new String 圆形区域, 方形区域jComboBox1 = new jPanel1.setBounds(21, 61, 153, =(new String 圆形区域, 方形区域jComboBox1 = new public void i=0; iGeneralControl.getInstance().getAreas().size(); Vector area

18、 = new import import i=0; iGeneralControl.getInstance().getAreas().size(); Vector area = new import import import import import return ic void BlockUser = blockUser) getBeginServedUser() return ic void BeginServedUser = getEndServedUser() return ic void EndServedUserreturn ic void BlockUser = blockU

19、ser) getBeginServedUser() return ic void BeginServedUser = getEndServedUser() return ic void EndServedUser = endServedUser) etwork getLinkNetwork() return void linkNetwork) this.linkNetwork = etwork return void etwork this.oldLinkNetwork = public void draw(Graphics g, Color /TODOAuto-generatedmethod

20、stub super.draw(g, mtColor, SIZE);Color c = g.getColor(); if(linkNetwork!=null)SIZE) i=0; icouldLinks.size(); package java.awt.geom.Po i=0; i *in WSS,in 相关表示其WSS 中的用户可能会切换到当前的WSS 中,即private eger *in WSS,in 相关表示其WSS 中的用户可能会切换到当前的WSS 中,即protected *out WSS,out WSS 中的用户可能会切换到其它与in WSS 中,即这里的用户到哪里protect

21、ed ArrayList - 需-ServedPhoneUserNetwork(SameNetworksSet linkMobileTerminals = new ArrayList(); channelHodingTimes = new ArrayListoWSSs = new ArrayList(); gotoWSSs = new ArrayList();number ,String name, this.number= = name; this.location = location;return 是否成功连public void openLink(MobileTerm

22、inal param public void i=0; ilinkMobileTerminals.size(); break - - -public void run_One_Time() /TODOAuto-generatedmethodstub i=0; i+) ;- - -public void run_One_Time() /TODOAuto-generatedmethodstub i=0; i+) ;user_Add(MobileTerminal / TODO Auto-generated method if( super.user_Add(mt, resource) returnr

23、eturn user_Remove(MobileTerminal / TODO Auto-generated method if( super.user_Remove(mt, resource) returnreturn public void oWSSs.removeAll( oWSSs); public void initial_Network() /TODOAuto-generatedmethodstub * 打印统计数 public istical_Data_Pr () super.st atistical_Data_Pr ();i=0;i param private void tim

24、e)if(channelHodingTimes.size()-1 i=channelHodingTimes.size(); i+) * 打印统计数 public istical_Data_Pr () super.st atistical_Data_Pr ();i=0;i param private void time)if(channelHodingTimes.size()-1 i=channelHodingTimes.size(); i+) get /in 相关的WSS 的相关用数* 获得用户到哪里去了信息param wss goto WSSWSS 为空则表示用户断开了网param Drop

25、User 用户是否掉 public void etwork resource, umber=us = wumber = elseusLeaveType.FinishCall) w umber wumber = elseusLeaveType.NoChange) returnSystem.out.pr ln(Wrong in ServedPhoneUserNetwork - i=0; igotoWSSs.size(); umber gotoWSSs.add(new RelativeWSS(Constant.DeadRate + umber), wn, wumber = elseusLeaveTy

26、pe.NoChange) returnSystem.out.pr ln(Wrong in ServedPhoneUserNetwork - i=0; igotoWSSs.size(); umber gotoWSSs.add(new RelativeWSS(Constant.DeadRate + umber), wn, umber, out WSS param out WSS 的名称* return out WSS String wwumber = Stringstr=umberRelativeWSS.DROP) str=+ else umber RelativeWSS.QUIT)str=str

27、str = str + wireless + /out 相关的WSS return public void param public void etwork wif(wn = wumber = if(wn.equals(this)eturnumber = i=0; i oWSSs.size(); umber oWSSs.add(new RelativeWSS(Constant.BirthRate + _ 获得 in 相关的无线网络的名称,如if(wn = wumber = if(wn.equals(this)eturnumber = i=0; i oWSSs.size(); umber oWS

28、Ss.add(new RelativeWSS(Constant.BirthRate + _ 获得 in 相关的无线网络的名称,如果该无线网络存在的话给出无线网络回其含param return in 相关的无线网络的名String get wwumber String str = umber= + EW) str=str = str + wireless + ArrayList return void linkMobileTerminals) this.linkMobileTerminals = ArrayList oWSSs() public void oWSSs) this. oWSSs A

29、rrayList getGotoWSSs() return void setGotoWSSs(ArrayList gotoWSSs) this.gotoWSSs = ArrayList getChannelHodingTimes() return void setChannelHodingTimes(ArrayList this.channelHodingTimes = -ArrayList getGotoWSSs() return void setGotoWSSs(ArrayList gotoWSSs) this.gotoWSSs = ArrayList getChannelHodingTi

30、mes() return void setChannelHodingTimes(ArrayList this.channelHodingTimes = -public void creat_Record_Tool() /TODOAuto-generatedmethodstub /System.out.pr i=0; i oWSSs.size(); i=0; igotoWSSs.size(); public void destroy_Record_Tool() /TODOAuto-generatedmethodstub i=0; i oWSSs.size(); i=0; igotoWSSs.si

31、ze(); public void record_Data() /TODOAuto-generatedmethodstub i=0;i public void reinitialize_Data() /TODOAuto-generatedmethodstub i=0; igotoWSSs.size(); i=0; i oWSSs.size(); -这里的相关 WSS 主要表现在用户上,对于一个 WSS public void reinitialize_Data() /TODOAuto-generatedmethodstub i=0; igotoWSSs.size(); i=0; i oWSSs

32、.size(); -这里的相关 WSS 主要表现在用户上,对于一个 WSS 来说,如果他的用户可以到另外一个 out 相关,如果其他WSS WSS in 相private class RelativeWSS implements * private ic private ic 掉线用DROP = -NEW = -QUIT = -private ic ave private String privateetwork/相关的 WSS 小于0 时有特殊含义(通常表示这个无线网络不存在/与这个相关 WSS 之间有联系的用户的量private ArrayList historyUserAmounts =

33、 new ArrayList private RelativeWSS(String name, = etwork this.wss = this.number = number; this.userAmount=userAmount; privateaddUserAmount()privatereduceUserAmount() userAm ount-;privatethis.wss = this.number = number; this.userAmount=userAmount; privateaddUserAmount()privatereduceUserAmou

34、nt() userAm ount-;privateetwork returnprivate void this.wss=getNumber() return etworkprivatevoid this.number=getUserAmount() return private void -public void record_Data() / TODO Auto-generated method /if(save = System.out.pr public void reinitialize_Data() /TODOAuto-generatedmethodstub userAmount =

35、 0;private void clearHistoryUserAmounts() public void creat_Record_Tool() / TODO Auto-generated method stub save = new ave(name + public public void creat_Record_Tool() / TODO Auto-generated method stub save = new ave(name + public void destroy_Record_Tool() /TODOAuto-generatedmethodstub String Stri

36、ng str = i=0; ihistoryUserAmounts.size(); str = str + + return i=historyUserAmounts.size(); i 可以连接上该 WSS 的用户,即这个网络能够检测到 MT *public List * 所属的是何种无线网private SameNetworksSet - 需-* 进入这个网络的信号覆盖范围之内的移动终端的数* 离开这个网络的信号覆盖范围之内的移动终端的数* 用户在该网络信号覆盖范围中的驻留时protected eger * 离开这个网络的信号覆盖范围之内的移动终端的数* 用户在该网络信号覆盖范围中的驻留时

37、protected eger - 需-public public couldLinkMobileTerminals = mobileTerminalResidenceTimeinCoverage = new ArrayList normalNeighbors = new s = this.resource = public number ,String name, this.number= = name; this.location = location;* 运行一个时间public void i=0; icouldLinkMobileTerminals.size(); /S

38、ystem.out.pr param public void signalDetect(MobileTerminal mt) param public void couldLinkMTEnter(MobileTerminalparam public void couldLinkMTEnter(MobileTerminal mt) couldLinkMobileTerminals.add(new MobileTerminalTimeInfo(mt); enterCouldLinkMobileTerminalAmount +;param public void couldLinkMTQuit(Mo

39、bileTerminal i=0; icouldLinkMobileTerminals.size(); param public void i=mobileTerminalResidenceTimeinCoverage.size(); i+) /if(this.number = /System.out.pr ln(this.number + , + time + , + mobileTerminalResidenceTimeinCoverage.size() , + mobileTerminalResidenceTimeinCoverage.get(time);+* 把停留时间打印出publi

40、c void pr System.out.pr ln(network number: + System.out.pr i=0; i+) System.out.pr (i+ System.out.pr ln(); System.out.pr (Amount);System.out.pr ln(network number: + System.out.pr i=0; i+) System.out.pr (i+ System.out.pr ln(); System.out.pr (Amount);i=0; i+) System.out.pr (mobileTerminalResidenceTimei

41、nCoverage.get(i) + System.out.pr ln(); System.out.pr time = i=0; i+) time += System.out.pr ln(i + , + System.out.pr ln(总时间: + param public void network) if(location.distance(network.location) 回收资param requireResource 回收的资源数return 是否成功回 this.resource += if(resourcesns.getResourceMax() return return *

42、 * return 是否有足够的资源进行分requireResource) if(resource this.resource-=requireResource; returntrue;System.out.pr ln(为:+this.number+的 * return 是否有足够的资源进行分requireResource) if(resource this.resource-=requireResource; returntrue;System.out.pr ln(为:+this.number+的 WSS 不能给该用户分配资源, +因为 WSS 的资源数量为:+resource+需要的资源为

43、+requireResource); return false;param param user_Add(MobileTerminal resource) if(resour return true;return * 删param param user_Remove(MobileTerminal /TODOAuto-generatedmethodstub return resource) System.out.pr ln(位置:BS returnfalse;public void etwork param wn 另一个网public void etwork param wn 另一个网param

44、 wn 另一个网param s public void etwork resource, s* WSS 的名称public String return etwork + public String String detailInfo = detailInfo=detailInfo++ returndetailInfo; + * 在屏幕中把统计参数打印出public void s istical_Data_Pr System.out.pr ln(进入数量 = + enterCouldLinkMobileTerminalAmount); System.out.pr ln(离开数量

45、 = + quiteCouldLinkMobiliteTerminalAmount);* public void * 清除网络与用户的连接信public void this.resource = sns.getResourceMax(); public void draw(Graphics Color c = g.getColor(); drawX = MainFrame.xV2R(location.getX(); drawY = MainFrame.yV2R(location.getY();drawCoverageArea = ( ) se() g.drawLine(drawX-drawCo

46、verageArea/2, ( ( g.drawLine(drawX+drawCoverageArea/2, ( )(drawY- drawCoverageArea*Math.sqrt(3)/2), drawX+drawCoverageArea, drawY);g.drawLine(drawX+drawCoverageArea, drawY, (g.drawLine(drawX-drawCoverageArea, drawY, drawX-se() g.drawLine(drawX-drawCoverageArea/2, ( ( g.drawLine(drawX+drawCoverageAre

47、a/2, ( )(drawY- drawCoverageArea*Math.sqrt(3)/2), drawX+drawCoverageArea, drawY);g.drawLine(drawX+drawCoverageArea, drawY, (g.drawLine(drawX-drawCoverageArea, drawY, drawX- caseRound:(g.drawOval(drawX -( )drawCoverageArea, drawY-)drawCoverageArea*2, ( (ig.drawString(name, drawX+5, drawY-/AP BS publi

48、c void mouseEvent(MouseEvent if(e.getButton() =MouseEvent.BUTTON3& getNormalNeighbors() return void etwork normalNeighbors) this.normalNeighbors = getEnterCouldLinkMobileTerminalAmount() public void enterCouldLinkMobileTerminalAmount) getQuiteCouldLinkMobiliteTerminalAmount() void quiteCouldLinkMobi

49、liteTerminalAmount) =List getMobileTerminalResidenceTimeinCoverage() void this.mobileTerminalResidenceTimeinCoverage = public void creat_Record_Tool() / TODO Auto-generated method stub enterCouldLinkMobileTerminalAmountSave = new+_ + wirelessthis.mobileTerminalResidenceTimeinCoverage = public void c

50、reat_Record_Tool() / TODO Auto-generated method stub enterCouldLinkMobileTerminalAmountSave = new+_ + wireless + this.number + quiteCouldLinkMobiliteTerminalAmountSave = +_ + wireless + this.number + mobileTerminalAmountSave = new ave(Constant.UserAmount _ + wireless + this.number + public void dest

51、roy_Record_Tool() / TODO Auto-generated method stub - public void record_Data() / TODO Auto-generated method public void reinitialize_Data() / TODO Auto-generated method stub enterCouldLinkMobileTerminalAmount=0;quiteCouldLinkMobiliteTerminalAmount = package import java.awt.geom.Po importjava.util.A

52、rrayList; importjava.util.List;etwork Node based on Connected author Tengfei *class package import java.awt.geom.Po importjava.util.ArrayList; importjava.util.List;etwork Node based on Connected author Tengfei *class etworkNode extends * 用户的资源数量,如果用户需要的资源数量为 1 的话,resource 就表示这个WSS 还能够连接* 这个WSS ,其中BS

53、 10000 开* WSS 的名in WSS,in 相关表示其它WSS WSS 中,即这protected oWSSs = new out WSS,out 相关表示当前WSS 中的用户可能会切换到其in *WSS protected ArrayList gotoWSSs = new * WSS 在地图上(即 User erface 中)drawX, public 通过设定WSS param 构造一个WSS 实例,这样WSS 的坐标需要另外WSS public this.number public 通过设定WSS param 构造一个WSS 实例,这样WSS 的坐标需要另外WSS public

54、this.number = * WSS 构造方法,同时设定WSS 的坐标WSS WSS param public etworkNode(Po 2D.Double this.location = * WSS 断开一个用户的连protected void closeLink(MobileTerminal user) userList.remove(user); WSS 断开一个需求的资源数量为 1 用户的连接,在 userList 中删除用户的指针,并回收资param user 连接上的用return 是否断开了一个用户的连接,如果 WSS 回收的资源超过了它的最大资源数量返false,否则返回

55、removeUser(MobileTerminal * WSS 断开一个需求的资源数resource 用户的连接,在userList 中删除用户的指针,并param user 连接上的用param resource 用* return 是否断开了一个用户的连接,如果 WSS 回收的资源超过了它的最大资源数量返false,否则返回 removeUser(MobileTerminal 回收资* WSS protected void openLink(MobileTerminal user)userList.add(user); enterAmount +;WSS 连接一个需求的资源数量为 1 的用

56、户,并且获得这个用户的指针,protected void openLink(MobileTerminal user)userList.add(user); enterAmount +;WSS 连接一个需求的资源数量为 1 的用户,并且获得这个用户的指针,给用户分配资param user 连接上的用return 是否成功连接了一个用户,如果 WSS 还有足够的资源分给用户返回true 否则返addUser(MobileTerminal returntrue;return * WSS 连接上连接一个需求的资源数量为 resource 的用户,并且获得这个用户的指针,给用* param user 连

57、接上的用* param 是否成功连接了一个用户,如果 WSS 还有足够的资源分给用户返回 true * addUser(MobileTerminal returntrue;return 给出资if(resource = this.resource-=requireResource; returntrue;System.out.pr ln(为:+number+的 WSS 不能给该用户分配资源, +因为 WSS 的资源数量为:+resource+需要的资源为+requireResource); return false;* 获得用户到哪里去了信息umber=-2 表示用户正常umber=-3 表示

58、用户掉param wss goto WSSWSS 为空则表示用户断开了网param DropUser 用户是否掉public void etworkNode wif(DropUser & wss = wumber = -elseif(!DropUser&wssnull) umberparam wss goto WSSWSS 为空则表示用户断开了网param DropUser 用户是否掉public void etworkNode wif(DropUser & wss = wumber = -elseif(!DropUser&wssnull) umber= -wumber = i=0; igot

59、oWSSs.size(); umber gotoWSSs.add(new RelativeWSS(wss, umber, out WSS param out WSS 的名称* return out WSS public String wumber = Stringstr=umber = -str = str + else umber = -str = str + str = str + return public void i=0; igotoWSSs.size(); public void public void wif(wss = wumber = -wumber = i oWSSs.si

60、ze(); umber public void clear i=0; i oWSSs.size(); public void 清除相关WSS 里面的历史用户数if(wss = wumber = -wumber = i oWSSs.size(); umber public void clear i=0; i oWSSs.size(); public void 清除相关WSS 里面的历史用户数i=0; i oWSSs.size(); i=0; igotoWSSs.size(); void 将相关 WSS 里面的用户数i=0; i oWSSs.size(); i=0; igotoWSSs.size(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论