Sunteți pe pagina 1din 115

1

Mdf Bible
Mdf MES Development framework

Step by step guidelines


Design and code to build a complete MES solution with Mdf library
EmPystudio IT plant solutions
Claudio Palomba and Massimiliano Papaleo

The best way to learn a new framework is


to build something with it.
This e-book walks through how to build a small,
but complete,
application using Mdf.

7
Contents

Introduction........................................................................................... 11

Aboutthisbook ..................................................................................... 12

Systemrequirements ............................................................................ 14

Supportforthisbook ............................................................................ 15

Part1 ............................................................................................................. 17
5

ISA95andMESapplication................................................................. 19
5.1

Equipmenthierarchicalmodel ...................................................... 20

5.2

Equipmentmodel .......................................................................... 22

5.3

Materialmodel .............................................................................. 23

5.4

Personnelmodel............................................................................ 24

5.5

Processsegmentmodel ................................................................ 25

5.6

Highlevelmodels .......................................................................... 27

5.7

Productioncapability..................................................................... 29

5.8

Productioncapabilityutilization.................................................... 31

5.9

Productdefinitioninformation ..................................................... 33

5.10

Productionschedule...................................................................... 35

5.11

ProductionPerformance ............................................................... 37

B2MML .................................................................................................. 39
6.1

SegmentRequirement .................................................................. 40

6.2

MaterialDefinition ........................................................................ 42

Mdf:ISA95andVisualStudio.NET....................................................... 43
7.1

MdfComponents........................................................................... 44

7.1.1

TheBusinessEntitiesproject................................................. 44

7.1.2

TheCustomClassGenerator ................................................. 45

Mdfarchitecture ................................................................................... 51

EntityFramework .................................................................................. 53

9.1

LINQtoEntities.............................................................................. 54

9.2

EntityDataModelMapping .......................................................... 54

9.3

ObjectService................................................................................ 54

9.4

EntityClientDataProvider ............................................................ 55

9.5

Somequeryexamples ................................................................... 55

10

WorkflowFoundation......................................................................... 57

10.1

SequentialWorkflow..................................................................... 58

10.2

StateMachineWorkflow............................................................... 59

Part2 ............................................................................................................. 61
11

InstallandconfigureMdf ................................................................... 63

11.1

MdfandMSDTC............................................................................. 63

11.2

Mdfconfiguration.......................................................................... 66

11.3

MdfPortaldatabaseconnection................................................... 66

11.4

Constantsandparameters ............................................................ 67

11.5

Sequences...................................................................................... 68

12

ModelMESapplication ...................................................................... 69

12.1

Mdfmodels ................................................................................... 69

12.1.1

HandlingUnitmodel.............................................................. 69

12.1.2

Ordermodel .......................................................................... 70

12.1.3

ProjectEntitiesmodel ........................................................... 70

12.2

Resourcemodelsdefinition........................................................... 71

12.2.1

Howtoaddanewclass ......................................................... 73

12.2.2

Howtoaddanewclassproperty.......................................... 73

12.2.3

Howtoaddclasspropertiestoaclass ................................. 74

12.3

Howtocreateaninstancesofcustomclass ................................. 76

12.4

ProcessSegmentDefinition .......................................................... 77

13

Customproductionrule ..................................................................... 80

13.1

Definematerialclassesforproducts............................................. 80

13.2

Howtocreateacustomproductionrule ...................................... 81

13.2.1

Howtodefineanaddproductionrulemethod .................... 82

13.2.2

Howtodefineamodifyproductionrulemethod ................. 84

13.2.3

Howtodefineadeleteproductionrulemethod .................. 84

13.3

ProductionRulepresentationlayer .............................................. 84

13.4

Conclusions.................................................................................... 84

14

Customproductionschedule ............................................................. 85

14.1

Howtorealizeanaddnewproductionschedule.......................... 86

14.2

Howtorealizeadeletemethod.................................................... 90

14.3

Howtorealizeamodifymethod................................................... 91

15

Collectproductiondata ...................................................................... 92

15.1

Productionperformance ............................................................... 92

15.2

Productioncapability..................................................................... 93

15.3

Productioncapabilityutilization.................................................... 94

15.4 Howtopopulatetheproductionperformanceandcapability
utilizationmodels ...................................................................................... 96
15.4.1

Startaproductionorder........................................................ 96

15.4.2

Stopaproductionorder ........................................................ 98

15.4.3

Restartaproductionorder.................................................. 100

Part3 ........................................................................................................... 103


16

Reporting .......................................................................................... 104

16.1

Howtoconstructareport ........................................................... 104

16.2

Howtoviewareport................................................................... 108

Part4 ........................................................................................................... 109


17

Usecase:Traceability ....................................................................... 111

17.1

Forwardtraceability .................................................................... 111

10

Appendix...................................................................................................... 113
A. Bibliography......................................................................................... 114
B. Website............................................................................................... 115

11

1 INTRODUCTION
The scope of this book is to introduce the reader to the use of the new
library Mdf. Mdf stands for MES development framework and its purpose is to
aid programmers in MES application to develop their solution easier and
faster in respect of the standard ANSI/ISA 95 and its implementation B2MML.
Mdf library was launched at the beginning of 2007 and completely reworked
by the end of 2008 with LINQ to Entities technology.
The intent of this book is to support the reared, by explanations and code
examples, in developing of MES applicative modules using Mdf library.

12

2 ABOUT THIS BOOK


This book originate from an university project for a master thesis at
University of Naples Federico II. In particular it regards the Master of
Automation Engineering at Faculty of Engineering.
The scope of this thesis is to establish the state of the art of MES applications
and train the reader in a real MES solution development instrument such as
Mdf. For this purpose the University of Naples Federico II have organize an
internship with EmPy studio with the intent to write this book.
The People involved in this project are:
Prof. Giovanni Celentano.
Giovanni Celentano was born in 1948. After a praiseworthy undergraduate
career, in 1973 he accomplished the Bachelor of Electronic Engineering
degree cum laude at University of Naples Federico II. In the same year he
began the academic career in the Automation Group at Faculty of
Engineering in Naples and in 1985 he became full professor in Systems
Theory. He was been involved in several research themes about system and
control theory and he have participated in many collaborations with industry,
university, and research institutes both national and international. In him
career Celentano have written about 150 scientific publication and 7 books.
He is presently supervisor for the thesis which this book is related.
Massimiliano Papaleo.
Born in 1971, Massimiliano Papaleo has a master degree in computer science
and industrial automation (University of Naples Federico II) and since 1998
works into MES projects, from analysis to start up, from developing to
customer service for Tau Controllo Processi, a company controlled by
Siemens. On March 2007 established EmPy studio working especially for
Siemens I&S. As soon as he started in the new company, with several skilled
technicians, wrote the Mdf library to develop MES solutions. With knowledge
of ISA-95 standard, Papaleo started to apply the guide lines with standard
tools like Microsoft Visual Studio .NET and SQL Server.
He is presently the external supervisor at EmPy studio for this thesis work
and writer of this book.
Fabio Caponetti.
Fabio Caponetti was born in San Severino Marche (MC), Italy, on 16 May
1982. In November 2004 he received the degree in Information and
Automation Engineering from Universit Politecnica delle Marche. In
December 2006 he received the Master degree cum laude in Industrial
Automation Engineering from Universit Politecnica delle Marche. He got the

13
title of Information and Industrial Engineer from the Italian State in 2007.
Since 2006 he attends an Industrial Research Doctorate in Artificial Intelligent
Systems held by DIIGA, Universit Politecnica delle Marche, Ancona (Italy) in
collaboration with Integra Software Srl, Jesi (Italy). Selected for the Siemens
Student Program, he got several industrial collaborations with them. His main
research interests include autonomous robotics, agent based software
systems, fault detection and diagnosis for industrial systems, supervision and
management of manufacture systems, Linux and high availability systems.
He is currently Assistant Researcher at the Technical University of Denmark
(DTU), Kgs. Lyngby (Denmark) to design methods and algorithms for datadriven fault detection and diagnosis as part of his PhD program.
He is collaborating with EmPy studio (Naples, Italy), on the definition of
reliable .NET tools for ISA-95 compliant Manufacturing Execution Systems
development.
Claudio Palomba.
Claudio Palomba was born in Naples, Italy on 5 July 1983. In 2006 he
accomplished the Bachelor of Automation Engineering degree with a
graduation thesis about the use of genetic algorithm for material cutting.
In the same year he started studying for the Master of Automation
Engineering degree, within this framework, he is now involved in the
internship with EmPy studio for writing this book in order to complete the
studies with the degree thesis which this book is related.

14

3 SYSTEM REQUIREMENTS
The system required for using Mdf library are the following:

Operative System: Windows Server 2003, Windows Server 2008,


Windows XP Professional, Windows Vista Business, Windows 7
Professional or more with Internet Information Service installed

.NET Framework 3.5 Service Pack 1 available on Microsoft Download


Center 1 Web site

Visual Studio 2008 with Service Pack 1 (minimal Standard Edition)

SQL Server 2008 any version.

Mdf library freely available on EmPy studio 2 web site

The download of Mdf library subordinate to a little presentation that consist


in indicate few personal data: Name, Surname, Company and Mail address.
At the mail address indicated an e-mail will be sent with download link inside.
The Mdf version available for download will work continuously for 20
minutes, after the library throws an exception. By waiting 10 minutes it will
work again (see Figure 3-1). By this way would be possible to develop and
test the framework in the contest of a custom made application.
Such limitation is obviously not present in the commercial version of Mdf
where no time limit are present.

Figure 3-1 Time distribution Mdf exception

http://www.microsoft.com/downloads/details.aspx?FamilyId=333325FDAE52-4E35-B531-508D977D32A6&displaylang=en
2
http://www.empystudio.com/Mdf/Downloads.aspx

15

4 SUPPORT FOR THIS BOOK


This book is supported by several document which are listen in the
bibliography and web site bibliography section. Some of this documents are
particular important in order to better understand the scope of this library
and how it works.

1
2
3

Mdf is based on ISA 95 standardISA2000, documentation about


it is available on the ISA 1 web site

Mdf is compatible with B2MML standardWorld Batch Forum),


documentation about it is available on the B2MML 2 web page

Mdf is written with C# .NET language that make it compatible with


the ASP.NET tool, documentation about ASP.NET 3 is available on its
web site.

http://www.isa.org/
https://www.wbf.org/catalog/b2mml.php
http://asp.net

16

17

P ART 1

18

19

5 ISA - 95 AND MES APPLICATION


MES (Manufacturing Execution System) is the execution layer of a
manufacturing application. It works as intermediary between the business
system, such as an ERP (Enterprise Resource Planning), and the
manufacturing plant floor control system. The scope of a MES system is to
deliver updated information useful for the optimization of production
activities from order launch to finished goods.
In order to define and implement industry-specific MES solutions a detailed
definition is mandatory. To rule this growing field, ISA (The Instrumentation
System, and Automation Society) introduced the ISA-95 standard in the
.
2000ISA2000
This standard separates the enterprise application functionally into three
identifiable layers.
The top layer is referred to as Business Planning and Logistic, which handles
the supplier and customer-facing applications and the internal business level
functions related to resource planning, product life cycle management,
financials, inventory management and logistics.
The bottom layer of functionality applies to the specific process control
activities related to batch, continuous and discrete control. This is the layer of
control that is responsible for the physical control of the machinery and
manual processes used for manufacturing.
Manufacturing operation management is the middle ground between the two
boundary functional layers and is the modern equivalent of MES. This
standard provides a clear picture of the various functional activities and highlevel information flows found within manufacturing operations management
in enough detail to define and implement MES solution.
ISA-95 standard firstly defines models and the terminology to emphasize
good integration practices between control and enterprise systems during the
entire life cycle. Moreover they can be used to improve existing integration
capabilities of manufacturing control systems with enterprise systems, and
can be applied regardless of the automation degree.
ISA-95 is not a norm but only a standard. There is no intent to suggest a big
picture that must be followed in each enterprise system.
Nevertheless by following a standard the time required to design and develop
should be (as arguable) lesser than custom-made solutions. Sharing ideas,
comments and solutions to common issues will enhance and boost the
application development.

20
All the models defined in the standard are structured hierarchically. The
modelling procedure consists of two phases: definition of the resource
models than introduction of the relationships between.
The resource models are split in three models:

Equipment model,

Material model,

Personnel model.

5.1

Equipment hierarchical model

Level 0,1,2

Level 3

Level 4

Also the equipments are organized in a hierarchical model. Equipment


models have to describe the physical assets of a manufacturing enterprise,
which naturally follow a hierarchical structure. The formal equipment
hierarchical model, shown below, describes how lower level groupings are
combined to form high level entities. Such schema defines the areas of
responsibility for the different function levels.

Figure 5-1 Equipment hierarchy model


The function levels are:

Level 4. Business planning and logistics level. It concern, among


other things, operation management, plant production scheduling,
collect and maintaining all files in order to manage the enterprise
resources and orders.

21

Level 3. Manufacturing operation and control. It concern, among


other things, dispatching production, detailer production schedule,
reliability assurance, optimize the area resources use for production.

Level 0, 1, 2. Discrete, continuous and batch control. It concern the


direct control of local resources.

Figure 5-1 illustrates the equipment hierarchy model.

An enterprise is a collection of one or more sites and may contain


sites and areas. The enterprise is responsible for determining what
products will be manufactured, at which sites, and in general how
they will be manufactured.

A site is a physical, geographical, or logical grouping determined by


the enterprise. At this level are implements the level 4 functions
focus on local site management and optimization.

An area is a physical, geographical, or logical grouping determined


by the site. This level implements some of level 3 and 4 functions,
especially for planning and scheduling.

Under the area level there are the lowest level equipment typically
scheduled by the level 4 or level 3 functions, which are splits depend
on manufacturing process type:
o

Production units for continuous manufacturing;

Production lines and work cells for discrete manufacturing;

Process cell and units for batch manufacturing.

The following paragraphs will show the various model defined by ISA-95
standard. To increase the readability the properties of the models will not be
discussed. For a detailed review please refer toISA2000.
In the following all the graphs which will be introduced will make use of a
table of colour.

