编写 OPC UA Compile的模型设计文件

OPC Foundation 开源了一个模型编译工具-UA ModelCompiler.它接受下面两种信息模型格式:

  • NodeSet2.xml
  • ModelDesign.xml

    看来ModelDesign 是专门为UA ModelCompiler设计的,采用了分层结构描述,它比NodeSet2 可读性更好一点。适合使用普通文本编辑器手工编写。

编辑完成后,使用 UA-ModelCompiler 编译为NodeSet2.xml,C# 的数据常量和类。可以将它们结合到OPCUA 的Server中去。

例子 锅炉类型

这个例子考虑了锅炉中从水中产生蒸汽的真实过程。系统(锅炉)包括:

  • 输入和输出管道

  • 锅炉汽包

  • 控制模块

  • 传感器

锅炉如下图所示

编写 OPC UA Compile的模型设计文件_第1张图片

 OPC UA 模型

编写 OPC UA Compile的模型设计文件_第2张图片

 OPC UA 地址空间模型设计器中的锅炉模型

        可以使用多种工具来构建OPC UA 地址空间中的模型,设计的输出是模型的XML 描述,OPCUA Fundation 提出了XML 的格式规范,NodeSet2.xml,在ModelCompiler 项目中又提出了ModelDesign.xml 的格式。

模型设计器的输出

  • NodeSet2.xml
  • ModelDesign.xml

模型的结构

锅炉

      输入管道(Input Pipe)

                流量变送器(FlowTransmitter1)

                阀门(Valve)

     汽包(Drum)

                位指示器(LevelIndicator)

       输出管道(Output Pipe)

                流量变送器(FlowTransmitter2)

定义的类型

从上面的结构看,我们需要建立下面几种类型

BoilerType

BoilerInputPipeType

FlowTransmitter1

ValveType

BoilerDrumType

LevelIndicatorType

BoilerOutputPipeType

FlowTransmitter2

但是还需要构建一些支持类型

(1)FlowTransmitter1和FlowTransmitter2 分别是输入管道和输出管道中的流量发送器,因此,需要定义:

FlowTransmitterType

(2)FlowTransmitterType和LevelIndicatorType的基类型是通用传感器,因此定义:

GenericSensorType

(3)阀门的基类型是通用执行器类型,因此定义

GenericActuatorType

 (4)在信息模型的右边,还定义的控制部分的模型,它们包括

  流量控制器 FlowTransmitterType(FC001)

   位控制器  LevelIndicatorType(LC001)

 (5) 位控制器和流量控制器的基类型是通用控制器

    GenericControllerType

(6)还有一个定制控制器

   定制控制器CustomControllerType(CC1001)

(7) 该模型中,还定义了某厂商的流量发送器类型

AcmeFlowTransmitterType

(8) 此外定义测试数据类型

TestDataObjectType

(9) 方法

CreateBoiler

我理解该信息模型主要是为了展示Model.xml 的模型定义方法,我们并不需要去深入了解模型的实际意义。

