--+-----------------------------------------------------------------------------+
--+                        SOHO Project -- Control File
--+                        ----------------------------
--+
--+ Name        : MDI_IPCSLD , !Print 
--+ Purpose     : (See Procedure headers)
--+                    
--+ Sub_system  : PLM
--+ Drawing No  : 3137-ZA042-SCB  Issue : A/00
--+ Project No  : SH-MAR-SW-70224
--+ Origin      : UK 
--+ Author      : Ph. IATRINO
--+-----------------------------------------------------------------------------+
--+ Principle   :
--+ ---------
--+   Holding CF for a group of related Procedures, originally written in
--+   MDI's own Control File language.
--+
--+ Passed parameters :
--+ -----------------
--+   !Proc_s   : Name of required Procedure.
--+   !Print    : CF Log print indicator ( "yes" (default) | "no" ).
--+
--+ Prerequisites :
--+ -------------
--+    Control File MDI_ON must have been successfully performed.
--+
--+ History :
--+ -------
--+   Issue SIC Note Time   Date      Name/Updates
--+   +---+ +------+ +---+  +------+ +------------------------------------------+
--+   1/00           10:57   8/10/94  Ph. IATRINO     Creation with MDI Updates.
--+   1/01    611    17:02  21/06/95  Ph. IATRINO     -- New On Board S/W .
--+
--+-----------------------------------------------------------------------------+
Common
Var
    Bool        !GZ_Window              -- Open window flag (on CF start)
    Bool        !GZ_Spool               -- Automatic Spool (at End of CF exec)
    Bool        !GZ_Halt                -- Check Error flag (to halt if error)
    Bool        !GZ_Test                -- Execution test flag (to not send TC)
    Int         !GZ_Trace               -- Level of Trace (TBD)

    Int         !GM_Conf                -- MDI Configuration
    Int         !GM_NbErr               -- MDI Global Error Count
    Int         !GM_I0
    Int         !GM_I9
End Common
--------------------------------------------------------------------------------+
Extern
    Cfile       PLM_BLOCK
    Group       MWTM , PWP12TM

    Procedure   AskReal , AskStr , AskInt
    Procedure   CheckAna , CheckDig , CheckReg
    Procedure   CheckArgReal , CheckArgStr , CheckArgInt
    Procedure   DispMess
    Procedure   ExConnect , ExDisconnect
    Procedure   ExitCF
    Procedure   Message
    Procedure   OpenWindow
    Procedure   PrintAna , PrintDig , PrintReg , PrintParam
    Procedure   SendCommand 
    Procedure   Lower , Upper
    Procedure   WaitAna , WaitDig , WaitReg , WaitTime

End Extern
--------------------------------------------------------------------------------+
Program MDI_IPCSLD , Unique

--  IP Control Store Load patch file for DEP v10:0a

Defarg
    Str(3)      !Print   = "yes"
End Defarg

Var
    Str( 3)     !ExpName = "MDI"
    Int         !NbErr   = 0
    Str(49)     !Title   = " "
    str(80)     !S       = &80s(" ")
    Str(10)     !Phase     = " "
    Str(80)     !Question  = " "

    Int         !LM_I0     = 0
    int         !Cmd_Data(30)