Blue, model table,

Green, resource model,

Orange, high level model.

Both resource and high level models may be referenced by other model
tables.

22

5.2

Equipment model

The equipment model contains the information about specific equipment, the
classes of equipment, both of them with their own property (several
equipment property maps to equipment class property), equipment capability
test, and maintenance information associated with equipment. Figure 5-2
illustrate the ISA-95 equipment model.

Figure 5-2 Equipment model

An equipment class is a way to describe a group of equipments with


similar characteristics for purpose of scheduling and planning.

Equipment represents the elements of the equipment hierarchy


model defined above. Equipment may be made up of other
equipment, as defined in the equipment hierarchy model.

An equipment capability test specification may be associated with an


equipment property. This is typically used where a test is required to
ensure that the equipment has the rated capability.

An equipment capability test result records the results from a


qualification test for a specific piece of equipment.

23

5.3

A maintenance request is made against a specific equipment. There


may be many outstanding maintenance requests against a piece of
equipment. A maintenance request may result in a maintenance work
order against the equipment. Zero or more maintenance work orders
may be generated from a maintenance request. A maintenance
response is made against a maintenance work order.

Material model

The material model defines the actual materials (split in lot and sublot
material), material definitions, and information about classes of material
definitions, which of them with their own property (several material
definitions property maps to material class property and some material lot
property maps to definition material property). Figure 5-3 illustrates the
material model.

Figure 5-3 Material model

A material definition is a means to defining goods with similar


characteristics for purposes of scheduling and planning. The same
material may have different definitions for different production
requests, depending on specific customer requirements.

A material class is a means to defining groupings of material


definitions for use in production scheduling or processing. A material
definition may belong to zero or more material classes.

24

A material lot object uniquely identifies a specific amount of material,


countable or weighable. This describes the actual total quantity or
amount of material available, its current state, and its specific
property values.

A material lot may be stored as separate identifiable quantity, each


of them is identified in a material sublot object. All material sublot
must contain the same material lot, so they use the material lot
elements property value. Each material sublot also contains the
location of the sublot and the quantity of material available in the
sublot.

A QA (Quality Assurance) test specification may be associated with a


material class property. This is typically used where a test is required
to ensure that the material has the required property value.

A QA (Quality Assurance) test result records the results from a QA


test for a specific piece of material lot.

5.4

Personnel model

The personnel model contains the information about specific personnel, class
of personnel, both of them with their own property (several person property
maps to personnel class property), and qualifications of personnel. Figure 5-4
illustrates the personnel model.

Figure 5-4 Personnel model

A personnel class is used to describe a grouping of persons with


similar characteristics for purposes of scheduling and planning.

A person represents an identifiable individual.

A qualification test specification may be associated with a personnel


class property or person property. This is typically used where a
qualification test is required to ensure that a person has the correct

25
training and/or experience for specific operations. A qualification test
specification may test for one or more properties.

5.5

A qualification test result records the results from a qualification test


for a specific person.

Process segment model

The relationships between resources (equipments, materials and personnel)


are describe by process segment models.
A process segment is a logical grouping of equipment, material and
personnel resources required to carry out a production step. Process segment
usually defines the needed classes of equipment, material and personnel, but
it may define a specific resource. Process segment usually defines the
quantity of the resource needed. A process segment may relative to one or
more products, and may be made up of other process segment, in a
hierarchy of definitions. Figure 5-5 illustrates the process segment model.

Figure 5-5 Process segment model

The resource (equipment, material and personnel) segment


specifications define which resources are required to carry out the
process segment.

26

Process segment parameters define specific parameters required for


the process segment such as product shape or colour, or assembly or
packaging options.

Process segment dependency can be used to describe process


dependencies that are independent of any particular product. This
dependencies may be related to another process segments or to
specific resources within the segments.

27

5.6

High level models

The models describe so far are the core of the MES, they define the data
which will be used to define higher level models. It is possible to mark two
model groups, one of these contain all models concerning the capability data
and the other contain all models involved in production.
Production
Capability
What resources
are/will be available

Corresponds
to a
Resource
Capability

Production
Capability

Corresponds
to a
Corresponds
to a
Resource
Segment
Capability

Process
Capability

Process
Segment
Capability

Process
Segment

Resource
Segment
What can be
Specification
generally done
with the resources

Corresponds
to a
Resource

Process
Capability
utilization
What was done
with the resources

Production
Capability
Utilization
What resources
are/were used

Process
Segment

Segment
Capability
Utilization

Corresponds
to a
Resource
Capability
Utilization

Corresponds
to a

May be compared to obtain OEE

Corresponds
to a

May be compared to obtain OEE

What can be
done with the
resources

Process
Segment
Capability
Utilization

Corresponds
to a
Production
Capability
Utilization

Figure 5-6 Capability model inter-relation


The core of this model group is the process segment model, described in the
paragraph Process segment model5.5, the others models make reference to
this one. The process segment model is not exactly an high level model but

28
represents the linker model between the resources model and the high level
ones. It expresses what can be generally done with the resources.
Still referring to the Figure 5-6 the first two models are strongly dependent;
indeed the process capability model is present as a part of the production
capability model. Its the same for the two last models.

Figure 5-7 High model inter-relations


Also this second model group is based on the process segment model which
the other models is referred.
The last two have a large correlation; all together they form the production
information. The production scheduling corresponds to requests for
production and the production performances are the responses to the
requests. Figure 5-7 illustrates the model cross reference.

29

5.7

Production capability

The production capabilities data are the collection of information about all the
resources available in production at a given time. These information are
obtained by combination of the available, committed, and unattainable
capability. Hence the production capabilities represents the theoretical
maximum capabilities available for use in production.

Committed capability defines resources that are committed to future


production, due to existing schedules and/or materials in production.

Unattainable capability defines resources that are not attainable


given the equipment condition, equipment utilization, personnel
availability, and material availability.

Available capability defines the resources that are available for


additional production and not committed to production.

The model for production capability (illustrated in Figure 5-8) is defined as a


collection of resource capabilities and process segment capabilities for a
given segment of time. It can be committed, available and unattainable.

Figure 5-8 Production capability model

Resource capability are defined as a set of references to a specific


resource (for each resources: equipments, materials, lots or sublots
and personnel) or resource classes (equipment classes, material
classes and personnel classes) that are committed, available or
unavailable for a defined time. The resources capability properties
may include the quantity of the resource referenced.

30

A process segment capability is defined as a logical grouping of


resources that are committed, available, or unavailable for a definite
process segment for a specific time. A process segment capability is
related to a product segment that can be required during production,
as defined in the product definition information model, and it may
relate to one or more products. Figure 5-9 illustrates the process
capability model.
Process
Segment
Capability

Corresponds to

Process
Segment

Is defined as a collection of

0..n

0..n

0..n

Equipment
Segment
Capability

Material
Segment
Capability

Personnel
Segment
Capability

Corresponds
to element in
1..1
Equipment Model

Corresponds
to element in
1..1
Material Model

Corresponds
to element in
1..1

Personnel Model

Figure 5-9 Process capability model

31

5.8

Production capability utilization

The production capability utilization model is define as a collection of


equipment, material, personnel and process segment historical capabilities
information for a specific time (past or current). This information keep track
of the use of each resources and, for a definite time slice, they may be
defined as utilized, unused or maximum available.

Utilized capability defines resources that were used in production of


products within acceptable quality limits.

Unused capability defines resources that were not used in


production. They may have
multiple reasons for the unused
capacity, for example lack of demand, equipment failure or
maintenance.

Maximum available production capacity utilization is the capability


that was available for use in production. It may be calculated from
the beset capacity utilization achieved over some recent period of
time. It may have change over time as equipment material and
personnel capability is added modified or removed.

The model for production capability utilization (illustrated in Figure 5-10) is


defined as a collection of capability utilization resources and process segment
capability utilization for a given segment of time. It can be utilized, unused
and maximum available.
Production
Capability
Utilization
Is defined as a collection of
0..n
Equipment
Capability
Utilization
Corresponds
to element in
1..1

0..n

0..n

0..n

Material
Capability
Utilization

Personnel
Capability
Utilization

Process
Segment
Capability
Utilization

Corresponds
to element in
1..1

Equipment Model

Material Model

Corresponds
to element in
1..1

Personnel Model

Figure 5-10 Production capability model

32

Resource capability utilization are defined as a set of references to a


specific resource (for each resources: equipments, materials, lots or
sublots and personnel) or resource classes (equipment classes,
material classes and personnel classes) that were utilized, unused or
maximum available for a defined time.

A process segment capability utilization is defined as a logical


grouping of resources that were utilized, unused or maximum
available for a definite process segment for a specific time. A process
segment capability utilization is related to a product segment that
was required during production, as defined in the product definition
information model, and it may relate to one or more products. Figure
5-11 illustrates the process capability model.
Process
Segment
Capability
Utilization

Corresponds to

Process
Segment

Is defined as a collection of

0..n

0..n

0..n

Equipment
Segment
Capability
Utilization

Material
Segment
Capability
Utilization

Personnel
Segment
Capability
Utilization

Corresponds
to element in
1..1
Equipment Model

Corresponds
to element in
1..1
Material Model

Corresponds
to element in
1..1

Personnel Model

Figure 5-11 Process capability model

33

5.9

Product definition information

The product definition information model collects the information required for
the production of a specific product. This information is shared between
production rules, bill of material and bill of resources. Figure 5-12 illustrates
the ISA-95 product definition information model.

Has a reference to
Bill of Resources
(Externel)

Bill of Materia
(External)

Has a reference to
Has associated

Has associated
0..n
Has associated
Product
Production Rule
0..n

Manufacturing
Bill
1..1

Has associated
May be
made up of
0..n

0..n

1..n
Product
Segment

Corresponds to

Process
Segment

Is defined as a collection of
0..n
Product
Paremeter

0..n

0..n

0..n

Equipment
Segment
Capability

Material
Segment
Capability

Personnel
Segment
Capability

Corresponds
to element in
Equipment Model
1..1

Corresponds
to element in
1..1

1..n
Material Model

Corresponds
to element in
1..1

Personnel Model

Figure 5-12 Product definition information model

34

Product production rules are defined as the information used to


instruct a manufacturing operation on how to produce a product.

The bill of material is a list of all materials required to produce a


product including the quantity of each request. It is a subset of the
bill of resource.

The bill of resources is the list of the resources required to produce a


product.

A product segment identifies, references or corresponds to a process


segment. A product segment is related to a specific product, while a
process segment is product independent. The collection of product
segments for a product defines the sequence and order of segments
required to manufacture a product in sufficient detail for product
planning and scheduling.

A resource (equipments, materials, personnel) specification identifies,


references or corresponds to a resource capability and may specify
either a resource class or a particular resource (equipment, material,
lot, person). This identifies the specific resource capability that is
associated with the identified product segment.

The manufacturing bill includes all uses of the material in production


of the product, while the product segments material specification
defines just the amount used in a segment of production.

35

5.10

Production schedule

The production schedule model contains all of the information about the
execution of scheduled production runs. Figure 5-13 illustrates the product
definition information model.

Figure 5-13 Production schedule model

36

A production schedule defined a request for production. A production


schedule is made up of one or more production requests.

A production request defined a request for production for a single


product identified by a production rule. A production request must
contain at last one segment requirement.

A production segment requirement is made up of one or more


segment requirements. Each segment requirement must correspond
to, or reference, an identified process or product segment.

An instance of the equipment requirement class could be an


equipment that the facility will use in the production process for the
scheduled item. It could be a generic equipment or a particular pices
of equipment.

A material produced requirements is an identification of a material to


be produced from the production request.

A material consumed requirements is an identification of a material


to be used in the production request.

Consumable expected include resources that are not normally


included in bills of material or not individually accounted for in a
specific production requests. Consumable are often materials that do
have an inventory balance but do not have a lot identifications.

A personnel requirement refer to the number, type, duration and


scheduling of specific certifications and job classifications needed to
support the current production request.

A production parameter is information contained in the enterprise


system that is required by the operation system for correct
production.

A requested segment response is the definition of the information


that must be sent back as result of the production request.

37

5.11

Production Performance

The production performances are obtained collecting what was made and
used for production. Figure 5-14 illustrates the production performance
model.

Figure 5-14 Production performance model

38

Production performance is a collection of production responses.

Production response contains the responses from manufacturing that


are associated with a production request. A production result may
include the status of the request.

A segment response is the production response for a specific


segment of production.

Production data is information related to the actual products made.

The resource (equipments, materials, personnel) actual in a


production response identifies a resource capability (equipments,
materials produced and materials used, personnel) during a definite
product segment.

Consumable actual include resources that are consumed and that are
not included in a bill of material.

39

6 B2MML
The Business to Manufacturing Markup Language (B2MML) is used courtesy
of the World Batch Forum (WBF) The organization for production
technology 1 . WBF is a non-profit, non commercial end-user oriented
professional organization and it is an association of vendor, consultants, enduser and academics.
B2MML is an XML implementation of the ANSI/ISA 95 family of standards.
B2MML consists of a set of XML schemas written using the Word Wide Web
Consortiums XML Schemas language (XSD) that implement the data models
in the ISA95 standard.
The B2MML standard is widely used for the communication between
Enterprise Resource Planning (ERP) and Manufacturing Execution System
(MES), for example more product of the ICT company SAP allow to easy
import and export data by B2MML protocols.
A MES solution that support B2MML is possible to easy integrate this one to
other ICT modules in order to obtain an high automated enterprise. Moreover
the compatibility with B2MML reduce the implementation time, for example if
an enterprise that produce perfumes have made all production rules in
respect of B2MML standard, the MES solution have only to integrate them
instead of rewrite them all.
In chapter 5 are shown the ISA 95 models without the relatives attributes.
The description of these attributes is the intent of ISA 95 Part 2. A B2MML
schema consist in accurate transposition of the ISA 95 models with all
attributes. In order to increment compatibility and customizability in B2MML
schemas are added some other attribute, like Extended or Any, that allow
the programmer to adapt models to their own needs. Moreover B2MML add
some new models to the ISA 95 standards ones, like Common model that
contain the information that is used in common by B2MML equipment,
material, personnel, maintenance, capabilities, product definition, production
schedule and production performance schemas.
Other information about B2MML is available on the WBF web site at the
B2MML page 2
The following paragraphs show two examples of B2MML schemas and in both
of them the added attributes are highlighted.

