Using partial class
Microsoft introduced partial class in c# 2.0. This technique is very useful to use custom tool like Mdf Custom Class Generator.
Mdf Custom Class Generator write, in this example, Tank.Mdf.cs. In this way you can add your partial class to manage some custom business rule.
In this example we add a new method: RefreshFromPLC()
1#region Using
2
3using System;
4using System.Collections.Generic;
5using System.Text;
6using EmPy.S7;
7
8#endregion
9
10namespace Mdf.BusinessEntities.Equipment
11{
12 public partial class Tank
13 {
14 #region Custom methods
15
16 public void RefreshFromPLC()
17 {
18 if (PlcReader != null)
19 {
20 Volume = (decimal)PlcReader.ReadFloat(DB, DW);
21 if (Volume > Threshold)
22 {
23 throw new Exception("Volume over threshold!");
24 }
25 }
26 else
27 {
28 throw new Exception("Plc reader not setted!");
29 }
30 }
31
32 #endregion
33
34 #region Custom properties
35
36 public PlcReader PlcReader;
37
38
39
40
41 public byte DB;
42 public ushort DW;
43
44
45
46 public decimal Threshold;
47
48 #endregion
49 }
50}
As you can see, in this example we added:
- Some custom properties
- Some custom methods
In the partial class we can access all properties and methods of the CCG generated class (i.e. Volume property).
Mdf - Mes development framework
Mdf - MES Development
Framework has been defined from experienced developers to respond to both customers and developers needs.
Write complex Manufacturing Execution Systems fully ISA-95 compliant will never be easier using
c# or VB.NET with LINQ to Entity technology,
SQL Server 2005/2008 as storage layer,
ASP.NET 3.5 with extensive use of Ajax and
ASP.NET MVC for user interface,
OPC to communicate with PLCs and field devices and
Windows Workflow Foundation for plant business rules.
Download the Mdf latest version here.
Mdf Demo