Main

    @OpenWindow()

    !Title = "-Start of IPCSLD Sequence."
    @Message( "DCL" , "date" , !ExpName , !Phase , !Title , *!S )

    @varcmd ("MBDPML", "3990,0," + \
    "0x00b8,0xe910,0x0023,0xb0bb,0xff8a,0xbbe3,0x8921,0xe3ff,0xe3bb,0xff90")

    @varcmd ("MBDPML", "3990,20," + \
    "0xbbe3,0x90f5,0xe3ff,0x0cbb,0xff91,0xbbe3,0x9146,0xe3ff,0x61bb,0xff91")

    @varcmd ("MBDPML", "3990,40," + \
    "0xa1e3,0x4a74,0x020d,0xa300,0x4a74,0x74b8,0x504a,0x21b8") 

    @varcmd ("MBDPML", "3990,56," + \
    "0x5000,0xc9e8,0x59ff,0x3359,0xa3c0,0x0098,0x96a3,0xb000,0xa200,0x008f")

    @varcmd ("MBDPML", "3990,76," + \
    "0x8ea2,0xc700,0x0c06,0x0000,0xc720,0x0a06,0x0000,0xe820,0x0019,0x023d")

    @varcmd ("MBDPML", "3990,96," + \
    "0x7400,0xa108,0x4a6c,0x0b48,0x74c0,0xb8f0,0x0000,0xe850") 

    @varcmd ("MBDPML", "3990,112," + \
    "0xffb2,0xe859,0xff95,0x55c3,0xec8b,0xec83,0x5606,0xc757,0xfa46,0x0001")

    @varcmd ("MBDPML", "3990,132," + \
    "0xff33,0x3e83,0x0098,0x7501,0xbf05,0x0001,0x4deb,0x2cb8,0x5001,0x81e8")

    @varcmd ("MBDPML", "3990,152," + \
    "0x59ff,0x98a3,0x3d00,0x0004,0x0b75,0x06b8,0x5000,0x76e8") 

    @varcmd ("MBDPML", "3990,168," + \
    "0x59ff,0x02bf,0x8300,0x983e,0xff00,0x2175,0x43be,0xa100,0x0096,0x0eff")

    @varcmd ("MBDPML", "3990,188," + \
    "0x0096,0xc00b,0x0c7f,0xffbf,0x83ff,0xfa7e,0x7401,0xbe03,0x0018,0xe856")

    @varcmd ("MBDPML", "3990,208," + \
    "0xff4d,0xeb59,0xc706,0x9606,0x0a00,0x0b00,0x74ff,0x83a7") 

    @varcmd ("MBDPML", "3990,224," + \
    "0x01ff,0x0374,0x81e9,0xff00,0xfa76,0x91e8,0x5900,0xc00b,0x0574,0x15be")

    @varcmd ("MBDPML", "3990,244," + \
    "0xeb00,0x836c,0xfa7e,0x7501,0xba0b,0x000e,0xda8b,0x478b,0x890e,0xfc46")

    @varcmd ("MBDPML", "3990,264," + \
    "0x7e83,0x04fa,0x4f76,0x468b,0x2dfa,0x0005,0xe0d1,0xe0d1") 

    @varcmd ("MBDPML", "3990,280," + \
    "0xe0d1,0x4689,0x33fe,0x8bf6,0xb1d6,0xd304,0x81e2,0x0ec2,0x8b00,0xfe46")

    @varcmd ("MBDPML", "3990,300," + \
    "0xc603,0x463b,0x73fc,0xff0b,0x0c36,0x8b00,0xfe46,0xc603,0x0ceb,0x36ff")

    @varcmd ("MBDPML", "3990,320," + \
    "0x000a,0x468b,0x03fe,0x2bc6,0xfc46,0x04b1,0xe0d3,0x1e50") 

    @varcmd ("MBDPML", "3990,336," + \
    "0xe852,0x0120,0xc483,0x4608,0xfe83,0x7208,0xbec2,0x0006,0x46ff,0x56fa")

    @varcmd ("MBDPML", "3990,356," + \
    "0xb8e8,0x59fe,0x06c7,0x0098,0x0000,0xff83,0x7501,0xe903,0xff0e,0xc78b")

    @varcmd ("MBDPML", "3990,376," + \
    "0x5e5f,0xe58b,0xc35d,0x8b55,0x83ec,0x04ec,0x5756,0xf633") 

    @varcmd ("MBDPML", "3990,392," + \
    "0x02b8,0x5000,0x8be8,0x59fe,0x4689,0x3dfe,0xffff,0x0175,0xb846,0x0002")

    @varcmd ("MBDPML", "3990,412," + \
    "0xe850,0xfe7a,0x8959,0xfc46,0xff3d,0x75ff,0x4601,0xff33,0x19eb,0x02b8")

    @varcmd ("MBDPML", "3990,432," + \
    "0x5000,0x65e8,0x59fe,0x98a3,0x3d00,0xffff,0x0175,0xa046") 

    @varcmd ("MBDPML", "3990,448," + \
    "0x0098,0x8588,0x000e,0x8147,0x80ff,0x7d00,0x0b04,0x74f6,0xb8dd,0x0002")

    @varcmd ("MBDPML", "3990,468," + \
    "0xe850,0xfe42,0xa359,0x0098,0xff3d,0x75ff,0x4601,0x3e8b,0x0098,0xe781")

    @varcmd ("MBDPML", "3990,488," + \
    "0x00ff,0x08b1,0xe7d3,0x02b8,0x5000,0x25e8,0x59fe,0x98a3") 

    @varcmd ("MBDPML", "3990,504," + \
    "0x3d00,0xffff,0x0175,0xa146,0x0098,0xff25,0x0b00,0x8bf8,0xfe46,0x4603")

    @varcmd ("MBDPML", "3990,524," + \
    "0x25fc,0x00ff,0x98a3,0x8100,0x983e,0xff00,0x7500,0x8b0b,0x0446,0xff25")

    @varcmd ("MBDPML", "3990,544," + \
    "0x3b00,0xfe46,0x0174,0xb846,0x000e,0x5750,0x0fe8,0x5900") 

    @varcmd ("MBDPML", "3990,560," + \
    "0x0b59,0x74c0,0x4601,0xc68b,0x5e5f,0xe58b,0xc35d,0x8b55,0x56ec,0x8b57")

    @varcmd ("MBDPML", "3990,580," + \
    "0x0676,0xfe8b,0xc781,0x0082,0xc033,0x08b9,0x8a00,0xd01c,0xd1d3,0x73d0")

    @varcmd ("MBDPML", "3990,600," + \
    "0x3503,0x1021,0xf5e2,0x3b46,0x75fe,0x8beb,0x0456,0x4689") 

    @varcmd ("MBDPML", "3990,616," + \
    "0x2b06,0x74c2,0xb803,0xffff,0x5e5f,0xc35d,0x8b55,0x57ec,0x9c56,0x061e")

    @varcmd ("MBDPML", "3990,636," + \
    "0x8bfc,0x0a46,0xc08e,0x7e8b,0x8b08,0x0646,0xd88e,0x768b,0xb904,0x0010")

    @varcmd ("MBDPML", "3990,656," + \
    "0xa5f3,0x1f07,0x5e9d,0x5d5f,0x00c3,0x0000,0x0000,0x0000") 

    @varcmd ("MBDPML", "0x1000,0,0x6f64,0x656e,0x000a,0x0008,0x009a") 

    @varcmd ("MBDPML", "0x1000,0x4b3e,0x201 2,0xff00,0x60ff,0x1f5")

    !Cmd_Data(0) = 0x0001

    PERFORM/NO PLM_BLOCK , "MDI" , 0x02 , !Cmd_Data() , 1

    !GM_NbErr = !GM_NbErr + !NbErr

    !Title = "-End of IPCSLD Sequence."
    @Message( "DCL" , "date" , !ExpName , !Phase , !Title , *!S )

    @ExitCF (!NbErr)
    @PrintCF ( !ExpName , !Print )
  Return !Rstat