1
2

https://www.wbf.org/catalog/
https://www.wbf.org/catalog/b2mml.php

40
The two example are a description of segment requirement in the production
schedule model and a Xml implementation of material definition in the
material model.

6.1

Segment Requirement

The definition that the B2MML standards gives for this table of the production
schedule model is similar to the ISA 95 definition but it is more accurate
where it says that a segment requirement corresponds to either a product
segment or a process segment. B2MML suggest that in order to respect the
spirit of the ISA 95 standard, a segment requirement should corresponds to a
product segment while a product segment should refer to a process segment.
In this way the segment requirement point to the product segment but it can
contain both product or process segment properties, for this reason the
production parameters are partitioned in process parameter and production
parameter.
The only attributes that are already present in ISA 95 standards are: ID,
Production Segment ID, Process Segment ID, Description, Earliest Start
Time, Latest End Time and Duration, and these are show in the following
diagram with orange colour blokes. The other blue blokes are B2MML
introduced attributes.
In particular B2MML introduced the possibility that a Segment Requirement
could refer to another Segment Requirement.
Figure 6-1 illustrates the Segment Requirement XML schema.

41

Figure 6-1 Segment Requirement XML schema

42

6.2

Material Definition

In this paragraph is shown an example of Xml code that regards a particular


material definition that include also a material definition property with its own
attributes.
In this case we suppose that we need to insert a particular Finished
Material called Fashion Perfume identified with the following ID
FinishedMaterial.Perfume351 and relative to a particular Material Lot
FinishedMaterial.Perfume351.Lot53. It contain also a material property
called Perfumery Concentration with its own ID and the property value 20
determinate by a QA (Quality assurance) test QATest.PerfumeryConc.
<MaterialDefinition>
<ID>FinishedMaterial.Perfume351</ID>
<Description>Fashion Perfume</Description>
<MaterialDefinitionProperty>
<ID>FinishedMaterial.PerfumeryConcentration</ID>
<Description>Perfumery Concentration</Description>
<Value>20</Value>
<QAMaterialTestSpecificationID>QATest.PerfumeryConc
</QAMaterialTestSpecificationID>
<Extended></Extended>
<Any></Any>
</MaterialDefinitionProperty>
<MaterialClassID>FinishedMaterial</MaterialClassID>
<MaterialLotID>FinishedMaterial.Perfume351.Lot53</MaterialLotID>
<Extended></Extended>
<Any></Any>
</MaterialDefinition>

In this case only Extended and Any are been added to the ISA 95 standard
attributes, besides of course MaterialClassID and MaterialLotID that are
defined implicitly by ISA 95 material model though they are not expressly
indicate as material definition attributes.

43

7 MDF: ISA-95 AND VISUAL STUDIO .NET


As already seen in the preceding chapters, the ANSI/ISA 95 standard
determinate the guidelines for the implementation of an MES solution.
B2MML, instead, is itself an implementation that is based on the ISA 95
standard but it expand a lot of its models and it creates some other new
models. Also Mdf is an implementation of the Isa 95 standard that is
compatible with B2MML so is possible to import or export data between
them. It means that the data can be imported or exported between all the
application that respect the B2MML standard.
Mdf stands for MES development framework, it is a library that permit a
faster, easier and more accurate developing of a MES solution. This can be
because it force the user to respect the ISA 95 and B2MML standards so the
whole architecture result more solid and efficient.
The Mdf library base technologies are two Microsoft products:

.NET Framework

SQL Sever

The .NET Framework is a Windows component that provides an objectoriented programming environment. It has two main component: the
Common Language Runtime and the .NET Framework class library. The
runtime is regarded as an agent that manage code at the execution time,
and providing some core services such as memory management, thread
management, and remoting. The class library is a collection of reusable types
that you can use to develop applications or other custom object library.
Microsoft .NET supports multiple languages such as Visual Basic .NET, Visual
C# .NET, Visual J#.NET and many more that follow the Common Language
Infrastructure specification. More information about .NET are available on
Microsoft Developer Network (MSDN) .NET Framework Developer Center 1
web site. For Mdf we opt for Visual C# .NET language.
SQL Server is a database platform that is composed by three main part:
Database Engine, Analysis Services and Reporting Services. The Database
Engine is the core service for storing data and includes some other services
such as creating indexes, views, and stored procedures for viewing,
managing, and securing data. Analysis Services is the core services for
supporting rapid analysis of business data, delivering online analytical
processing (OLPA) and data mining functionality in business intelligence
applications. Reporting Services is a server-based reporting platform that
provides comprehensive data reporting from relational and multidimensional
data sources. More information about SQL Server are available on Microsoft
1

http://msdn.microsoft.com/en-us/netframework/default.aspx

44
Developer Network (MSDN) SQL Server Developer Center 1 web site. For
Mdf we use SQL Server as storage layer of the Mdf architecture that will deal
with in the following chapter. Mdf also use the SQL tool Reporting Services to
create and manage production reporting.

7.1

Mdf Components

Mdf is composed by several parts that are: Mdf Console Application


(Windows application), Mdf Portal (Web application), Mdf Business Entities
(Visual Studio 2008 project template), and Custom Class Generator (Visual
Studio 2008 add-in).
Once you have installed Mdf console application, its possible to automatically
create an Mdf database with all the ISA 95/B2MML/Mdf standard tables (how
to do this is shown in Part 2 of this white paper). The web application Mdf
Portal is used to populate the database (describing this application is not the
intent of this chapter).
To implement the business rules that manage the MES, Mdf makes available
a Visual Studio project template named Business Entities and a Visual Studio
add-in named Custom Class Generator (CCG). Both of them are implemented
in C# code.

7.1.1

The Business Entities project

The Business Entities has two base functions. It is the interface between
storage layer and the other projects that make up a MES application, such as
a web application for accessing the MES data. This function is obtained by
creating an ADO.NET Entity Data Model, by using the LINQ to Entities
technology (see Chapter 9), for each resource (Equipment, material and
Personnel), Order, and Project Entities models (that are an extension of
ISA95 and B2MML models), and the other ISA95 high level models.
Business Entities is also the MES solution core, because provide all custom
classes with a standard set of business rules (automatically generated by the
CCG) that can be extended by using the partial class technique in order to
include in each class all others methods and business rules required by the
particular MES implementation. The partial class technique make it possible
to split the definition of a class over two or more source files. Each source file
contains a section of the class definition, and all parts are combined when
the application is compiled. In this way its possible to add class methods
without having to edit the file created by the Custom Class Generator.

http://msdn.microsoft.com/en-us/sqlserver/default.aspx

45

7.1.2

The Custom Class Generator

On Business Entities works the Custom Class Generator (CCG) that is a Visual
Studio 2008 add-on, installed with Mdf. It works by following a custom class
pattern shown in Figure 7-1.

Figure 7-1 Custom Class Pattern


Once you have create the Mdf database you can insert in it some new classes
such as Packaging-Line class as a new Equipment Class or Raw-Material and
Semi Finished in Material Classes (you can do this by using Mdf Portal). You
can also create a custom class property and associate it with a class. Figure
7-2 illustrates an example with the equipment classes that make clear how is
used a new custom class (in red)
Equipment Classes

Packaging Line

Packaging Line 02

Elements:

Elements:

Properties:

Enterprise
Packaging Line
Site

Packaging Line 01
Packaging Line 02
Packaging Line 03

Status: Available
Package Counter: 10

Custom Equipment Class Property


Elements:
Status
Manager
Package Counter

Figure 7-2 Equipment custom class, tables example


Figure 7-3 also illustrates the same example with the material classes. In this
case there are only custom classes (in red) and for each of them it had to
create a table. It is possible to add properties to each custom class taking
them from the Custom Material Class Property table where all the material
properties are defined. Actually there are more than one type of custom

46
element related to a material class but for the sake of simplicity this example
contain only the tables related to Material Definition elements.
Raw Material

Alcohol

Elements:

Properties:

Colouring 51
Alcohol
Essence 192

Gradation: 96%

Material Classes

Custom Material Class Property

Elements:

Elements:

Raw Material
Semi Finished

Purity
Gradation
Cream type

Semi Finished

Iri Cream

Elements:

Properties:

Limoncello
Iri Cream

Gradation: 15%
Cream type: with whole milk

Figure 7-3 Material custom class, tables example


In this two cases the Custom Class Generator makes some change on
Business Entities. Firstly it modifies the database adding three new tables
that
will
be
named
dbo.customEquipmet_PackagingLines,
dbo.customMaterial_RawMaterials and dbo.customMaterial_SemiFinisheds.
Figure 7-4 shows some Mdf database tables among which the three new
tables are highlighted.

Figure 7-4 New database tables


Than it modifies the Equipment and Material Entity Data Models so that they
include the new tables. Which of them are shown in Figure 7-5 and Figure
7-6

47

Figure 7-5 Equipment Entity Data Model

Figure 7-6 Material Entity Data Model


In the end it creates two class files, one for each new classes, that contain
the standard methods required to work with the new classes such as Get,
Add, Modify, Delete, and other standard methods.

48

Figure 7-7 PackagingLine Class diagram

49
The following code is refer to the custom method ResetPackagingCounter:
public partial class PackagingLine
{
public void ResetPackagingCounter()
{
this.PackageCounter = 0;
}
public static void ResetPackagingCounter(string packagingLineID)
{
PackagingLine packageLine = PackagingLine.Load(packagingLineID);
packageLine.ResetPackagingCounter();
packageLine.Save();
}
}

The code above extends the PackagingLine class with a custom method. A
example could be Reset Package Counter, it provide to reset the Package
Counter property and could be invoked for example every hour in order to
count the number of package per hour that this line can actual provide. This
method is written in a custom class file in the Business Entities project that
extend the class with the partial class method.
The CCG makes these changes when it notices that there is a new custom
class, but it dont do nothing when a custom class is deleted from the
database. The CCG use this policy to preserve data that could by inserted in
the custom class table. For example: if you erase an entry from Equipment
Class you are deleting an equipment custom class for which the CCG has
generate a table. This one could contain important data that shouldnt be lost
so the is better not to delete this table.
The Figure 7-8 illustrates the class diagrams for RowMaterial and
SemiFinished classes.

50

Figure 7-8 RawMaterial and SemiFinished Class diagrams

51

8 MDF ARCHITECTURE
A MES solution developed with Mdf is based on a client-server architecture.
This allow the application to be scaled while assuring higher levels of
dependability. Maintenance operations are simplified as well, since will be
dealing only with single system part.
Main advantages guaranteed from this architecture type are:

It is natively oriented to server application, where a main server


offers services to several clients

It is natively built for distributed environments

Client and server pars can be optimized independently for different


task

Client or server applications can be substituted by other third-part


software if the communication channels and protocols are the same
as the MES solution. (E.g. Each user can chose between different
interfaces or can select the preferred one)

Figure 8-1 MES architecture based on Mdf


The following software components will be running on the server:

SQL Server to permanently store the data

Mdf to access and manage the data

Business rules as tool to model the production needs

Internet Information service to allow the operators access the system


through internet

Reporting service to generate production summaries

All the client machines will access the server functions through a web
browser like internet Explorer.

52
No limitation on the client number is set. In this way each personal computer
connected to the factory network will be able to access the data shared by
the MES solution.
Microsoft .NET technology is used to guarantee simple and faster
maintenance of the system graphical user interfaces. This solution is scalable
on the need and allows to easy code web application to be used in the
factory Intranet or to be exposed on the factory website to allow the data
access also from outside the factory.
Web solutions carry a number of advantages, like:

Simpler access to the application. No deployment activities are


needed to use the MES application. To use the system it is only
needed to have a pc connected to the factory network and a internet
browser.

Simpler maintenance. The computing part and the logics are running
only on the server. An update on the server will be automatically
reflected on all the clients.

Scalability of the solution. The new Microsoft technology allows the


complete scalability and customizability of the MES application.

53

9 ENTITY FRAMEWORK
Entity Framework is a component of ADO.NET which is an integral part of the
.Net Framework. ADO.NET is a collection of classes that expose data access
service for .NET Framework programmers. Its purpose is providing access to
XML, relational and application data.
Entity Framework is an Object-Relational Mapping (ORM) oriented towards
business application that are written to be connected to a relational
database. The scope is to aid programmer to easy integrate database with a
object-oriented application.
Without this tool often programmer have to use two or more languages in
their application, an high-level language for the business logic such as Visual
Basic or C# code (as in Mdf case), than an another lower level language
have to be used to manage the database such as Transact-SQL. In this way a
programmer that wants develop a business program must know more than
one language and how to use them together. In many case, in fact, the low
level language should be used by the high-level one, for example: often
query could be written as string in the high level language. This can be cause
of several errors because the high level compiler dont know nothing about
that query and then it is not able to determinate if there is syntax errors or if
it contain wrong tables or attributes.
This and other problems may be avoided by using Entity Framework for
accessing data.
The Entity Framework enables developers to work with data in the form of
domain-specific objects and properties, without having to think about the
underlying database tables and columns where this data is stored.
The Entity Framework architecture is shown in Figure 9-1.
LINQ to Entities
Object Service
Entity Client Data Providre
Entity Data Model
Mapping

ADO.NET Data Provider

Database

Figure 9-1 Entity Framework architecture

54

9.1

LINQ to Entities

LINQ allows developers to formulate set-based queries in their application


code, without having to use a separate query language.
LINQ is an universal query language that can be used to query every kind of
data source. LINQ to Entities is the LINQ specialization that allow to directly
query the domain model classes. Entity Framework do not force to have
classes mapped exactly as the database tables, so is more evident that
queries are aimed at classes. Task of the underlying structures is to convert
the query expression tree in the database language in according to the
database type.

9.2

Entity Data Model Mapping

This component works on mapping between domain classes and database


