ASN.1 tag
-------------------------
BOOLEAN            01
INTEGER            02
BITSTRING          03
OCTETSTRING        04
NULL               05
OBJECT IDENTIFIER  06

SEQUENCE           10
IA5STRING          16
UTCTIME            17
GENERALIZETIME     18
VISIBLESTRING      1A

L
LENGTH:
If the length of the DATA is less than 128 bytes, the LENGTH is that number of bytes.
If the length of the DATA is greater than or equal to 128 bytes, the LENGTH is
encoded as several bytes.The first indicating how many bytes encode the actual
length, and with bit 7 set. The subsequent length bytes contain the actual length.

V
Data

====================================================
MMS
主要目的是定义一套用来在设备和计算机程序之间高度互通、协同工作的通讯标准
-----------------------------------------------------               
Part 1 is the service specification.
     The service specification contains a definition of
1) the Virtual Manufacturing Device,
2) the services (or messages) exchanged between nodes on a network, and
3) the attributes and parameters associated with the VMD and services.

ISO9506-1定义了服务(Service)规范,包括:
 (1)虚拟制造设备(VMD,Virtual Manufacturing Device)概念的引入和定义;
 (2)网络环境下各节点之间服务或报文的交换规则定义;
 (3)与VMD和服务有关的属性和参数的定义
 
ISO9506-1定义了如下几大类服务:
 (1)环境及通用管理服务(Environment And General Management Services);
 (2)虚拟制造设备支持服务(VMD Support Services);
 (3)域管理服务(Domain Management Services);
 (4)程序管理服务(Program Invocation Management Services);
 (5)变量访问服务(Variable Access Services);
      Read ,Write,InformationReport,GetVariableAccessAttributes
      DefineNamedVariable,DeleteVariableAccess
      DefineNamedVariableList
      GetNamedVariableListAttributes
      DeleteNamedVariableList
      DefineNamedType
      DeleteNamedType
      GetNamedTypeAttributes
     
 (6)信号量管理服务(Semaphore Management Services);
 (7)操作员通信服务(Operator Communication Services);
 (8)事件管理服务(Event Management Services);
 (9)日志管理服务(Journal Management Services)。
 
Part 2 is the protocol specification. The protocol specification
       defines the rules of communication which includes
1) the sequencing of messages across the network,
2) the format (or encoding) of the messages, and
3) the interaction of the MMS layer with the other layers of the communications network.
ISO/IEC 9506-2定义了协议(Protocol)规范,包括:
 (1)报文的执行序列;
 (2)报文或编码的格式;
 (3)MMS层与OSI参考模型其它层的相互作用关系

协议规范使用表示层标准ISO8824即抽象语句标识(ASN.1,Abstract Syntax Notation Number One)
定义MMS的报文格式。MMS提供了通过网络进行对等(peer-to-peer)实时通信的一套服务集。
MMS应该可以支持多种通信方式,包括以太网、令牌总线、RS-232C、OSI、TCP/IP、MiniMAP、FAIS等,
MMS也可通过网桥、路由器或网关连接到其它系统上。

互操作性 
MMS标准还提供了如下的定义:
 (1)对象(Object):  MMS定义了一套通用对象(如变量)及这些对象的网络可见属性(如名字、值、类型)。
 (2)服务(Service): MMS定义了一套访问和管理网络环境下对象的通信服务(如读、写)。
 (3)行为(Behavior):MMS定义了当执行相关服务时,设备所应表现出的网络可见行为。

 对象、服务、行为的定义构成了一套关于设备和应用在VMD模型中如何通信的规范。VMD模型只定义
 了通信的网络可见方面,对于实际设备如何实现VMD模型的细节,如编程语言、操作系统、CPU类型
 和I/O系统等MMS则不作定义。通过定义设备的网络可见部分的行为,MMS的VMD模型就能使设备之间
 具有很高的互操作性,同时这些定义又不妨碍设备和应用内部使用不断创新的新技术。
 a.The Developer of the Application
 b.Network Connectivity
 c.Function Performed.
 
独立性
 与很多只适用于特定产品的专用通信系统不同,MMS是一个通用的、独立于专用设备的国际标准体系。
 MMS为用户提供了一个独立于所完成功能的通用通信环境

MMS, as an application layer protocol
provides application services to the business functions, not connectivity services.
只提供连通服务消息机制,并没有提供连通服务。

MMS的关键特点是VMD模型,定义了:
a. objects (e.g. variables) that are contained in the server,
b. the services that a client can use to access and manipulate these objects
   (e.g. read or write a variable), and
c. the behavior of the server upon receipt of these service requests from clients.

MMS 对象
a. VMD Object
   Status,UnsolicitedStatus,Identify
  
   属性:
   Capabilities、Logical Status、Physical Status
   服务:
   Status、UnsolicitedStatus、 GetNameList、 Identify.
  
b. Variable and Type Objects
   变量访问模型
    MMS Variables是a virtual object ,只是指明访问实际变量(real variable)的路径,
    MMS Variables的创建、删除只是针对访问路经,并不指实际的变量。
   
    两种类型MMS Variables:
    1. Unnamed Variable Object: 通过设备地址访问,为了兼容老设备
       属性:
          Address
            (地址表示法:Numeric(e.g. 103),Symbolic(e.g. "R001" or "N7:0"),Unconstrained )
          MMS Deletable
          Type Description
    2. Named Variable Object
       属性:
          MMS Deletable
          Type Description
          Access Method       
  
