Flexsim  编程常用代码
1.所有方向都是顺时针
2.入口跟出口连接,并入口跟升降机连接,升降机跟出口不需要连接,而且要把入口那传送带参数的FLOW设置为User Transport 沟上
3.无论那个入口和出口一定记得用A连接上
4.码盘机必须连接两次路口
5.User Transport除了升降机,堆垛机,机器人,插车.需要沟上
6.入库到仓库用A连接,跟堆垛机用s连接.出库时堆垛机不要跟出的那个传送带相连接
7.货架必须参数的FLOW设置为User Transport 沟上
8.在码盘机(Combiner)上可以设置托盘垛可以码多少 
//一、在输送机上产生一垛空托盘
fsnode* current = ownerobject(c);
fsnode* tempitem;
fsnode* destination = current;
int total  = 5;
fsnode* copy = createcopy(first(rank(node("/Tools/FlowItemBin",model()),6)),model(),0,0,1,0);
moveobject(copy,destination,0);
setitemtype(copy,1);
for (int index = 0; index < total; index++) {
 tempitem = createcopy(first(rank(node("/Tools/FlowItemBin",model()),6)),model(),0,0,1,0);
 setcolor(tempitem,255,0,0);
 moveobject(tempitem,copy);
}
//收货时的OnEntry方法代码,关闭输送机的输入口
fsnode* mypoint = node("/Conveyor147",model());
closeinput(mypoint);
//收货时的OnExit方法代码,打开输送机的输入口
fsnode* mypoint = node("/Conveyor147",model());
openinput(mypoint);
//获取全局变量的值,要指定表名,行,列号
settablenum("GlobalTable",1,1, gettablenum("GlobalTable",1,1) + 1);
//设置itemType的值 
fsnode* involved = item ;
setitemtype(involved, duniform(139, 139) );
//平均分配托盘垛到入货口
double utPort = 1;
if ((unsigned int) getitemtype(item)  == 138) {
 if (gettablenum("GlobalTable",1,1) == 1) {
  outPort = 2;
  settablenum("GlobalTable",1,1, gettablenum("GlobalTable",1,1) + 1);
  pf(gettablenum("GlobalTable",1,1));
  pr();
 } else if ( gettablenum("GlobalTable",1,1) == 2) {
  outPort = 1;
  settablenum("GlobalTable",1,1, gettablenum("GlobalTable",1,1) + 1);
 
  pf(gettablenum("GlobalTable",1,1));
  pr();
 }
 if ( gettablenum("GlobalTable",1,1) > 2) {
   settablenum("GlobalTable",1,1,  1);
 }
return outPort ;
} else {
 return 1;
}
//平均分配入库,distribute为全局变量 
if((distribute % 3) == 1){
 setitemtype(item, getitemtype(item) + 1);
}
if((distribute % 3) == 2){
 setitemtype(item, getitemtype(item) + 2);
}
if((distribute % 3) == 0){
 setitemtype(item, getitemtype(item) + 3);
}
if (distribute % 3 == 0) {
 distribute = 1;
} else {
 distribute++;
}
unsigned int type=getitemtype(item);
switch(type%100){
 case 1: return 1;
 default: return 2;
}
//用来画圆盘的代码
fsnode* current = ownerobject(c);
fsnode* view = parnode(1);
fsnode* location=getvarnode(current,"locationDisk");
double x,y,z,red,green,blue,inner,outer,start,sweep;
double x= xloc(current);
double y= yloc(current);
double z= zloc(current);
double xrot=xrot(current);
double yrot=yrot(current);
double zrot=zrot(current);
red=47;
green=140;
tabletableblue=164;
inner=1;
outer=2;
start=0;
sweep=360
drawtomodelscale(current);
drawdisk(x,y,z,inner,outer,start,sweep,xrot,yrot,zrot,red,green,blue)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。