tables. Based part of this layer is the mapping file. Entity Framework use an
external XML file for describing how classes have to be mapped on database.
This file is defined Entity Data Model (EDM) and it is composed by three
layers:

Storage Schema Definition (SSDL): describes the database,

Conceptual Schema Definition (CSDL): describes domain classes,

Mapping Schema Definition (MSL): describes mapping between


classes and database.

The first layer contain the database description whit all tables, fields,
relations, primary key and all needed to describe the database structure.
The second layer specifies the domain classes structure: fields, data type,
navigation properties, etc.
The third file contain the mapping information between classes schema and
database tables. This layer is probably the most complex especially when
there is no 1:1 mapping between class and table.
Entity Framework also contain a visual designer added to Visual Studio that
take care of all necessity so programmers have only to visually design
classes. It generates all code needed and the mapping file with EDMX
extension.

9.3

Object Service

This component have a lot of duties in fact it is the most used by developer.
Its first task is to provide access to the ObjectQuery<T> class that is the
starting point to execute any query. Once a query is carried out the Object
Service transform data from table form, from the underlying layers, to class.
Another important Object Service function is to trace the object state in order

55
to remember which of them are been modified, inserted or eliminated so it is
possible to save this changes on database only on user request.

9.4

Entity Client Data Provider

Entity Client Data Provider takes care of directly interaction with database. In
this layer the expression trees obtained by the LINQ to Entities query are
interpreted in order to generate the query directed toward database. It also
manage the connection, command and reader life cycle.

9.5

Some query examples

This chapter will show some query examples in order to clear how Entity
Framework could be used.
The following query extract 20 products order by price.
using (Entities ctx = new Entities()) {
var c = (from cu in ctx.Products
orderby cu.Price
select cu).Take(20); }

Entities is the class name that inherit from ObjectContext, it is generated


automatically from designer. Products is an Entities property that allow to
execute the LINQ query.
Another example could be: first product with price lower than 250.
using (Entities ctx = new Entities()) {
var c = (from cu in ctx.Products
where cu.Price < 250
select cu).First(); }

More interesting is: how LINQ to Entities realize a filtering by an another


class property. Class structure requires that the Orders class has a property
named Order_Details, this property contain all order details. In the same
way, Order_Details class has a property named Order that is the order which
details is related. This property are named navigation property because they
allow navigation between classes.
The following query takes all orders with a specific product where ProductId
is a property of Order_Details class:
using (Entities ctx = new Entities()) {
var c = (from d in ctx.Order_Details
where d.ProductID == 123
select d.Orders); }

The same query in SQL need a join between two tables, in LINQ to Entities
we need only a navigation property.

56

57

10 WORKFLOW FOUNDATION
A workflow is a logical step by step representation of a real process.
It is a very simple method to describe problems, solutions or business rules,
especially for who isnt involved in programming and has only a grossly idea
of the problem. This may be the case of a company that want buy an IT
solution for warehouse management, probably they will describe their
business rules as a workflow.
An example of workflow organization may be an e-commerce site navigation
schema, we may have to follow some step as such: products consulting,
choose, order data inserting, payment and shipping. This steps are simples to
follow by a customer and, also, it is simples to hierarchically programming
them. So Windows Workflow Foundation provide a tool for both developers
and end-users.
A MES solution based on Mdf may use Workflow Foundation (WF) to develop
all business rules that follow a workflow model, and they could be based on
the business rules defined in the Mdf Business Entities project.
WF is been written in .NET language and it is based on an engine able to
manage one or more workflows for long periods. This engine is named
Runtime Engine and manage the workflow life cycle providing several
services that are:

Persistence: some workflows last a few seconds, but others may


require human interaction and last up to a month or be infinite. So
the engine cant work only during the process life and save all data in
memory but it have to save the information about workflow state
and all queued command to execute. WF can make permanent this
data on an SQL Server.

Schedulation: this services allow programmer to chose with how


many thread a workflow is executed.

Tracing: in many case is important to consult the workflow state and


what it did in past. This service store and return this information.

Transaction: every workflow step may depend by others and


together they may compose an atomic operation called transaction.
Each transaction must terminate with success, in that case all
modification performed during the transaction are committed and
made permanent, if an error occurs during transaction it fail and its
possible to roll back the transaction to undo all steps that compose
the transaction.

Exchanging data: a workflow may refer to external data, call


methods or respond to events of custom classes.

58
WF provide two kind of flow: sequential or state machine.

10.1

Sequential Workflow

A sequential workflow is a model based on sequential activity so it can be


represented by a predetermined path. It is composed by an initial and a final
activities and it terminate with the last activity. The Figure 10-1 illustrates an
example of this model.

Figure 10-1 Sequential workflow


In the CodeActivity blokes is inserted code in order to realize what is
provided for the sequential step.
public sealed partial class Workflow : SequentialWorkflowActivity
{
public Workflow()
{
InitializeComponent();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
Mdf.BusinessEntities.Material.MyCustomMaterial.DoSomething();
}
}

59

10.2

State Machine Workflow

This model have not a predetermined path, it is based on a definition of


states. The transactions between states depend on event, they respond to
events and may generate other event depending on the business rules
defined in that state. Figure 10-2 contains an examples of state machine
workflow.

Figure 10-2 State Machine Workflow


Each states contain some CodeActivity blokes that may be executed
depending on the event which active the state. An example is shows in
Figure 10-3.

Figure 10-3 Waiting state event activity

60
Figure 10-3 contain the definition of the run event in the Waiting state.
This event receive input from a web service, then it start a code activity
named runOrder with the following code:
public sealed partial class StateMachine : StateMachineWorkflowActivity
{
public StateMachine()
{
InitializeComponent();
}
private void runOrder_ExecuteCode(object sender, EventArgs e)
{
Mdf.BusinessEntities.Order.InboundOrder.Run();
}
}

Each state may be processed several time before the final state of the
workflow is activated.

61

P ART 2

62

63

11 INSTALL AND CONFIGURE MDF


Once you have download the Mdf setup (see chapter 3) you have only to
start it and follow the instruction to chose the installation folder.
After, you have to chose which component install, by default chose both
console application and Visual Studio 2008 addin.

Figure 11-1 Mdf setup


The next step is install Mdf.Portal. To install it is necessary to have already
installed Internet Information Service so that Mdf.Portal web application can
be accessed from a web browser.
If you have installed IIS just now, remember to register ASP.NET. You can do
it by execute the file: aspnet_regiis.exe (with -i parameter)
It is located in the following path:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

In Windows Start menu chose Programs and then youll find Mdf MES
Development Framework, in this folder there is the Mdf Portal setup file,
execute it. The installer will ask the web location, the default settings are
Site: default Web Site, and Virtual directory: Mdf.Portal.

11.1

Mdf and MSDTC

Mdf use MSDTC (Microsoft Distributed Transaction Coordinator) as


transaction manager. It permits client applications to include several different
sources of data in one transaction. So a distributed transaction is simple a
transactions which spans between two or more machines.

64
If not well configured MSDTC may cause some problems, in that case see the
following tips:
First verify the "Distribute Transaction Coordinator" Service is running on
both database server computer and client computers:
1. Go to "Administrative Tools > Services"
2. Turn on the "Distribute Transaction Coordinator" Service if it is not
running
If it is running and client application is not on the same computer as the
database server, on the computer running database server:
1. Go to "Administrative Tools > Component Services"
2. On the left navigation tree, go to "Component Services > Computers
> My Computer" (you may need to double click and wait as some
nodes need time to expand)
3. Right click on "My Computer", select "Properties"

4. Select "MSDTC" tab


5. Click "Security Configuration"

65

6. Make sure you check "Network DTC Access", "Allow Remote Client",
"Allow Inbound/Outbound", "Enable TIP" (Some option may not be
necessary, have a try to get your configuration)

7. The service will restart


8. If it still doesnt work you may need to reboot your server

66
On your client computer use the same above procedure to open the "Security
Configuration" setting, make sure you check "Network DTC Access", "Allow
Inbound/Outbound" option, restart service and computer if necessary.
On you SQL server service manager, click "Service" dropdown, select
"Distribute Transaction Coordinator", it should be also running on your server
computer.

11.2

Mdf configuration

Now you can create a Mdf database using the console application. You have
to specify the information shown in Figure 11-2.

Figure 11-2 Database creation form


This information compose the connection string that allow the application to
access this database.
Most of the Mdf configuration may be set using the Mdf Portal web
application.
You can access to Mdf Portal by writing the following address:
http://localhost/Mdf.Pottal in your web browser address bar. Obviously this
address is correct only if you have chose the default web location when you
install Mdf Portal (see above) and if you are accessing from the machine on
which Mdf is installed else you have to access to web location you have
chose: http://Your_Mdf_server/Your_web_location_for_Mdf_Portal.
To set some Mdf configurations you must access to Mdf Portal and click on
the configuration link at the top right of the page (see Figure 11-3). A
configuration page will be open.

11.3

Mdf Portal database connection

Mdf Portal works on a particular Mdf database so you have to impost a


connection string. To do this, access to Mdf Portal configuration page where

67
you may insert the connection string data, the same that you define creating
an Mdf database.
Once the connection data are written in the fields click on the Set
connection string link, in this way start a connection test to the database
that determinate if there are any mistake. If there are no errors the
connection string is saved.
This connection tool works only if the ASN.NET user or the NETWORK Service
user, depending on your operative system, must be allowed to access to the
Web.config configuration file (you can find it at this path:
C:\Inetpub\wwwroot\Mdf.Portal, if you have chose the default web location).
The Figure 11-3 illustrates the Mdf Portal configuration page, the
configuration link on top right is highlighted with a red circle.

Figure 11-3 Mdf Portal configuration page


Now you may simple use your web browser to create all models that your
MES application needs.
An alternative procedure may be: open the Web.config file with a text editor.
This is an XML file so you will see a configuration tag that contain a
connectionString tag in which you have to put the database data.
The following example highlight the database data to insert:
<connectionStrings>
<add name="MdfConnectionString"
connectionString="
Data Source=LOCALHOST\SQLEXPRESS;
Initial Catalog=MyMdfDatabase;
User Id=UserName;
Password=password;
MultipleActiveResultSets=true"
providerName="System.Data.SqlClient" />
</connectionStrings>

11.4

Constants and parameters

In the configuration page you may also define some constants and
parameters that could be useful for your MES solution. For both of them you

68
have to chose a constant/parameter name, a description, the data type, the
unit of measure and a value.

11.5

Sequences

Mdf provide you with a very useful tool that manage sequential strings. This
strings may be functional in any case you need to set a primary key for a
table. For example you may develop a MES solution which contain a section
dedicated to raw materials. In this section a user can insert a new raw
material, this means that he need to set a new material ID. The best way to
maintain the data integrity is do not allow the users to chose the ID but set
automatically a new ID on every add operation. In this context a sequential
string generator can be very helpful.
You can set a new sequences in the configuration page at the sequences
section. A Sequence is characterize by a name (that is also the ID of your
sequence), and a description than you have set a minimum value, a
maximum value, a sequence prefix and suffix and a current value. In this
way you may create a sequence that generates a string like that:
RawM.010567.Extra or more complicate because you can use more than one
sequence to construct an ID.
You can also define a sequence directly in your program using few command.
When you need to set an new ID you have only to create a sequence if it
does not already exist and get the next value available in it.
if (!Mdf.Common.Sequence.Exists("SemiFinished"))
{
Mdf.Common.Sequence.Add(
"SemiFinished",
"Semi finished sequence",
20000,
20000,
99999,
"SF.",
"",
DateTime.Now,
"system");
}
string semiFinishedID = Mdf.Common.Sequence.
GetNextValue("SemiFinished");

69

12 MODEL MES APPLICATION


In this chapter we start creating a new MES application with Mdf library. As
previously said Mdf aid to create MES solutions in respect of the ISA 95
standard, just for this, we have to follow the ISA 95 modelling procedure that
consists of two phases: definition of the resource models than introduction of
the relationships between.

12.1

Mdf models

The ISA 95 resource models are often not enough for describe all business
elements of a real enterprise. For this reason Mdf introduce three more
models: Handling Unit, Order and Project Entities.

12.1.1 Handling Unit model


The handling unit model is an Mdf integration at the ISA 95 material model.
The material standard model do not treat about material handling, in
particular it is not possible specify the various handling unit types which an
industry daily use such as pallet type. This model allow you to define both
the handling unit types and the properties needed. We define it separately
but it is a part of the Mdf material model, in fact the Custom Class Generator
maps them tables in the same Entity Framework model and it creates on
database a table named cusomMaterial_HandlingUnitIDs. Material sublot
contain, among standard properties, an HandlingUnitID field, this property
allow you to create for example a pallet whit several material sublots. The
Figure 12-1 illustrates the Mdf material model composed by the ISA 95
standard model and the Hendling Unit model.

Figure 12-1 Mdf Material Model

70

12.1.2 Order model


The Order model regard all orders that not are production orders, because
this ones are modelled in the Production Schedule model. Examples of orders
contained in this model may be: in bound orders or shipping orders. The
Figure 12-2 illustrates the order model with relate property.

Figure 12-2 Order model

Order Class is used to describe a grouping of orders with similar


characteristics for purposes of scheduling and planning. Any order
may be a member of zero or more order classes. It is possible to
define some class property. An order class may be In Bound Order or
Shipping Order

An Order represents a single order that may contain some properties


which may map to Order Class Properties. An order may contain zero
or more order items.

An Order Item is an object (usually a resource)to which the order is


related.

12.1.3 Project Entities model


The Project Entities model is a general purpose model. There are many
resource entity which are associated to a MES solution that are not already
considerate from the ISA 95 models, orders are one of this and Mdf dispose a
dedicated model to it, but there are more example such as: you could want
to collect all supplier (they are not either equipments or materials, and are
not exactly a personnel); or all your customers; or you could collect all
machinery downtime causal. Even if you would manage this entities without
any models this is not the easy and correct way to proceed, especially if you
have the Mdf Custom Class Generator available. With a click on CCG the new
class which you have defined is automatically added at the Entity Framework

