TTCN3软件课设报告_软件课设总结报告

其他范文 时间:2020-02-29 07:28:04 收藏本文下载本文
【www.daodoc.com - 其他范文】

TTCN3软件课设报告由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“软件课设总结报告”。

软件课程设计

TTCN-3软件课设报告

电信0701 郭福晨 U200713312

TTCN-3软件课设

本次软件实验课程我选的是TTCN-3语言的平台移植。我和黄炯同学组成一个小

组。软件课设的大课题为:TTCN-3语言及其编译器的设计与移植。我们选择的是用ttcn语言实现自动饮料贩卖机的功能。

自助饮料售卖机的实现

1.任务要求

饮料类型:咖啡、可乐、鲜橙多、矿泉水、绿茶、红茶

饮料价格:4元、3元、3元、1元、3元、3元(只接受整数输入)

输入包括饮料类型和投币金额

输出包括输出饮料的数量以及找回钱金额

2.程序算法

module AutoSellMachine

{

function MachineFunction(in integer Number,in integer Money)runs on DrinkerComponentType//从顾客处{var charstring temp;InputPort.receive(charstring:?)-> value temp;log(temp);OutputPort.send(Number);InputPort.receive(charstring:?)-> value temp;log(temp);do {OutputPort.send(Money);接收消息并赋值,判断饮料的种类和所要求的价钱 type component DrinkerComponentType//定义接收和输入的接口 {} port CharstringInputPortType InputPort;port IntegerOutputPortType OutputPort;type port IntegerOutputPortType meage { out integer } type port CharstringInputPortType meage { in charstring }

}} log(temp);while(temp==“Sorry,money is not enough!Please try more again!”);//判断顾客给出的钱数,如果不够if(temp==“Sorry,it is not a convient number!Please try again!”)//判断顾客所选择的饮料类型,如果选{}则显示金钱不够 择的不是给出的6种饮料,则显示选择错误 return;setverdict(pa);type component EmptyComponentType {}//下述为所给出的几种情况的实例 testcase TestOne()runs on EmptyComponentType system DrinkerComponentType {}testcase TestTwo()runs on EmptyComponentType system DrinkerComponentType {} testcase TestThree()runs on EmptyComponentType system DrinkerComponentType { var DrinkerComponentType Drinker;Drinker := DrinkerComponentType.create;map(Drinker:OutputPort, system:OutputPort);map(Drinker:InputPort, system:InputPort);Drinker.start(MachineFunction(5,1));//此处方可所选定的饮料种类和给出的金钱 Drinker.done;unmap(Drinker:OutputPort, system:OutputPort);unmap(Drinker:InputPort, system:InputPort);var DrinkerComponentType Drinker;Drinker := DrinkerComponentType.create;map(Drinker:OutputPort, system:OutputPort);map(Drinker:InputPort, system:InputPort);Drinker.start(MachineFunction(0,10));//此处即顾客所选定饮料种类和给出的金钱 Drinker.done;unmap(Drinker:OutputPort, system:OutputPort);unmap(Drinker:InputPort, system:InputPort);

}} Drinker := DrinkerComponentType.create;map(Drinker:OutputPort, system:OutputPort);map(Drinker:InputPort, system:InputPort);Drinker.start(MachineFunction(6,100));//此处为顾客选定的饮料和给出的金钱 Drinker.done;unmap(Drinker:OutputPort, system:OutputPort);unmap(Drinker:InputPort, system:InputPort);

C编写的咖啡机贩卖程序

using System;

using System.Collections.Generic;

using System.Threading;

public cla AtuoDrinkMachine//定义输入和输出,饮料类型和价格

