博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JACK——BOM Exercise1
阅读量:5137 次
发布时间:2019-06-13

本文共 4874 字,大约阅读时间需要 16 分钟。

来源:

 

Exercise 1

Set up a Bill of Materials (BOM) beliefset.

 

In this exercise you will create a simplified BOM beliefset to be used within a Planner agent. A BOM is a data structure used in manufacturing to describe the component/subcomponent structure of part assemblies. In this tutorial, the BOM will only capture the component/subcomponent structure: in practice, it will contain much more information, such as the number of a particular component that is required, whether the component is made internally or is outsourced etc.

You will also create a main program to read BOM data provided by the user. This information will be stored in a JACK beliefset which is private to the Planner agent. An alternative mechanism for initialising the beliefset is to use a JACOB file. This alternative is used in Exercise 5.

 

1. Create a directory called practical2/ex1. In this directory, start the JDE and open a new project called BOM.

2. Create a beliefset type called BOM:

  • Open the Data Model container in the browser.
  • Right-click on the Beliefset Types folder and select Add New Beliefset Type from the pop-up menu. Call the beliefset BOM and add it to the bom package. It is to have two key fields of type String. One field is used to store a component type, and the other field is used to store a subcomponent type. This means that in this beliefset there will be n entries per component, where n is the number of subcomponent types that are used to build that component. Note that we distinguish between subcomponent types and subcomponents. For example, a table may have two subcomponent types (top and leg) but five subcomponents (one top and four legs).
  • Use the Edit as JACK File option to add the two key fields and a getSubcomponent query to the beliefset. In Exercise 2 the getSubcomponent query will be used to find a subcomponent of a given component. This means that the subcomponent field is to be an output field in the query. Although this query is not required until Exercise 2, it is added now because a JACK beliefset must have at least one query. Your BOM beliefset should be similar to the following:

package bom;

public beliefset BOM extends OpenWorld {

#key field String component;

#key field String subcomponent;

#indexed query getSubcomponent(String component,

logical String subcomponent);

}

3. We will now use the design tool to define an agent, Planner, that will store component/subcomponent tuples in a private beliefset of type BOM:

  • Create a new design diagram called Planner_AD.
  • Drag a new agent onto the Planner_AD design canvas. It is to be called Planner and it is to be in the bom package.
  • Drag the Named Data icon from the design palette onto the design canvas. The named data is to be called bom and is to be of type bom.BOM.
  • Create a private link from the Planner agent to the bom named data on the design canvas.

4. The beliefset will be populated at agent construction time. Consequently the agent's constructor will be passed two strings – the agent's name and the name of a file containing component-subcomponent details. The constructor must read each component-subcomponent relation from the file, and add the information to the agent's BOM beliefset. The code to achieve this can be added to the agent by using the browser to edit the agent as a JACK file. Sample code for the constructor follows:

public Planner(String name, String filename)

{

super(name);

StringTokenizer tokens;

String record;

String t1,t2;

BufferedReader datafile = null;

try {

datafile = new BufferedReader(new FileReader(filename));

}

catch (FileNotFoundException e) {

System.err.println("unable to open file "+e.toString());

System.exit(1);

}

try {

while ((record = datafile.readLine())!=null) {

tokens = new StringTokenizer(record);

t1 = tokens.nextToken();

t2 = tokens.nextToken();

bom.add(t1,t2);

}

}

catch (Exception e) {

System.err.println("error reading bom data into beliefset");

System.exit(1);

}

}

Make sure that the Planner agent has the following import statements:

import java.io.*;

import java.util.*;

5. Add a new file called Program.java to the Other Files folder in the browser. It will create a Planner agent, perhaps as follows:

import java.io.*;

import bom.Planner;

public class Program {

public static void main( String args[] )

{

Planner planner = new Planner("planner1","bom.dat");

System.exit(0);

}

}

If you wish to run the project from within the JDE make sure that you use the full pathname for bom.dat.

6. Create the file bom.dat and populate it with component/subcomponent records. It could contain:

chair back

chair seat

chair leg

chair arm

table top

table leg

cupboard door

cupboard drawer

cupboard leg

cupboard cabinet

7. Compile and run the program. No output is generated by the program at this stage, but it provides the basis for the remaining exercises.

 

转载于:https://www.cnblogs.com/6DAN_HUST/archive/2011/06/15/2081262.html

你可能感兴趣的文章
转负二进制(个人模版)
查看>>
LintCode-Backpack
查看>>
查询数据库锁
查看>>
[LeetCode] Palindrome Number
查看>>
我对于脚本程序的理解——百度轻应用有感
查看>>
SQL更新某列包含XX的所有值
查看>>
网易味央第二座猪场落户江西 面积超过3300亩
查看>>
面试时被问到的问题
查看>>
spring 事务管理
查看>>
VS2008 去掉msvcr90的依赖
查看>>
当前记录已被另一个用户锁定
查看>>
Bootstrap
查看>>
Node.js 连接 MySQL
查看>>
ACM-ICPC 2018 world final A题 Catch the Plane
查看>>
那些年,那些书
查看>>
面向对象六大基本原则的理解
查看>>
注解小结
查看>>
java代码编译与C/C++代码编译的区别
查看>>
Bitmap 算法
查看>>
转载 C#文件中GetCommandLineArgs()
查看>>