71
model, the requested tables are added to database and it provide you with a
class file with a batch of general methods. In this way you can make more
order in both database and business entities project.
The Project Entities model is far more easy than the others model in this
book because it is composed only by a Project Entity Class table and its relate
property, as shown in Figure 12-3.

Figure 12-3 Project Entities model

12.2

Resource models definition

In this chapter it is shown how to define the resource models by using Mdf
Portal. A right resource models definition is one of the most important step to
develop a MES application using Mdf. Mdf is based on the resource models
from which it constructs the database custom tables and the Business
Entities Visual Studio project using the Custom Class Generator.
To which end you may suppose to develop a MES application to manage a
productive process for flexible packaging composed by several process
segments such as: extrusion, assembly, film printing, coupling, cutting, and
welding processes.
The basic elements needed to describe a productive process are primarily the
equipments which are involved in it, so you have to define firstly the
equipment classes. After you have to define the material used in these
process segment, and then the other resource models: handling unit types,
personnel, order and all project entities that your productive process need.
To do this you have to access to Mdf Portal and enter in the resource section,
than on the tab menu you may chose between all resource model defined in
Mdf. The first is the equipment model. If you select it you may chose to work
with three tables: equipment, equipment class, and equipment class
properties. Selecting the second option you can manage the equipment
classes. This procedure is the same for all resource models.
Generally in this page is listed all defined class (an example is shown in
Figure 12-5). You can manage a class clicking on it, in this way it will be
open a detail page that contain all information about the class with a list of
all properties added to it (see the Figure 12-4).

72

Figure 12-4 Class detail page


In this page is possible to modify the class data (expect for the class ID), add
or delete properties and delete the whole class.
Only for the equipment class management page, at your first access you can
see that some equipment class are already added, these equipment classes
are the standard classes defined in the equipment hierarchy model about
which we discussed in chapter 5.1 plus two storage classes: StorageUnit and
StorageZone not included n the original model.

Figure 12-5 Equipment class management page


This standard property are not changeable or erasable, in fact they are not
clickable. In this way you cannot add properties to them. If that were the
case, for example you want to add a property to the Site class such as

73
location, you have to create a new custom class, for example MySite, in
which you can add your property.

12.2.1 How to add a new class


In this paragraph describe how to add a new class. In order to be more
understandable we continue with the equipment example but this procedure
is quite the same for the other classes.
With the hyperlink at the bottom of the page (Add new equipment class) you
can add a new equipment class. To define a new class you must chose class
ID, description, and hierarchy level (only for equipment class).
Because classes became element of the Business Entities project using the
Custom Class Generator (see chapter 7.1), the class ID name have to follow
some rules: the class ID must not contain spaces, it have to begin with
capital letter, and it must not contain special characters.
In this example you might insert the following new classes with
ProductionLine as level of the hierarchy model: Extruder, AssemblyWorkCell,
Printer, CouplingMachine, Cutter, WeldingMachine.

Figure 12-6 Add-new-class page


These classes are needed to compose the flexible packaging production
process and more than equipments each of they represent also a process
segment.
If you focalize on printing process segment you may notice that you need
more than a printer class to define it. In particular you need at least an
InkRoller class, and a Cliche class.

12.2.2 How to add a new class property


In this paragraph is described how to add a new class property, in order to
be more understandable we continue with the equipment example but this
procedure is quite the same for the other classes except for the order
properties which are examined in the subparagraph .
If you want create new properties you have to follow a procedure quite
similar to previous ones to add a new equipment class. From the equipment
page chose by the tab menu, click on the equipment class properties link.
This page will contain all equipment property you will define by clicking on
the Add new equipment property hyperlink. To define a new property the

74
field required are: property Id, description, unit of measures, data type, and
the data size in bit (you must set it only if you chose string as data type, else
it is auto fit to standard dimension).
In this example, you may insert: diameter, length, serial number, note, etc.

Figure 12-7 Add-new- class-property page

12.2.2.1

How to add a new order class property

In the order model beside the orders there is the order items (see paragraph
12.1.2) so when you define a property you have to define if it is an order or
an order item property. This decision can be taken setting two check boxes
as shown in Figure 12-8

Figure 12-8 Add-new-order-class-property page

12.2.3 How to add class properties to a class


In this paragraph is describe how to add a class property to a class, in order
to be more understandable we continue with the equipment example but this
procedure is quite the same for the other classes except for the material
properties which are examined in the subparagraph .
Once you have create your classes and class properties, you can add
properties at each class. This can be done by clicking on that class which you
want to add a property in equipment class page (Figure 12-5). Then you may
click on the Add-property hyperlink and then you can chose between all
property you have already define shown in a pop up panel. The property is
added just clicking on it.

75

Figure 12-9 Add a property in a class

12.2.3.1
How to add class properties to a material
class
The material model is composed by a material class table and three other
tables: material definition, lot, and sublot. In this case, when you add a
property to a material class you must specify which tables inherits this
property. This decision can be taken setting three check boxes at the base of
the pup up panel that came out when you click the Add property hyperlink in
a material class detail page (see the Figure 12-10). The check boxes have to
be set before clicking in the property you want add.

Figure 12-10 Add a property in a material class

76

12.3

How to create an instances of custom class

You may use Mdf Portal also to instantiate a custom class. This function may
be useful if you need to populate the database in order to test your MES
application or because you want insert some standard object such as an
enterprise equipment, that in your application probably you define only one
time.
The object that you can insert are equipment, material definition, lot and
sublot, person, order and order item (about the order class see the
paragraph 12.1.2).
To add a new object you must select the model which you are interested,
than in the default page that will be open you must chose one of the links
that we listed in the paragraph above. For example if you chose the
equipment model from the tab menu, in the resource section, you may chose
among three links: equipment, equipment class and equipment class
property. The first link show you a list of all equipment that are already
inserted and with the add-new-equipment link you can access to a detail
page (similar to the detail-class page) in which you can add a new equipment
specifying to which class it belong, beside an ID and a description (and, only
in the equipment case, an equipment parent ID too, to specify an hierarchical
relation between the equipment in according with the hierarchy model). In
this modality you cannot insert the value for each property that you have add
to the class to instantiate, and they are fixed to a null value. To specify
another value you must access to your element in update modality. For this
purpose you must click on a element already inserted then you access to its
detail page in update modality.
In Figure 12-11 you can see the equipment detail page after a modify
operation in which the property fields are been inserted.

Figure 12-11 Equipment detail page

77

12.4

Process Segment Definition

After you have defined all resource classes need to describe your production
process, you must define the relation between this resources. This
relationships are represented as process segments.
Whit a process segment you identify all resource involved in a particular part
of the production process (see paragraph 5.5). In the flexible packaging
example we have already say that is possible identify several process
segments such as: Extruding, Assembling, Printing, Coupling, Cutting and
Welding.
The process segment management page can be found in the Combined
resource page clicking on the first tab of the tabs menu.

Figure 12-12 Process Segment management page


In this page you can manage the process segment that are already defined,
clicking on one of them a detail page will be open in which you can view,
modify or delete the whole process segment or add, modify or delete a single
element of the process segment.
It is possible to import process segment that are already defined in respect of
the B2MML standard clicking on the e hyperlink at the bottom of this page
and specifying the file name and its path.
With the Add new process segment link the detail page is open in inserting
mode so you can fill all fields needed to define a new process segment. This
page is shown in Figure 12-13 where in the fields are inserted the printing
process segment data.
The data that you may insert in this page are, as usually, a process segment
ID (required) and a description, than is possible to insert a location, that
indicates the site or the area in which this process segment is executed. You
may also specify the equipment element level of this process segment that is
the hierarchy level at which the process segment is related. With the duration

78
fields it is possible to define the number of years, months, days, hours,
minutes, and seconds of the process use time. The published data is the data
on which the process segment was generate. The parent process segment
allow you to create the process segment in hierarchy way. Extended and Any
are two Xml fields that allow you to insert some other information not
contained among the standard fields but that you retain important, for
example you may insert a Note field.

Figure 12-13 Add-new-process-segment page


Each process segment need some resources to be executed, this resources
have to be specified each one in they own resource segment specification
table. The material segment specification, in addition, have to contain both
the produced, consumed, and consumable material differentiating by the
material use field. The process segment may also contain some property that
can be used also for parameterize the process segment with an appropriated
business rule. it is also possible to defining dependency relations between
this and other process segment.

Figure 12-14 Process segment detail page

79
The Printing process segment for example need at least a printer, an ink
roller and a clich as equipments, the raw film and the colours as materials,
and an operator as personnel. You may also suppose to establish that the
cutting process must be executed only after the printing process, in that case
you must define a dependency.
The Figure 12-14 shown the detail page of the printing process segment, in
the selected tab at the bottom of the page you can see that a process
segment dependency is been defined for this process segment.
In each tabs is possible to insert one or more elements. Clicking on the Add
new... link each time an adding page will require to insert the data for the
new element in according with the fields specified in the ISA 95 part 2 and
with the B2MMl standard.
Clicking on an element that is already inserted you will see a detail page in
which you can modify or delete this element or add a property to it related
specifically to this process segment.

Figure 12-15 Material segment specification element detail page


For the equipment, material, and personnel segment specification is possible
to specify either a class (such as RawFilm) or an element of a class (such as
RawFilm001), in this way your process segment may require a generic class
without specify a particular element or require a particular element.
In Figure 12-15 is specify only the material class RawFilm because the
printing process need a film on which print, but at this time the kind of film is
not important and it will be chose at schedule time. Otherwise it is possible to
imagine a beverage production process that surely need water to be execute,
in this case among the other material segment specification it is added
directly water as material definition.

80

13 CUSTOM PRODUCTION RULE


The previous chapter explain how to define the resource models using Mdf
Portal, these models are the skeleton of each MES solution implemented with
Mdf. This is the reason that permit the development and the utilization of a
tool as the Custom Class Generator. The CCG basically maps the resource
models on the Business Entities project providing a set of standard methods
and create the storage layer below.
Starting by this is now possible to define the other high level models that
compose any MES solution. From this point the problems can be solved in
several way, especially because each plant define different business rules, so
in this chapter and in the following we propose some solutions that can
explain how something may be done in respect of the ISA 95 standard, but
there is no intent to suggest a unique way to solve all problems.
From now on we will use Mdf Portal only as a diagnostic tool that allow you
to navigate through all database tables and if necessary to add modify or
delete records. We do not use it to create an entire production rule or a
production schedule because our intent in not to fill a database but create a
MES solution. This mean to create all needed tool and graphic interfaces that
an operator of your application have to use. In the following we may use Mdf
Portal as example but not as end user interface.
A MES solution is developed for industries which usually produce some
goods, a production rule is a collection of information that describe how
those goods must be done.
Locking at the Production Definition Information model (see paragraph 5.8),
you can notify how these information are collected. To describe a new
product you have firstly define a production rule that has associated with it
one or more product segment (that correspond to a process segment) and
each one require several resource. You probably guess that for a single
product you need modify several tables then can be necessary to write some
code to do this.

13.1

Define material classes for products

If you try to define a new production rule using Mdf Portal in the Production
Process Product section you can notify that the first field required is a
Product ID that you have to chose among the material definition elements.
This happen because a production rule have to describe how a finished or
semi-finished material is made.
In a MES solution the better way is probably impose that when an user want
add a new product (produced in his plant) he has to specify also how this
product is made without a separate page for production rule. In this way the

81
user does not know that there is a dedicated model for the production rules,
he only view a page that require additional information in comparison to a
consumed material such as a raw material.
To make possible this distinction between product and the other materials
you need to create one or more separate material classes for your product,
for example you may define a SemiFinished material class or a FinishGood
material class that will have a different behaviour compare to the other
material classes such as a RawMaterial class.
In the following we will develop a SemiFinished material class as example to
explain the production rule model.

13.2

How to create a custom production rule

Now that you have create a SemiFinished class, when you start the CCG you
obtain a SemiFinished table and a class with some methods that allow you to
access to the data on this table. For example you can use the add, modify,
delete and get methods. This ones are not enough for define a production
rule associated to this product, as already seen you have to manage several
tables and not just the SemiFinished one. So you have only one part of the
structure that you need to create to manage the product definition.
The other part is however provide from the Mdf library. It is the
ProductDefinitionInformation class library that provide you with all standard
method to manage the product definition model whose tables are already
been created when you have defined a new Mdf database.
Now you have all tables, classes, and methods needed to manage separately
the product definition information model and your semifinished custom class.
The next step is the creation of an unique class that have to manage the two
models together.
In our example we define the SemiFinishedProductioRule class.

Figure 13-1 Mdf Business Entities Project

82
In order to better understand how this class manage the two others we may
take a look at the at its definition. This section is composed of two steps,
firstly you have to declare two private variables as SemiFinished class and
ProductProductionRule class, then you initialize them with data loads from
the two classes where the ID are specify as parameters of the new class.
public partial class SemiFinishedProductionRule
{
protected SemiFinished SemiFinished = null;
protected Mdf.ProductDefinitionInformation.ProductProductionRule
ProductProductionRule = null;
public SemiFinishedProductionRule(string semiFinishedID,
string version)
{
SemiFinished = SemiFinished.Load(semiFinishedID);
ProductProductionRule = ProductDefinitionInformation.
ProductProductionRule.Load(semiFinishedID, version);
}
}

In this way, when an object of this class is instanced specifying a


semiFinishedID and a version, it will contain one pointer for each model
class. This allow you to define a unique method starting from that which are
already defined for each class. In the following is shown how may be
developed the add, modify and delete methods.

13.2.1 How to define an add production rule method


We establish that the production rule data are require when the user try to
add a new semi-finished material. Then the user interface may require some
information which are not all relative at the material definition but a part of
them define the production rule. For example the ID required in this page
may be identification for both semi-finished and production rule. Instead the
version, that with the ID compose the primary key for the production rule, is
not a material definition field. So the add method that have to be invoked is
composed from several part
Firstly you have to consider that it is true that this method only invoke some
other procedure and function defined in other classes, but this ones will
modify the storage layer. In order to save the data integrity youd better use
the transaction scope tool, in this way either all modify have to came out well
in a unique transaction or they are all aborted.
Moreover in order to execute your database modify you need to create the
context. The context is an object of the Entity Framework class that allow
you to access the database. Once the context is created you can invoke the
methods you need and pass them this context.
In this case you need to access at two different entity models: the custom
material entities and the product definition information entities, these are the
class that provide you with the database access at the two models which we