End Program
-------------------------------------------------------------------------------+
Procedure varcmd( Str(10) !Cmd_name , Str(80) !Cmd_data )
Var
    Str(1)    !Expt_s
    Int       !Code_i
    Int       !Cmd_data_i(30)
    Int       !No_of_cmds_i
    Int       !Data_len_i
    Str(10)   !Data_item_s
    Int       !Commas_i
    Int       !Count
    Int       !Char_pos 
    Str(1)    !Char
    Str(49)   !Title     = " "
    Str(80)   !Cmd_data_s
    Str(80)   !S = &80s("")

Main
    !Expt_s = Extract( !Cmd_name , 1 , 1 )
    If !Expt_s <> "M" Then
        !Title = "*ERROR: Non-MDI Command " + !Cmd_name
        @Message( "DC", "time", "MDI", " ", !Title , *!S)
        Halt
        !Title = "+Operator CONTinue "
        @Message( "DC", "time", "MDI", " ", !Title , *!S)
        Return
    End If

    Select !Cmd_name
    Case "MBIPCMD"
        !Code_i = 0x0E
        !No_of_cmds_i = 0

    Case "MBIPTBL"
        !Code_i = 0x0F
        !No_of_cmds_i = 0

    Case "MBIPMACL"
        !Code_i = 0x11
        !No_of_cmds_i = 0

    Case "MBIPLDIN"
        !Code_i = 0x12
        !No_of_cmds_i = 1
        !Cmd_data_i(0) = 4

    Case "MBDPML"
        !Code_i = 0x0A
        !No_of_cmds_i = 0

    Case "MBDPCONF"
        !Code_i = 0x1D
        !No_of_cmds_i = 0

    Default
        !Title = "*ERROR: Unrecognised Command " + !Cmd_name
        @Message( "DC", "time", "MDI", " ", !Title , *!S)
        Halt
        !Title = "+Operator CONTinue "
        @Message( "DC", "time", "MDI", " ", !Title , *!S)
        Return
    End Select

    !Cmd_data_s = !Cmd_data + ","
    !Data_len_i = Len( !Cmd_data_s )
    !Commas_i = 0

    For !Char_pos = 1 to !Data_len_i
        !Char = Extract( !Cmd_data_s , !Char_pos , 1 )
        If !Char = "," Then
           !Commas_i = !Commas_i + 1
        End If
    End For

    For !Count = 1 To !Commas_i
        !Data_item_s = Splitstr( !Cmd_data_s , "," , !Count )
        !Cmd_data_i( !No_of_cmds_i ) = Int( Val( !Data_item_s ) )
        !No_of_cmds_i = !No_of_cmds_i + 1
    End For

    PERFORM/NO PLM_BLOCK , "MDI" , !Code_i , !Cmd_data_i() , !No_of_cmds_i
    @WaitTime    ( "00h00m02s" , *!S )

Return
End Procedure
-------------------------------------------------------------------------------+
Procedure PrintCF( str(3) !ExpName, str(8) !Print)
--. Print the control file log file if required by !Print ;
--.  - using the 'Spool' statement if the variable !GZ_Spool is TRUE,
--.  - using the dialog box window if the variable !GZ_Spool is FALSE.
--. 
  Var
    str(80) !S = &80s("")

  Main
    If !Print = "yes" Then
     If !GZ_Spool = TRUE  Then
        Spool CF
     Else   
        Cflog
        @Message( "DC", "date", !ExpName, " ", \
                  "++++Print the CFLog, then type CONT+++", *!S)
        Halt
        @Message( "DC", "date", !ExpName, " ", \
                  "+Operator continue.", *!S)
     End If
    End If
  Return
End Procedure
-------------------------------------------------------------------------------+