{

public static Queue inputPort;

public static Queue outputPort;

private static string[] DrinkName= {“Coffee”,“Cola”,“Orange”,“Water”,“Greentea”,“Redtea”};private static int[] DrinkPrice=new int[6] {4,3,3,1,3,3};

static Thread Task;

public static void SwitchOn()

{

inputPort = new Queue();

outputPort = new Queue();

Task = new Thread(new ThreadStart(Behaviour));

Task.Start();

}

public static void SwitchOff()

{

Task.Abort();

}

static void Behaviour()

{

int amount,choice,i,quantity,change;

outputPort.Enqueue(Convert.StringToByteArray(“Please choose one of thedrink:n0_Coffeet1_Colat2_Orangen3_Watert4_Greenteat5_Redtea”));

while(inputPort.Count == 0)Thread.Sleep(10);

byte[] InputByte=inputPort.Dequeue();

choice = Convert.ByteArrayToInt(InputByte);

if(choice5)

{

}

outputPort.Enqueue(Convert.StringToByteArray(“The drink you choosing is: ” outputPort.Enqueue(Convert.StringToByteArray(“Sorry,it return;is not a convient number!Please try again!”));+DrinkName[choice]+ “.n”+“The single price of ” +DrinkName[choice]+“is ” +DrinkPrice[choice].ToString()+“.”));

while(inputPort.Count == 0)Thread.Sleep(10);

InputByte = inputPort.Dequeue();

i = Convert.ByteArrayToInt(InputByte);

amount=i;

while(amount

{

}

quantity=amount/DrinkPrice[choice];

change=amount%DrinkPrice[choice];

outputPort.Enqueue(Convert.StringToByteArray(“Here your ”+quantity.ToString()+“ outputPort.Enqueue(Convert.StringToByteArray(”Sorry,money while(inputPort.Count == 0)Thread.Sleep(10);InputByte = inputPort.Dequeue();i = Convert.ByteArrayToInt(InputByte);amount+=i;is not enough!Please try more again!“));drink(s)and ”+change.ToString()+“ Yuan left are.Thanks!”));

Thread.Sleep(100);

}

}

课设总结

这次软件课设的整个过程使我切实的认识到了程序编写的不易和所需的严谨,任何一个小的错误与疏忽都可能导致程序的崩溃。虽然之前从书本中学习C语言的编程知识,有一定的编程基础,但是确确实实做一个真正的东西出来还是第一次,所以有很多问题都不能自己解决,所以这个过程也培养了我学习新知识和与团队配合的能力。我觉得虽然自己还是有很多不懂的地方,对于TTCN-3这门语言的了解也还远远不够,但我还是觉得自己收获很多。对于自己所学习的专业,和自己所学习的知识的实践

应用都有了全新的认识。很高兴能有这次软件课设的机会,让自己看到自己的不足,我会好好把握自己大学的最后时间,尽量在各个方面都强化自己。我觉得,课设让我看到自己和某些很优秀同学的差距,我相信,只要好好努力,有一天我也可以成为一个出色的程序员。谢谢

软件课设心得体会(模板19篇)

心得体会是一个好的学习方法,可以帮助我们更好地吸取经验、总结规律和提高自己。写心得体会时,我们需要注意结合具体案例,通过事实和数据来支持我们的观点和论述。以下是一些名......

软件课设心得体会(专业19篇)

在撰写心得体会时,要注意言之有物,结构清晰,并展现自己的独特见解与观点。在写心得体会时,可以适当运用一些图表和数据,使文章更加具体和可信。以下是小编为大家整理的心得体会,希......

软件课设心得体会(优秀15篇)

写心得体会可以培养我们的观察和思考能力,提高学习和工作的效率。写心得体会时,可以加入一些个人的感受和思考,使文章更有个性化和独特性。接下来将为大家分享一些精选的心得体......

软件课设心得体会(实用16篇)

总结心得体会可以帮助我们更好地反思和认识自己,提高自我认知和成长。写心得体会时,要注意遣词造句的准确性和得体性,尽量避免口语化表达。心得体会的写作风格因人而异,以下是一......

软件课设心得体会(优质20篇)

写心得体会可以让我们更好地反思自己的成长和发展过程。选择恰当的总结方式和结构对于写一篇完美的总结非常重要。在这里,我们为大家准备了一些实用的心得体会,希望能给大家带......

下载TTCN3软件课设报告word格式文档
下载TTCN3软件课设报告.doc
将本文档下载到自己电脑,方便修改和收藏。
点此处下载文档

文档为doc格式

热门文章
点击下载本文