83
are interested. For the first model we dont create explicitly the context
because it is automatically create from the add semifinished method. At the
second model, instead we need to access with more than one method, then
it is better create the context only one time and pass it to each of them.
In the transaction scope section you can now invoke all needed add methods
in particular, for this example, an add semi-finished for the custom material
model and for the product definition information model an add production
rule and an add product segment.
The product segment that you have now created have to correspond to a
process segment so if you set as product segment the printing process
segment you have to maps all resource segment specification tables and
parameters of this process segment in the new product segment
specifications tables. For this purpose Mdf provide you with specific product
segment methods named CopyFrom... that allow you to copy only a
particular table from the process segment, such as the equipment segment
specification table, or all tables of the process segment selected.
We chose to write this add as function that return a SemiFinished object.
public static SemiFinished Add(string semiFinishedID,
string description, string version)
{
SemiFinished semiFinished = null;
ProductDefinitionInformationEntities
productDefinitionInformationEntities =
ProductDefinitionInformationEntities.
CreateProductDefinitionInformationEntities();
using (TransactionScope transactionScope = new TransactionScope())
{
semiFinished = SemiFinished.Add(semiFinishedID, description);
ProductProductionRule.Add(productDefinitionInformationEntities,
semiFinishedID, version, description, null, DateTime.Now,
"<Extended />", "<Any />");
ProductSegment productSegment = ProductSegment.Add(
productDefinitionInformationEntities,
"Printing", semiFinishedID, version, description, null,
"Printing", null, null, null, null, null);
// productSegment.CopyFromEquipmentSegmentSpecification();
// productSegment.CopyFromMaterialSegmentSpecification();
// productSegment.CopyFromPersonnelSegmentSpecification();
// productSegment.CopyFromProcessSegmentParameter();
productSegment.CopyFromProcessSegment();
transactionScope.Complete();
}
return semiFinished;
}

84

13.2.2 How to define a modify production rule method


This method is quite similar to the add one so we not propose a code
example. In a transaction scope two modify methods are called, one for the
semi-finished and one for the production rule.

13.2.3 How to define a delete production rule method


The delete method is the easer one. It only require the semi-finished ID and
the production rule version and it start two delete method in a transaction
scope
public static void Delete(string semiFinishedID, string version)
{
using (TransactionScope transactionScope = new TransactionScope())
{
Mdf.ProductDefinitionInformation.ProductProductionRule.
Delete(semiFinishedID, version);
Mdf.BusinessEntities.Material.SemiFinished.
Delete(semiFinishedID);
transactionScope.Complete();
}
}

13.3

Production Rule presentation layer

The presentation layer for a production rule may be made, for example, as a
web application. Anyway the user should consider the products as materials.
So he should found, among the other material classes, a page that list all
product of a same class, such as semi-finished. By clicking on one of them he
should be found a detail page composed by an header part which contain all
generic information and a second part that contain all information about
product segment, resource specifications, and parameters.

13.4

Conclusions

In this chapter we explain how to manage a custom production rule. we


summarize the procedure in few steps:

Create a custom material as product to which the production rule


must be related

Create a custom class that manage the new custom material and the
product production rule models

Create all methods in order to manage the data in the two models

Create a presentation layer that show to user an unique page


without distinction between custom material and production rule.

85

14 CUSTOM PRODUCTION SCHEDULE


This chapter explain how create and manage a custom production schedule.
Even if the production schedule model is one of the most complex of the ISA
95 models, Mdf provide a set of standard methods in order to simplify its
management.
The purpose of this methods is allow you to develop a presentation layer for
the schedule management that construct a production orders list only asking
for a product and for a quantity for each production order. However in the
tables below have to be inserted the right data. For this purpose there are
two problems to solve:

The production schedule model, as well as the product definition


information model, is composed by several tables that map similar
tables in other models. To manage this model you should write some
code that copy all information from those tables to yours starting
from the product ID to schedule.
Mdf directly provide you with some CopyFrom... methods that allow
you to easy import all data already define in other tables.

The production rules fix the quantity of all needed resources in


according to a standard quantity. For example it is possible to define
a production rule for 1000 litres of a beverage. In this case the
quantity of raw and semi-finished materials, equipments and
personnel involved in this product production are report to 1000
litres. When in the production schedule management page the user
set a quantity different from the standard value you need to execute
a scalar operation that set right the quantities for all resources.
Mdf directly provide you with some methods ad hoc for this purpose.

The management of this model require more attention compared to the


previous models because in the other models we have only describe how a
plant is composed and how it produce its products. This model, instead,
contain information regarding the real production that have to be done. In
particular you have to pay attention to relationship between the various
production schedule (or production request in a production schedule) that
are mutually dependent. If you add, modify or delete a production order you
have to worry about the consequences on others production orders (or
production request related to the same production order).
The production schedule may be managed in several ways. By ISA 95
standard a production schedule may contain 1 or more production request
such as for a product production that require another semi-finished product
to be terminate. Depending on the case you may also chose to fix that a

86
production schedule contain only one production request. For example each
production schedule is related to a product that may be independent from
the others or not, so you could have stand-alone product segment or
dependent on each other.
The following paragraphs illustrate an example of a beverage production
process in which we want produce 1000 bottles of 0.75 litres each of a liquor
produced in the same plant. We suppose that we have a production rule
available for the 0.75 l bottle that, among the others material consumed
requirement, contains a semi-finished material (which represent the liquor to
bottle in) with quantity 0.75 litres. In this case, to complete the bottle
production, we need before to complete another production schedule of 750
litres of the liquor required.
As we have often clarify, there are several way to manage this production
schedule, we chose to assign to each process segment only one production
request. The methods to develop are construct in respect of this chose.

14.1

How to realize an add new production schedule

In this paragraph is shown how an add method could be construct in order to


describe how add a new production schedule that depend on another one,
and how to solve the quantity fields alignment problems.
If you have to add a new production schedule your add method have to
consider all other tables needed to make your production schedule complete.
It is possible imagine a complex problem split in two parts:

The first part takes care of the adding of the tables related to the
production schedule model concerning your product. In our example
these tables are related to the production scheduling of 1000 bottles
of 0.75 litres each

The second part deal with all other production schedule needed to
complete the first production order. In our example we have to
produce 750 litres of a particular liquor that will fill the bottles (semifinished product).

To solve these problems it possible to use two (or more if necessary) classes.
One of them contain methods that manage the adding of the finished
product and all semi-finished products needed (in our example
FinishedProductioSchedule). The second class contain all methods needed to
manage the production schedule of a semi-finished product (that is not
require by a finished product) and have to contain also some methods that
can be used from the first class (in our example we call it
SemiFinishedProductioSchedule). Others classes may defined in order to
contain some others methods needed to solve the problem.

87
Then the solution is to realize a class to manage the finished product and if
necessary takes care to call methods of an another class.
Since this method have to update the storage layer we use a transaction
scope to be sure that the modifies are all correct and only in this case they
are commit all together.
If you see the code written below, in the first part you will find that we have
used the B2MML class. We do that because we need to define a location
object that is an XML element and have to be construct in respect of the
B2MML standard. This means than in an appropriate XML structure we have
to insert the equipment that we use as location and the equipment element
level.
Now we have all needed data to add a new production schedule for a
finished product. Mdf provide us with two add methods, one of these is for
the production schedule table in with we have to insert this information:

Production schedule ID

Description

Location as XML

Published, scheduled and ending dates

Equipment element level which this schedule is related

Schedule state that can assume the value: running, waiting, closed
and aborted.

Extended and Any XML fields.

The second method realize the production request add. The parameters
require are:

Production request ID

Parent production schedule ID

Production rule ID and its version

Description

Location as XML

Scheduled and ending dates

Priority level (that can be chose among the records of an apposite


table named ProductionPriority)

Production request state that can assume the value: running,


waiting, closed and aborted.

Extended and Any XML fields

88

Material quantity to produce. This quantity is require in this add


method but its value is inserted in the MaterialProducedRequirement
table, in the quantity fields of the entry with the same ID of the
product (in our case the finished or semi-finished material).

This second methods solve automatically the alignment problem. All


information about this production rule are copied in the appropriated
production schedule tables (for example this method copy all product
segments of this production rule in the segment requirement tables). The
resource quantities are set in respect of the quantity of product to produce.
Generically with one production rule its possible to produce more than one
material but one production rule is referred only at one product. The product
to produce is specify as material produced among the other material in the
material specification table, it may be inserted in more than one product
segment of a production rule.
To better understand how the alignment procedure work suppose to have a
production rule (for example a production rule that specify how to produce
10 liquor bottles of 0.75 litres each) with 3 product segments. Two of them
have, among the other material specification, the product to produce as
produced material (for example they could be used to produce the same
product in two different way, suppose that they produce 5 bottles each), and
the other segment is used to produce 7.5 litres of liquor needed to fill the 10
bottles.
When you want create a production request for this production rule you have
to use this second add method with Mdf provide you. This add method
require a product quantity as parameter (in our case you can chose to
produce 1000 bottles). The alignment procedure is composed by some steps:

Firstly the procedure have to know how many products are produced
using a particular production rule as production request. In our
example we specify the production rule to produce 10 bottles, 5 for
each segment.

Now that the number of product produced with a particular


production rule is known, the method can calculate the scale factor
that is used for the alignment procedure. In our case the production
rule is proportioned to produce 10 bottles of liquor and in the
production request we have chose to produce 1000 bottles, so the
scale factor is 100.

This number is used to scale all resources involved in the production


request, for example the third segment requirement of our example
now contain 750 litres of liquor to produce.

With only two methods it possible to create a production schedule complete


and with the right quantity value for each fields.

89
Our example continue supposing that now we have to create another number
of production schedules to produce a semi-finished product.
With some simple code lines its possible to get the semi-finished ID, the
quantity to produce, and the production rule version to use. Than we
suppose that the equipment used for this process segment have a maximum
value over which another production schedule have to be defined. So in a
loop we determine the quantity of product to produce and invoke the two
add methods described above.
Some of the command used in the example below are define on other class
but is not useful to show their definition.
private static void add(string productionScheduleID, string finishedID,
string productVersion, decimal finishedQuantity,
DateTime scheduledDate, string priorityID)
{
using (TransactionScope transactionScope = new TransactionScope())
{
// Load finished production rule
FinishedProductionRule finishedProductionRule =
new FinishedProductionRule(finishedID, productVersion);
// Set locations
B2MML.Common.Location productionLocation = new Mdf.B2MML.
Common.Location(
"MyEnterprice.MyProductionSite.MyProductionArea","Area");
B2MML.Common.Location preparationLocation = new Mdf.B2MML.
Common.Location(
"MyEnterprice.MyProductionSite.MyPreparationArea","Area");
// Add production schedule and production request
Mdf.ProductionSchedule.ProductionSchedule.Add(
productionScheduleID, finishedProductionRule.Description,
productionLocation.ToString(), DateTime.Now,scheduledDate,
null, "Area", "Waiting", null, null);
Mdf.ProductionSchedule.ProductionRequest.Add(
productionScheduleID,productionScheduleID, finishedID,
productVersion, finishedProductionRule.Description,
productionLocation.ToString(), scheduledDate, null,
priorityID, "Waiting", null, null, finishedQuantity);
// Get semi finished ID
string semiFinishedID = finishedProductionRule.SemiFinishedID;
// Get semi finished quantity
decimal semiFinishedQuantity = finishedQuantity *
finishedProductionRule.SemiFinishedQuantity;
// Define and set local variables
string semiFinishedVersion = SemiFinishedProductionRule.
GetActiveVersion(semiFinishedID);
SemiFinishedProductionRule semiFinishedProductionRule =
new SemiFinishedProductionRule(semiFinishedID,
semiFinishedVersion);
// Loop on semiFinishedQuantity

90
while (semiFinishedQuantity > 0)
{
// Get production schedule ID
string semiFinishedProductionScheduleID = Mdf.Common.
Sequence.GetNextValue("ProductionSchedule");
// Set semi finished production request quantity
decimal quantity = 0;
if (semiFinishedQuantity < PcmsMixerTank.MixerSize)
{
quantity = semiFinishedQuantity;
}
else
{
quantity = PcmsMixerTank.MixerSize;
}
// Add production schedule and request
Mdf.ProductionSchedule.ProductionSchedule.Add(
semiFinishedProductionScheduleID,
semiFinishedProductionRule.Description,
preparationLocation.ToString(), DateTime.Now,
scheduledDate, null, "Area", "Waiting", null, null);
Mdf.ProductionSchedule.ProductionRequest.Add(
semiFinishedProductionScheduleID,
semiFinishedProductionScheduleID, semiFinishedID,
semiFinishedVersion, semiFinishedProductionRule.
Description, preparationLocation.ToString(),
scheduledDate, null, priorityID, "Waiting", null, null,
quantity);
// Update semi finished quantity
semiFinishedQuantity -= quantity;
}
transactionScope.Complete();
}
}

14.2

How to realize a delete method

In our particular case the delete method have to consider that when you
erase a production schedule you have also delete the other production
schedule that is referred to it.
In our example we have created a list which contain all production requests
linked to the parent production schedule that we want to cancel. With a loop
on this list we delete all its elements. Then we can delete also the parent
production schedule.
The delete methods that we have used are provide by the Mdf library for the
production schedule class that maps the production schedule model.
All this methods that change the storage layer are invoked in a transaction
scope that make sure that all database updates have a successful conclusion,
if this is not happened al database modifies are roll back.

