开发者

How to parse CIMPLICITY's ctx file

I have to parse CIMPLICITY's ctx file. Ctx file sample:

(Version 42)
(DocumentSummary)
(GmmiToplevelDocument
  (GmmiDocumentObject
    (GmmiContainerObject
      (GmmiObject "" 0
        (Help "" "" "")
        (GmmiPointMap
          (GmmiPoint "MODBUS.HOIST.HST1.HST" 8 0 1)
          (GmmiPoint "MODBUS.HOIST.HST2.MAXVAL" 9 0 1))
        (GmmiOptionTable
          (GmmiVariables))
        (GmmiTabOrder -1)) (Color 3 8) (Color 3 5)
      (Font "Arial" 0 280 1 0)
      (GmmiObjectPtrList
        (GmmiOleObject
          (GmmiObject "" 0
            (Help "" "" "")
            (Empty)
            (GmmiTabOrder 0)) 0
          (Extents
            (Rect 180 6840 6255 3825)
            (Rect 180 6840 6255 3825))
          (Border (Color 1 &hff000000) 0 11 0)
          (Interior (Color 0) (Color 1 &hff000000) 1)
          (Interior (Color 1 &hff000000) (Color 1 &hff000000) 1) 0 0 1000 1000 1000 1000
          (Rect 180 6840 6255 3825) "TREND.TrendCtrl.1"
          (OleMagic 0)
          (GROleControl
            (OlePropBag {B4E7803D-9435-11CE-9CF4-0020AF743F4D}
               "BInLegend1" 1
               "BaseProject" "MOD_TEST"
               "Color1" 255
               "CompressionSampleUnits1" 0
               "Name1" "MODBUS.HOIST.HST1.HST"
               "Name2" "Chart X Axis"
               "Name3" "Chart Y Axis"
               "NumberLines" 1
               "Order1" 0
               "PointID1" "MODBUS.HOIST.HST1.HST"
               "Type1" 7
               "Type3" 1
               "_ExtentX" 10716
               "_ExtentY" 5318
               "_StockProps" 13
               "_Version" 393220)))
        (GmmiTextObject
          (GmmiObject "" 0
            (Help "" "" "")
            (Empty)
            (GmmiTabOrder -1)) 23
          (Extents
            (Rect 180 3600 3144 2752)
            (Rect 180 3600 1776 2752))
          (Font "" 0 720 1 0)
          (Interior (Color 1 &hff000000) (Color 1 &hffffffff) 1)
          (Border (Color 1 &hff000000) 0 11 0) 18
          (Point 180 3600) "HOIST 1")
        (GmmiTextObject
          (GmmiObject "" 0
            (Help "" "" "")
            (GmmiOptionTable
              (GmmiOptionTable
                (GmmiValueAnim
                  (GmmiExprAnim 3
                    (GmmiExpr "MODBUS.HOIST.HST1.HST")) 0
                  (ExecCond "" "") "%s" 4)))
            (GmmiTabOrder -1)) 23
          (Extents
            (Rect 3240 3600 4436 2964)
            (Rect 3240 3420 4436 2784))
          (Font "" 0 540 1 0)
          (Interior (Color 1 &hff000000) (Color 1 &hffffffff) 1)
          (Border (Color 1 &hff000000) 0 11 0) 18
          (Point 3240 3600) "Text")
        (GmmiTextObject
          (GmmiObject "" 0
            (Help "" "" "")
            (Empty)
            (GmmiTabOrder -1)) 23
          (Extents
            (Rect 360 1800 1662 1471)
            (Rect 360 1800 1662 1471))
          (Font "Arial" 0 -280 1 0)
          (Interior (Color 1 &hff000000) (Color 1 &hffffffff) 1)
          (Border (Color 1 &hff000000) 0 11 0) 18
          (Point 360 1800) "Test data:")
        (GmmiTextObject
          (GmmiObject "" 0
            (Help "" "" "")
            (GmmiOptionTable
              (GmmiOptionTable
                (GmmiValueAnim
                  (GmmiExprAnim 3
                    (GmmiExpr "MODBUS.HOIST.HST2.MAXVAL")) 0
                  (ExecCond "" "") "%s" 4)))
            (GmmiTabOrder -1)) 23
          (Extents
            (Rect 1980 1800 2599 1471)
            (Rect 1980 1800 2599 1471))
          (Font "Arial" 0 -280 1 0)
          (Interior (Color 1 &hff000000) (Color 1 &hffffffff) 1)
          (Border (Color 1 &hff000000) 0 11 0) 18
          (Point 1980 1800) "Text")) 0
      (GmmiBackdrop
        (Border (Color 1 &hff000000) 0 11 0)
        (Interior (Color 1 &hffc0c0c0) (Color 1 &hff000000) 1))))
  (Point 100 100)
  (Size 9600 7200) 100 "")
(OleItems)

The file above represents CIMPLICITY's screen. The issue is to build WPF screen based on that file. First of all, by my opinion, I should parse that file, remove unneeded parts and then build interface.

I've googled on the Internet .N开发者_运维技巧et based parser - FParsec. The problem is I've never coded with F# and it's difficult to understand how to use this library. So I don't want to do an extra work.

The main question: is it possible to parse that file to custom object representing screen's structure with FParsec. For example, this object may has so definition:

public class Document
{
    public string Version { get; set; }
    public object Summary { get; set; }

    public GmmiTopLevelDocument GmmiTopLevelDocument { get; set: }
}

public class GmmiTopLevelDocument
{
    public GmmiDocumentObject GmmiDocumentObject { get; set; }

    public Point Point { get; set; }
    public Size Size { get; set; }
}

public class GmmiDocumentObject
{
    ...
}

May be it's wrong way? What is right?

UPDATE:

Also I have BNF for scree language. Sample:

<GmmiTextButtonObject> ::= "(" GmmiTextButtonObject<GmmiButtonObject><GRTextButton>")"
<GmmiTextObject> ::= "(" GmmiTextObject<GmmiGraphicObject> <GRText> ")"

<ToplevelDocument> ::= "(" GmmiToplevelDocument<GmmiDocument><initialPosition.Point><Size>zoom.number> ")"
<ToplevelDocumentPO> ::= <GmmiPointMap><ambientForeground.GRColorAttr><ambientBackground.GRColorAttr>
<ambientFont.GRFontAttr>
<GmmiProcedureMap>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