c. Program Control Objects (Domains and Program Invocations)  
   A MMS domain is defined as an object that represents a resource
   within the VMD (e.g. the memory in which a program is stored).
  
   the VMD execution model provides for MMS clients are:
   .Services for commanding a VMD to upload/download their domains to/from a
     MMS client or file in a filestore system (either in the VMD or external to the VMD)
   .Services for a VMD to request a domain upload/download from a client.
   .Start, Stop, Reset, Resume, and Kill services for controlling the execution
     of program invocations.
   .Services for deleting, creating, and obtaining the attributes of domains and
     program invocations.
    
   VMD执行模型:
   Domains模型---代表MMS对象中实际设备的一些资源,如:连续数据块,内存
   (思想借鉴于工业过程控制中的批处理...)
    属性:
        Capabilities
        State        - LOADING, COMPLETE, INCOMPLETE, READY, or IN-USE
        Deletable
        Sharable
    服务:
        InitiateDownloadSequence
        DownloadSegment
        TerminateDownloadSeqence
        InitiateUploadSequence
        UploadSegment
        TerminateUploadSequence
        DeleteDomain
        GetDomainAttributes
        RequestDomainDownload
        RequestDomainUploa
  LoadDomainContent
  StoreDomainContent
   Program Invocations模型(思想借鉴于UNIX Execution Thread)
     A program invocation is an execution thread which consists
     of a collection of one or more domains.(一段可执行代码??)
     属性:
       State
       List of Domains
       Deletable
       Reusable
       Monitored
       Execution Argument
     服务:
       CreateProgramInvocation
    DeleteProgramInvocation
    GetProgramInvocationAttributes
       Start
       Stop
       Reset
       Resume
       Kill
 
d. Event Objects    
  . event conditions :the state of an event
    两种类型
    a. Network Triggered
    b. Monitored
    ab共同属性:
      MMS Deletable
      State
      Priority
      Severity
    b的属性:
      Monitored Variable 
      Enabled
      Alarm Summary Reports
      Evaluation Interval
      Time of Last Transition to Active
   Time of Last Transition to Idle
  服务:
    DefineEventCondition.
       DeleteEventCondition.
       GetEventConditionAttributes
       ReportEventConditionStatus
       AlterEventConditionMonitoring
       GetAlarmSummary      
  . event enrollments:who to notify about the occurrence of an event
      属性:
       MMS Deletable
       Event Condition
       Transitions
       Notification Lost
  . event actions    :the action that the VMD should take upon the occurrence of an event
     属性:
       MMS Deletable
       Service Request
     服务:
       DefineEventAction.
       DeleteEventAction.
       GetEventActionAttributes
       GeportEventActionStatus
 
e. Semaphore Objects (以Unix的Semphore/token为原型)

   Token Semaphores属性:
      Deletable
      Number of Tokens
      Owned Tokens
      Hung Tokens
   Pool Semaphores属性: 
      Free Named Tokens
      Owned Named Tokens
      Hung Named Tokens
     
f. Journal Objects
g. Operator Station Object
h. File
i. MMS CONTEXT MANAGEMENT
MMS provides services for managing the context of communications between two MMS
nodes on a network. These services are used to establish and terminate application
associations and for handling protocol errors between two MMS nodes.

VMD
A server is a device or application that contains a VMD
         and its objects (variables, etc.).
A client is a networked application (or device) that asks for
         data or an action from the server.

In a very general sense, a client is a network entity that issues
MMS service requests to a server. A server is a network entity that
responds to the MMS requests of a client.

MMS模型中通用的方法是:
Get,Set,QueryAttributes,Create,Delete
具体的每个对象、服务的定义都可Map到现在的面向对象编程思想中

Object Scope:
VMD Wide
Domain Specific
Association Specific
to the Manufacturing
Message Specification (MMS)
---------------------------------------------------------------
ASN.1
BER(Basic Encoding Rules ,X.209)

X6801

编码规则的区别:
1. DER
为确保编码的唯一性,出现了CER和DER两种编码方案,它们均为BER子集。
其中DER只使用定长编码,CER基于不定长编码。

2. PER
在PER中,tag从不传送,length和value如果双方都知道,也不需传送。
因此,其编码更精简,效率更高。

The key difference between them is that DER uses the definite
length form of encoding while CER uses the indefinite length
form. DER is more suitable for the small encoded values,
while CER is more suitable for the large ones.

Whereas the basic encoding rules give the sender of an encoding
various choices as to how data values may be encoded,
the canonical and distinguished encoding rules select just one
encoding from those allowed by the basic encoding rules, eliminating
all of the sender's options. The canonical and distinguished encoding
rules differ from each other in the set of restrictions that they
place on the basic encoding rules.

The distinguished encoding rules is more suitable than the canonical
encoding rules if the encoded value is small enough to fit into the
available memory and there is a need to rapidly skip over some nested
values. The canonical encoding rules is more suitable than the distinguished
encoding rules if there is a need to encode values that are so large that
they cannot readily fit into the available memory or it is necessary to
encode and transmit a part of a value before the entire value is available.
The basic encoding rules is more suitable than the canonical or distinguished
encoding rules if the encoding contains a set value or set-of value and there
is no need for the restrictions that the canonical and distinguished encoding
rules impose


8.6.2 制造自动化协议
(1) 定义map,是美国通用汽车公司(gm)提出的一种用于制造自动化的局域网协议。
(2) mms有两种称呼:iso把它叫做manufacturing message specification或iso9506,
      而eia则定名为maunfacturing messaging service或rs-511
(3) mms协议的核心是vmd
(4) mms主要有八大类应用功能:上下文管理,加工程序传输管理,加工程序运行控制,
     变量访问,操作员通信,vmd支持,时间管理和日志管理
(5) mms是一种不对称主-从式通信协议,使用了发起者和响应者的概念
(6) mms采用有连接证实型通信方式,两个mms用户必须线在它们之间建立联系,然后才可以在mms环境中交换信息。