91
public static void Delete(string productionScheduleID)
{
using (TransactionScope transactionScope = new TransactionScope())
{
// Get all preparation production request that
// are invelved in current production request
List<ProductionRequest> productionRequests =
SemiFinishedProductionSchedule.
GetLinkedPreparationRequests(productionScheduleID);
foreach (ProductionRequest productionRequest
in productionRequests)
{
Mdf.ProductionSchedule.ProductionSchedule.
Delete(productionRequest.ProductionScheduleID);
}
Mdf.ProductionSchedule.ProductionSchedule.
Delete(productionScheduleID);
transactionScope.Complete();
}
}

14.3

How to realize a modify method

There are several way to develop this method, for example you can realize it
similar to the add method. For the sake of simplicity we have construct it
assembling a delete and an add methods.
This is a very simple method, firstly is call a delete method with the
production schedule ID to modify, then an add method is invoked with the
same ID that we have deleted and the new parameters that we want to
modify.
public static void Modify(string productionScheduleID,
string finishedID, string version, decimal quantity,
DateTime scheduledDate, string priorityID)
{
using (TransactionScope transactionScope = new TransactionScope())
{
Delete(productionScheduleID);
add(productionScheduleID, finishedID, version, quantity,
scheduledDate, priorityID);
transactionScope.Complete();
}
}

92

15 COLLECT PRODUCTION DATA


The production data collection is one of the most important pieces that
compose a MES solution. For this reason there are more than one model
involved in this purpose.
The models that Mdf may use to collect the data are:

Production performance. It is used for provide responses to the


production schedule requests.

Production capability. It is used to collect the production


capability information for a specific time (current or future). Each
resource capability may be defined as committed, available or
unattainable.

Production capability utilization. It is a collection of the historical


information about the utilization of resources for a specific time (past
or current). Each resource capability utilization may be defined as
utilized or unused or maximum available.

15.1

Production performance

The production performance model with the production schedule model form
the production information. Using the production scheduling model its
possible to organize the production orders that may be interpreted as
requests for production. The production performance model allow to respond
to this requests.
When a production order has been scheduled all resources required are been
specified, but at that moment it is not required to specify which particular
material lot or equipment have to be used in production. For example, if you
want produce bottles of liquor you have to specify in your production
schedule, among the others material consumed requirement, a particular
bottle type but you not specify which lot of bottle you have to use. This in
fact is one of the information that are specify in the production performance
model.
For this reason at one production schedule corresponds one production
performance as well as to each production request correspond a production
response and to each segment requirement corresponds a segment
response.
A production schedule, and so also the production performance, may be
detailed for a particular time slice or for a particular production campaign, or
for others logical groupings. For the sake of simplicity in our example we
have linked one production schedule with only one production request, so the
same is being done for the production performance.

93
A production performance may collect data with several logical organizations
in dependency of your business rules. For example it possible to decide that
a production response have to be created when a production order, that is
scheduled by a particular production request, start. At the same moment a
business rule may require to specify which particular equipments (for
example a mixer) have to be used for this product production.
A code example of a method that implement this case is shown below in the
paragraph 15.4.
If you compare the production schedule model with the production
performance model you can calculate the order execution efficiency for
example comparing the end time scheduled with the effective end time, or if
the product quantity scheduled is more or less than the actual quantity
produced.

15.2

Production capability

The production capability model is define as a collection of equipment,


material, personnel and process segment capability information for a specific
time (current or future). This information keep track of the availability of
each resources and for a definite time slice they may be defined as
committed, available or unattainable.
For example a particular equipment will be unattainable for three days from
March 15 due to scheduled maintenance. Or a material may be unattainable
because not already shipped. Or a person is unattainable from August 3 to
August 22 due to vacation.
Any resources may be commit to a particular production order, in this case
they are not available because already committed.
This information are very important in order to organize a calendar which
indicate which resources are available on a particular date. This calendar may
be very useful for the production schedule.
By collecting this information its also possible to estimate the maximum
capability available for a particular time, and it is also possible assign a
confidence to this estimation (as capability property). For example you may
estimate that in January the 95% of all site personnel will be available but
this prediction is reliable only at 70% because in January is more probably to
get a cold.
These information, with the passing of time, may change. For example a new
worker may be hired in this case he became a new available resource and
the total production capability is increased. Or a production order may
became completed and all resources that were committed to its execution
are now available, except for the materials consumed which are not any
more available and also the total production capability is decremented. The

94
Figure 15-1 illustrates a capability calendar that contain all scheduled event
that can modify the production capability.

Figure 15-1 Capability calendar


This capability calendar may be updated when you schedule the production
of a new product. In this way you may reserve all needed resources for your
production and a new production schedule will be allowed in the same time
only if there are enough resources for both of them.

15.3

Production capability utilization

The production capability utilization model is define as a collection of


equipment, material, personnel and process segment historical capability
information for a specific time (past or current). This information keep track
of the use of each resources and, for a definite time slice, they may be
defined as utilized or unused or maximum available.
The utilized capacity is a collection of all resources that were used in
production of product in according to acceptable quality limits. Its important
to specify that you have to keep to the quality production limits because one
of the most important information of this model is the work time of a
particular resource such as an equipment. An equipment may took a nominal
time for satisfy a production order in according to a nominal quality. If you
use it at 130% of its capacity it could took less time to complete the
production (so you have increased your performances) but probably the
quality of product produced may be lesser then the quality limit required. In
this case you have to extend the working time while the production order is
not completed within quality limits. In the end the production performance
may results lesser then if the equipment was used within nominal condition.
The unused capacity is a collection of all resources that was not used in
production. There can be several reasons for which a resource may be not

95
used such as for lack of production orders (some resource that were
available may rest unused), or an equipment was not available due to
unplanned maintenance (cleaning) or machinery break down. You may also
decide to not more use a resource due to not reduce the product produced
quality, for example an equipment may require a pause to chill in order to
restore the nominal conditions.
This model provide another important information: the maximum available
production capability, it is the capability that was available for use in
production. It may be calculated from the best capacity utilization achieved
over some recent period of time.
The production capability utilization model may be update both at real time
during production (by using a automatic control system) or in a second time
as revision or at occurring of particular events in according to a business rule.

If your plant have a control system available for example based on


PLC, it is possible to update the capability utilization model at real
time. For example the materials that have to be used during the
production may became utilized only when they are actually collected
from an automatic warehouse.

During production an equipment failure may occur so the capability


utilization have to change, if this change is not automatically the
priority is to interrupt the production to maintenance the equipment
only when the emergency is over you may take care to modify the
model data.

In the example show in the paragraph 15.4 on production order start


a production capability utilization is automatically created and an
equipment capability utilization is added to it as utilized.
Maximum Available
Production Capacity Utilization

Current Capacity
Utilization

Capability
Utilization

Unused:
Planned maintenance
New
resource available
and not used
Equipment
efficiency
degradation

Unacceptable quality.
Clean maintenance
required

Mintenance
terminated

Unused Capacity
Unused:
Equipment Down

Unused: Cleaning
Equipment became
unused because failure

Utilized Capacity
Time

Figure 15-2 Capability utilization history

96
The Figure 15-2 illustrates an example of capability utilization that collect
various historical information about the use of resources. Following the arrow
of time the events show in this figure are:
A new resource became available. In this case the maximum
available production capability utilization is increased.

The efficiency of an equipment decreases. This event may


occur because an equipment could reduce the quality of product
produced during production for example because the temperature
overgrow, or in this case the equipment require a cleaning. When
this happen also the maximum available production capability
utilization index degrades over time.

Unacceptable quality, maintenance required. An equipment


may require an extraordinary maintenance because the quality of
product produced became unacceptable, in this case the equipment
that was utilized became unused. In figure this unused capacity is
painted with yellow colour in order to make clear that is unused due
to maintenance.

Maintenance terminated. When this event occur the maximum


available production capability utilization index came back to nominal
value and the reason because this equipment is unused change from
maintenance to no-specific-reason or no-demand. The maximum
available production capability utilization index return to the standard
value.

Equipment failure. A failure may occur to an equipment that is


used, in this case it became unused due to breakdown. In figure this
unused case is differentiated whit red colour.

15.4

How to populate the production performance and


capability utilization models

In the previous paragraphs you have seen which are the model that take
care of collecting the production data. Now is show some code examples to
explore case where the production performance and the production capability
utilization models have to be populated.

15.4.1 Start a production order


The case we want to study consider that when a production order starts
several operation have to be done in order to satisfy the business rules. This
operation are:

Update the production order state. The first step, on a start


event, is to update the production scheduled, and its related
production request, state from waiting to running.

97

Populate a production performance model. In the production


performance model have to be added an element for each of these
tables: production performance, production response and segment
response with all needed parameters.

Use a specific equipment. A business rule impose the specification


of an equipment element such as a mixer among the equipment
actual elements when a start event occurs. The quantity for this
element is defined as a B2MML quantity.

Populate a production capability utilization model. The next


step is the definition of a production capability utilization model. In
this example we have linked the production capability utilization with
a production performance in order to obtain a temporal mapping of
the resource utilization during production. For this reason on the
same start event also a production capability utilization element have
to start.

Record information about an equipment during production.


Given that the production capability utilization have to maps the
production performance, when you add a new equipment actual
element you have also add a new equipment capability utilization
element in order to be able to keep track of the information about
the equipment utilization.

public static void Start(string productionScheduleID, string mixerID)


{
using (TransactionScope transactionScope = new TransactionScope())
{
// Modify state from waiting to running
Mdf.ProductionSchedule.ProductionSchedule productionSchedule =
Mdf.ProductionSchedule.ProductionSchedule.
Load(productionScheduleID);
if (productionSchedule.ScheduleState != "Waiting")
{
throw new Exception(ErrorResource.NoOrderWaiting);
}
productionSchedule.ScheduleState = "Running";
productionSchedule.Save();
// Load production request
ProductionRequest productionRequest = ProductionRequest.
Load(productionScheduleID, productionScheduleID);
productionRequest.RequestState = "Running";
productionRequest.Save();
//Add production performance
Mdf.ProductionPerformance.ProductionPerformance.Add(
productionScheduleID, productionSchedule.Description,
productionSchedule.Location, DateTime.Now,
productionScheduleID, DateTime.Now, null,
productionSchedule.EquipmentElementLevelID, "Running",
null, null);

98

//Add production response


ProductionResponse.Add(productionScheduleID,
productionScheduleID, productionScheduleID,
productionScheduleID, productionRequest.ProductID,
productionRequest.ProductVersion,
productionSchedule.Location, DateTime.Now, null,
"Running", null, null);
//Add segment response
SegmentResponse.Add("Preparation", productionScheduleID,
productionScheduleID, productionScheduleID,
productionScheduleID, "Preparation", "Preparation",
productionRequest.ProductID, productionRequest.
ProductVersion, productionRequest.Description,
productionRequest.Location, DateTime.Now, null, null,
null, null, null, "Running", null, null);
// Add mixer
string mixerQuantity = new Mdf.B2MML.Common.Quantity(
"1", new Mdf.B2MML.Common.DataType("integer"),
"N/A", null).ToString();
EquipmentsActual.Add(mixerID, "Preparation",
productionScheduleID, productionScheduleID,
"PcmsMixerTank", mixerID,
PcmsMixerTank.Load(mixerID).Description,
productionSchedule.Location, mixerQuantity,
null, null, null);
// Add productionCapabilityUtilization
Mdf.ProductionCapabilityUtilization.
ProductionCapabilityUtilization.Add(productionScheduleID,
productionSchedule.Description, "Available", null, null,
productionSchedule.Location, DateTime.Now, null, null,
null);
// Add Mixer equipment actual
string equipmentCapabilityUtilizationID = Sequence.
GetNextValue("EquipmentCapabilityUtilization");
EquipmentCapabilityUtilization.Add(
equipmentCapabilityUtilizationID, productionScheduleID,
"PcmsMixerTank", mixerID, "Running", null,
productionSchedule.Location, DateTime.Now, null,
mixerQuantity, null, null);
transactionScope.Complete();
}
}

15.4.2 Stop a production order


You may need to stop the production order execution due to repair a
machinery downtime. In our example several operation have to be done:
Verify that the production order you want to stop is actually running.

Set as Down the state of all models involved in this production


order: production schedule, production request, production
performance, production response and segment response.

99

Update the material produced actual quantity and the related


material lot with the actually quantity of material produced when the
downtime occur.

In the equipment capability utilization model find all equipment that


is involved in this production order with end time unset (we suppose
that all of them have the utilization type field set as utilized), and,
for each of them, set the end time and start new equipment
capability utilization elements as unused, setting the appropriate
machinery downtime causal.

public static void StartMachinaryDowtime(string productionScheduleID,


decimal producedQuantity, DateTime startData, string causalID)
{
using (TransactionScope transactionScope = new TransactionScope())
{
// Verification
ProductionSchedule productionSchedule = ProductionSchedule.
Load(productionScheduleID);
if (productionSchedule.ScheduleState != "Running")
{
throw new Exception(ErrorResource.NoOrderRunning);
}
// Close Capability utilization and set endTime and quantity
productionSchedule.ScheduleState = "Down";
productionSchedule.Save();
ProductionRequest productionRequest = ProductionRequest.Load(
productionScheduleID, productionScheduleID);
productionRequest.RequestState = "Down";
productionRequest.Save();
ProductionPerformance productionPerformance =ProductionPerformance.
Load(productionScheduleID);
productionPerformance.PerformanceState = "Down";
productionPerformance.Save();
ProductionResponse productionResponse = ProductionResponse.Load(
productionScheduleID, productionScheduleID);
productionResponse.ResponseState = "Down";
productionResponse.Save();
SegmentResponse segmentResponse =SegmentResponse.Load("Production",
productionScheduleID, productionScheduleID);
segmentResponse.SegmentState = "Down";
segmentResponse.Save();
// Modify actual quantity
MaterialsProducedActual materialsProducedActual =
MaterialsProducedActual.Load(productionRequest.ProductID,
"Production", productionScheduleID, productionScheduleID);
string materialQuantity = new Quantity(producedQuantity.ToString(),
new DataType("integer"), "N/A", null).ToString();
materialsProducedActual.Quantity = materialQuantity;
materialsProducedActual.Save();
MaterialLot materialLot = MaterialLot.Load(
materialsProducedActual.MaterialLotID);
materialLot.Quantity = producedQuantity;

100
materialLot.Save();
//Close equipment capability utilization;
var query =
from EquipmentCapabilityUtilization
equipmentCapabilityUtilization in
EquipmentCapabilityUtilization.
GetEquipmentCapabilityUtilizations()
where equipmentCapabilityUtilization.
ProductionCapabilityUtilization.
ProductionCapabilityUtilizationID == productionScheduleID
&& equipmentCapabilityUtilization.EndTime == null
select equipmentCapabilityUtilization;
MachineryDowntimeCausal machineryDowntimeCausal =
MachineryDowntimeCausal.Load(causalID);
foreach (EquipmentCapabilityUtilization raw in query)
{
raw.EndTime = DateTime.Now;
raw.Save();
string equipmentCapabilityUtilizationID =Sequence.GetNextValue(
"EquipmentCapabilityUtilization");
EquipmentCapabilityUtilization.Add(
equipmentCapabilityUtilizationID, productionScheduleID,
raw.EquipmentClassID, raw.EquipmentID, "Down",
machineryDowntimeCausal.Description, raw.Location,
DateTime.Now, null, raw.Quantity, "<Extended><CausalID>" +
machineryDowntimeCausal.CausalID +"</CausalID></Extended>",
null);
}
transactionScope.Complete();
}
}

