查看: 1|回复: 1

谁能帮我把下面的代码用汉语标注出来啊?

[复制链接]

主题

0

回帖

93

积分

注册会员

积分
93
发表于 2012-5-9 16:03:33 | 显示全部楼层 |阅读模式
这是那个超市模型的代码,由于本人代码知识欠缺,对这些代码不了解,想请位人士帮忙标注下,不胜感激!代码如下:
/**Make the shopping list and Task Sequence*/
treenode current = ownerobject(c);
treenode Shopper = msgsendingobject;

treenode ShoppingList = label(Shopper,"ShoppingList");
clearcontents(ShoppingList);
int TotalItems = duniform(1,15,1);
for( int i = 1; i<=TotalItems; i++)
{
        int Type = duniform(1,gettablerows("FoodNames"),1);
        nodeinsertinto(ShoppingList);
        treenode ActiveNode = last(ShoppingList);
        nodeadddata(ActiveNode,DATATYPE_NUMBER);
        setnodenum(ActiveNode,Type);
        setnodename(ActiveNode,gettablestr("FoodNames",Type,1));
}

////////////////////////////////////////////////////////////////////////////////////////////////////////

// move the item into the model.
moveobject(Shopper, model(), 0);
// Now if there is a network node connected to me, then connect the flow item to that node.
treenode netnode = getnetnode(current, 1);
if(objectexists(netnode))
{
        // connect the item to the network
        contextdragconnection(netnode, Shopper, "A");
        // set the location of the item.
        setloc(Shopper, xloc(netnode), yloc(netnode), 0);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////
treenode Cart = first(Shopper);

treenode Item;
treenode ts = createemptytasksequence(Shopper,0,0);


setlabelnum(Cart, "Pointer", tonum(Shopper));
setlabelnum(Cart, "Content", 0);

treenode RecycleBin = rank(ItemBin,2);
int LocationID;
treenode StopLocation;

for(int Stop = 1; Stop <= TotalItems; Stop++)
{
        LocationID = getnodenum(rank(ShoppingList, Stop));
        StopLocation = outobject(current,LocationID);
        if(LocationID<=84)
        {
                if(content(RecycleBin>0))
                {
                        Item = last(RecycleBin);
                        transfernode(Item, model());
                }
                else
                {
                        createcopy(first(ItemBin), model());
                        Item = last(model());
                }
                setobjectshapeindex(Item,gettablenum("FoodNames",LocationID,2));
                setlabelnum(Item,"Reference",LocationID);
                moveobject(Item,StopLocation,1);
        }
        if(LocationID>84) //Deli
        {
                inserttask(ts,TASKTYPE_TRAVEL,StopLocation,NULL);
                inserttask(ts,TASKTYPE_SENDMESSAGE,StopLocation,NULL,1,(LocationID - 84),0,0);
                inserttask(ts,TASKTYPE_UTILIZE,StopLocation,NULL,0);
        }
        else
        {
                inserttask(ts,TASKTYPE_TRAVEL,StopLocation,NULL);
                inserttask(ts,TASKTYPE_MOVEOBJECT,Item,Cart,0);
                inserttask(ts,TASKTYPE_DELAY,NULL,NULL,2,0);
        }
}

inserttask(ts,TASKTYPE_DELAY,NULL,NULL,1,0);
inserttask(ts,TASKTYPE_SENDMESSAGE,NULL,current,0,0,0,.1);
dispatchtasksequence(ts);
万分感谢!

主题

0

回帖

93

积分

注册会员

积分
93
 楼主| 发表于 2012-5-9 16:09:35 | 显示全部楼层
这个任务量有点大,但是我急需...
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:admin@discuz.vip

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.|京ICP备14043114号-2

在本版发帖
关注公众号
QQ客服返回顶部