使用文本编辑器编写ModelDesgn.xml 文档



  
    http://opcfoundation.org/UA/
    http://opcfoundation.org/UA/Sample/
  

  
    A reference that indicates a flow between two objects.
    FlowFrom
  

  
    A reference that indicates a high temperature flow between two objects.
    HotFlowFrom
  

  
    A reference that indicates an electrical signal between two variables.
    SignalFrom
  

  
    Specified the vendor for a peice of equipment.
    VendorFor
  

  
    A generic PID controller
    
      
      
      
    
  

  
    A generic sensor that read a process value.
    
      
      
    
  

  
    Represents a piece of equipment that causes some action to occur.
    
      
    
  

  
    A custom PID controller with 3 inputs
    
      
      
      
      
    
  

  
    An actuator that controls the flow through a pipe.
  

  
    A controller for the level of a fluid in a drum.
  

  
    A controller for the flow of a fluid through a pipe.
  

  
    A sensor that reports the level of a liquid in a tank.
  

  
    A sensor that reports the flow of a liquid through a pipe.
                                                                

  
    A flow transmitter manufactured by Wile E. Coyote Enterprises.
    
      
        
          0000000
        
      
      
        
          
            en
              This documentation appears to be a recipe on how to cook road runners...
          
        
      
      
      
        
          
            How frequently to scan values when calibrating.
          
          
            The duration of the calibration cycle in seconds.
          
        
        
          
            A text report containing the calibration parameters.
          
        
      
    
  

  
    Creates an instance of an object or variable.
    
      
        The parent of the new instance.
      
      
        The reference from the parent to the new instance.
      
      
        The browse name for the new instance.
      
    
    
      
        The identifier assigned to the new instance.
      
    
  

  
    
      
        FTX001
      
      
        ValveX001
      
    
    
      
        ua:HasNotifier
        BoilerInputPipeType_FlowTransmitter1
      
    
  

  
    
      
        LIX001
      
    
    
      
        ua:HasNotifier
        BoilerDrumType_LevelIndicator
      
    
  

  
    
      
        FTX002
      
    
    
      
        ua:HasNotifier
        BoilerOutputPipeType_FlowTransmitter2
      
    
  

  
    A boiler used to produce stream.
    
      
        PipeX001
        
          
            FTX001
            
              
            
          
          
            ValveX001
            
              
            
          
        
        
          
            FlowTo
            BoilerType_Drum
          
        
      
      
        DrumX001
        
          
            LIX001
            
              
            
          
        
        
          
            HotFlowTo
            BoilerType_OutputPipe
          
        
      
      
        PipeX002
        
          
            FTX002
            
              
            
          
        
      
      
        FCX001
        
          
            
              
                SignalTo
                BoilerType_InputPipe_FlowTransmitter1_Output
              
            
          
          
          
            
              
                SignalTo
                BoilerType_InputPipe_Valve_Input
              
            
          
        
      
      
        LCX001
        
          
            
              
                SignalTo
                BoilerType_Drum_LevelIndicator_Output
              
            
          
          
          
            
              
                SignalTo
                BoilerType_CustomController_Input1
              
                        
          
        
      
      
        CCX001
        
          
          
            
              
                SignalTo
                BoilerType_InputPipe_FlowTransmitter1_Output
              
            
          
          
            
              
                SignalTo
                BoilerType_OutputPipe_FlowTransmitter2_Output
              
            
          
          
            
              
                SignalTo
                BoilerType_FlowController_SetPoint
              
            
          
        
      
      
        CreateBoiler
      
    
    
      
        ua:HasNotifier
        BoilerType_InputPipe
      
      
        ua:HasNotifier
        BoilerType_Drum
      
      
        ua:HasNotifier
        BoilerType_OutputPipe
      
    
  

  
    
      
        When the maintenence must be completed.
      
      
        True if the required maintenence is regularily scheduled.
      
    
  

  
    
      
        The identifier for the work order.
      
    
  

  
    
      
      
      
      
      
      
    
  

  
    A single address.
  

  
    
      
        ua:Organizes
        ua:ObjectsFolder
      
    
  

  
    A vendor described in the ERP system.
    
      
        The name of the company.
      
      
        The locations for the company.
      
    
  

  
    A standard boiler
    
      
        PipeX001
        
          
            FTX001             
          
        
            
    
    
      
        ua:Organizes
        Samples
            
    
  

  
    
      
        The number of new values to generate.
      
    
  

  
    
      
      
    
  

  
    
      
        If true the server will produce new values for each monitored variable.
      
      
    
  

  
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
  

  
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
  

  
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
  

  
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
  

  
    
      
        
          
          
        
      
    
    
      
        ua:Organizes
        Samples
      
    
  

  
    Opc.Ua.Sample
    
      
        ua:HasComponent
        ua:XmlSchema_TypeSystem
      
    
  

  
    Opc.Ua.Sample
    
      
        ua:HasComponent
        ua:OPCBinarySchema_TypeSystem
      
    
  

你可能感兴趣的:(OPCUA,自动化)