15.4.3 Restart a production order


When the emergency that cause the production suspension is over you need
to restart the production. In our example several operation have to be done:
Use the transaction scope to be sure that all database modifications
are committed together if no error occur

Verify that the production order you want to restart is actually


down.

Set as Running the state of all models involved in this production


order: production schedule, production request, production
performance, production response and segment response.

In the equipment capability utilization model find all equipment that


is involved in this production order with end time unset (we suppose
that all of them have the utilization type field set as unused), and,
for each of them, set the end time and start new equipment
capability utilization elements as utilized.

101

public static void StopMachinaryDowtime(string productionScheduleID,


DateTime stopData)
{
using (TransactionScope transactionScope = new TransactionScope())
{
ProductionSchedule productionSchedule = ProductionSchedule.Load(
productionScheduleID);
if (productionSchedule.ScheduleState != "Down")
{
throw new Exception(ErrorResource.NoOrderDown);
}
// Close Capability utilization and set endTime and quantity
productionSchedule.ScheduleState = "Running";
productionSchedule.Save();
ProductionRequest productionRequest = ProductionRequest.Load(
productionScheduleID, productionScheduleID);
productionRequest.RequestState = "Running";
productionRequest.Save();
ProductionPerformance productionPerformance =ProductionPerformance.
Load(productionScheduleID);
productionPerformance.PerformanceState = "Running";
productionPerformance.Save();
ProductionResponse productionResponse = ProductionResponse.Load(
productionScheduleID, productionScheduleID);
productionResponse.ResponseState = "Running";
productionResponse.Save();
SegmentResponse segmentResponse =SegmentResponse.Load("Production",
productionScheduleID, productionScheduleID);
segmentResponse.SegmentState = "Running";
segmentResponse.Save();
//Close equipment capability utilization;
var query =
from EquipmentCapabilityUtilization
equipmentCapabilityUtilization in
EquipmentCapabilityUtilization.
GetEquipmentCapabilityUtilizations()
where equipmentCapabilityUtilization.
ProductionCapabilityUtilization.
ProductionCapabilityUtilizationID == productionScheduleID
&& equipmentCapabilityUtilization.EndTime == null
select equipmentCapabilityUtilization;
foreach (EquipmentCapabilityUtilization raw in query)
{
raw.EndTime = DateTime.Now;
raw.Save();
string equipmentCapabilityUtilizationID =Sequence.GetNextValue(
"EquipmentCapabilityUtilization");
EquipmentCapabilityUtilization.Add(
equipmentCapabilityUtilizationID, productionScheduleID,
raw.EquipmentClassID, raw.EquipmentID, "Running", null,
raw.Location, DateTime.Now, null, raw.Quantity, null,null);
}
transactionScope.Complete();
}
}

102

103

P ART 3

104

16 REPORTING
This chapter explain how to create reports for production that are the one of
the end purpose of every MES solution.
With a report your MES solution may provide several king of data from the
more easy materials orders or customers master data to more complex
reports such as for product traceability or OEE.
There are several instruments that deal with reports. The tool that we will
use to explain how to create and manage reports are Microsoft SQL
Reporting Services and the Visual Studio Report Viewer tool to integrate
reports in a web application.
When you install SQL Server you may chose to install also the Reporting
Services tool that provide your machine with a report server a some Visual
Studio tool that allow you to create and manage report as a Visual Studio
project. More information about Reporting Services may be find at the
Microsoft Msdn SQL Server Reporting Services 1 web page.
A report is based on a select command on your database that may by filtered
by defining some parameters. For example you may list all material in a
warehouse and let users able to filter it by warehouse location or by a
particular material property.

16.1

How to construct a report

To construct a report project in Visual Studio you may use the report server
project provided by SQL Reporting Services. The environment that this tool
provides allow user to easy create both logic and graphic part that compose
a report.

The logic part is composed by the query that extracts the data from
database and the parameters required to implement filters.

The graphic part concerning the organization of data views and all
component that a report document have to contain.

To easy understand how to create a report we develop two example that


concerning the ISA - 95 production scheduling and production performance
models. In particular we want create a report for all segment requirement
scheduled and another for all segment response collected.
To better understand at which models and data we will refer to, the entityrelation models for the two segment models and the ISA - 95 models are
depicted below.

http://msdn.microsoft.com/en-us/library/ms159106.aspx

105

Figure 16-1 Segment Requirement entity-relation model


May contain

0..n

Segment Requirement
0..n
0..n
0..n

Production Parameter

Corresponds to element in

Equipment Requirement

1..1

Equipment Model

Corresponds to element in

Material Produced Requirement


1..1

Material Consumed Requirement

Material Model

Corresponds to element in

0..n
0..n

Consumable Expected
Corresponds to element in

Personnel Requirement

1..1

Personnel Model

Figure 16-2 ISA - 95 Segment Requirement model


The entity-relation model of the Mdf database (Figure 16-1) for the segment
requirement maps the B2MML standards. As you can see B2MML add an
ulterior table in compare with the ISA- 95 segment requirement model
(Figure 16-2) that is the material requirement table.
The report that we want develop contain a master zone in which there are all
data related to the segment requirement and the material produced then
there are a detail page that contain a list of all material consumed
requirement (see Figure 16-3 and Figure 16-6).
This report is obtain following this steps:

Create a Visual Basic project as Server Report Project Wizard. It


automatically provide an environment to create your reports. In the
Solution Explorer panel there are now two tables one for shared data
sources, and one for reports.

Left click on the reports table and then click on the Add New Report
link. Then a wizard form is shown that help you with the creation
procedure.

Firstly you have to set a data source that contain the data to expose.
So you have to indicate the database name, its type, and the

106
connection string. You may also chose to make this as a shared data
source, in this way you may use the same data source for various
reports.

Then you have to indicate the query or stored procedure you have to
use. It is possible to use a query builder to project them.

Go with next, you may chose if display the data as matrix or tabular.
And then how to group the data in the table/matrix. In our example
(Figure 16-3) we have inserted the SegmentRequirementID as page
field in order to obtain one page for each segment requirement, then
the fields related to the consumed material are inserted as detail
fields.

Next step complete the wizard allow you to chose if view a preview
of your report or not.

You may now complete your report adding all fields that you have
not chose in the wizard procedure, and defining parameters that
allow you to create filters. To create a new parameter you have to
access to the dataset property, then in the parameter section you
can add your parameter. Now, you may modify your query to be
filtered by this parameters. When you execute your report all
parameters defined will be required in a proper parameter section.

The figure below illustrates a simple report example. In the header part
there is an area in which you may insert the product ID to search. Below this
area there are the commands to change page and print the report.
Product Produced ID

PCMS
SR.0000063 White Sambuca
Material Produced

SF.020104

Quantity

1229,00 l

01.00

Semi finished produced

Requirement ID

Material description

Quantity

MSS.0100188

Sugar

245,80 kg

PreparationAlcohol

Alcohol

382,87 l

PreparationWater

Water

932,16 l

16/10/2009

PCMS - Plant Control Management System

Figure 16-3 Segment requirement report

Page 1 of 4

107
In this page there is another report example for the segment response
model. The Figure 16-4 illustrates the entity-relation model, the Figure 16-5
show the related ISA - 95 model and the Figure 16-6 is the report.

Figure 16-4 Segment Response entity-relation model

Figure 16-5 ISA - 95 Segment Response model


Product Produced ID

Production Line

PCMS
SR.0000110 White Sambuca 0,75l
Material Produced

FM.030105

Lot ID

L92932

01.00

White Sambuca 0,75l

Quantity

1000 BT

Equipment Used ID

Description

Status

Running

Preparation.Tank2

Tank 2

Start time

20/10/2009 14.44.40

Production.Line1

Automatic Line

Material Consumed ID

Material Lot Material description

Quantity

BT SAM 075

L3324

Sambuca Bottle 75 cl

1000 BT

SF.020104

S92932

White Sambuca

16/10/2009

PCMS - Plant Control Management System

Figure 16-6 Segment Response report

750 l
Page 1 of 4

108

16.2

How to view a report

Once your reports is created you may use it in several way. The first step is
to distribute your reports that is upload the .rdl report file on your report
server.
This operation can be done in two way: you can distribute your report using
the distribution command, you can find it in the context menu of the report
project in the solution explorer window. As an alternative you may load the
report file directly by the reporting servers web service using the upload
file link.

Figure 16-7 SQL Report Servers web service


To access to the web service you need only a web browser and enter the
Reporting Servers web services URL in the address bar.
Now that your reports are deployed on the report server essentially you have
two choices to access your reports: you may use the report web service, or
you can integrate the reports in your MES web application using Microsoft
Report Viewer. More information about this Visual Studio control may be find
on the Microsoft Msdn Report Viewer 1 web page. You may also use
report viewer in local mode without using a report server, in this case your
report files doesnt have to be deployed on the report server but have to be
converted in a .rdlc file type.
If you chose to use the report viewer in remote mode (using the report
server) you have only insert the report viewer tool in your web page set the
appropriate server report options:
<ServerReport
ReportPath="/EmPy.Pcms.Reports/MyReport"
ReportServerUrl="http://ServerIP:8080/reportserver" />

Another important options to set are the access credential, you may specify
them using the Windows identity impersonate method and set the user name
and password of the report server execution account.

http://msdn.microsoft.com/en-us/library/ms251671.aspx

109

P ART 4

110

111

17 USE CASE: TRACEABILITY


This chapter describe how can be realize a traceability report. The following
examples have the intent to make clear how can be easy collect all
information required to carry out a traceability report if your MES solution is
implemented in respect of the ISA - 95 standard as is a MES implemented
with Mdf.
According to the Wikipedia dictionary, traceability is defined as:

The ability to trace (identify and measure) all the stages that lead to
a particular point in a process that consist of a chain of interrelate
events. (Wiktionary 1 . 26/10/2009)
The product traceability is one of the most important information that an
industry have to provide according to the law. Several country fix some rules
due to make the production process traceable. This is particularly true for
food and beverage processing.
The traceability information may be related to:

Forward traceability. It is the collection of all finished or semifinished product lots in which a particular resource has been used.

Backward traceability. It is the collection of all resources that


have been used to carry out a particular product

In both cases a traceability report may also include the specification of the
inbound orders related to the resource(s) and/or the outbound order related
to the product(s) to trace.
The following chapters show two traceability reports respectively for forward
and backward traceability of a beverage product.

17.1

Forward traceability

http://en.wiktionary.org/wiki/traceability

112

PCMS

Forward Traceability

Material ID

Sugar

Description

Sugar sacks

Lot

L27403

Lot status

Available

Quantity

800 KG

Receipt

23/10/2009

Valid till

01/11/2011

Inbound Order
Order ID

Supplier ID

Corporate name

Bill

Schedule

Receipt

IO.100020

451.11

Sugar SRL

B83452

23/10/2009

23/10/2009

Semi-finished lots lost which contain the selected material lot


Material ID

Description

Lot

SF.020104

White Sambuca

S92945

Quantity
1.000 LT

Finished lots lost which contain the selected material lot


Material ID

Description

Lot

FM.030105

White Sambuca 0,75l

L92962

26/10/2009

PCMS - Plant Control Management System

Quantity
1 LT
Page 1 of 32

113

A PPENDIX

114

A. BIBLIOGRAPHY
ISA - The Instrumentation, Systems, and Automation Society

ANSI/ISA 95.00.01-2000, Enterprise - Controll System


Integrations.l.Instrument Siciety of America2000ISBN: 1-55617727-5
World Batch Forum (WBF) The organization for production
technologyBusiness To Manufacturing Markup Language
(B2MML)[Online][Cited: 1 September
2009]https://www.wbf.org/catalog/b2mml.php

115

B. WEB SITE
EMPYSTUDIOHTTP://WWW.EMPYSTUDIO.COM/MDF/DOWNLOADS.ASPX .......................... 7
MICROSOFTDEVELOPERNETWORK(MSDN).NETFRAMEWORKDEVELOPERCENTER
HTTP://MSDN.MICROSOFT.COM/ENUS/NETFRAMEWORK/DEFAULT.ASPX ........................ 30
MICROSOFTDEVELOPERNETWORK(MSDN)SQLSERVERDEVELOPERCENTER
HTTP://MSDN.MICROSOFT.COM/ENUS/SQLSERVER/DEFAULT.ASPX ................................ 31
MICROSOFTDOWNLOADCENTER
HTTP://WWW.MICROSOFT.COM/DOWNLOADS/DETAILS.ASPX?FAMILYID=333325FDAE52
4E35B531508D977D32A6&DISPLAYLANG=EN ...................................................... 7
WBFB2MMLHTTPS://WWW.WBF.ORG/CATALOG/B2MML.PHP ................................ 26
WORLDBATCHFORUM(WBF)HTTPS://WWW.WBF.ORG/CATALOG/............................... 26

S-ar putea să vă placă și