home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / Newton Platform Info / Newton 2.0 Sample Code / Endpoints / Basic Serial-1 / Basic Serial.text < prev    next >
Encoding:
Text File  |  1996-03-08  |  23.2 KB  |  775 lines  |  [TEXT/MPS ]

  1. // Text of project Basic Serial written on 3/8/96 at 12:48
  2. // Beginning of text file Project Data
  3. // Copyright © 1994-1995 Apple Computer, Inc. All rights reserved
  4.  
  5. constant kAction_Connect := 'connect;
  6. constant kAction_Listen := 'listen;
  7.  
  8. constant kState_Disconnected := 0;    // ready-to-go (default state)
  9. constant kState_Listen := 1;        // preparation for (asynchronous) listen
  10. constant kState_Listening := 2;        // in-process of (asynchronous) listen
  11. constant kState_Connect := 3;        // preparation for (asynchronous) connect
  12. constant kState_Connecting := 4;    // in-process of (asynchronous) connect
  13. constant kState_Connected := 5;        // connected (requires disconnect)
  14. constant kState_Disconnecting := 6;    // in-process of (asynchronous) disconnect
  15.  
  16. constant kMessage_Disconnected := "Ready to connect…";
  17. constant kMessage_Listening := "Waiting for connection...";
  18. constant kMessage_Connecting := "Connecting...";
  19. constant kMessage_Connected := "Connected, awaiting disconnect...";
  20. constant kMessage_Disconnecting := "Disconnecting, please wait...";
  21. constant kMessage_ConnectFailed := "Connection not established; no response.";
  22. constant kMessage_BufferOverrun := "The communications data buffer was overrun and has been reset.";
  23. constant kMessage_Timeout := "The connection seems to have timed out.";
  24. constant kMessage_PortInUse := "Another application seems to be using the communications port.";
  25. constant kMessage_PortDoesNotExist := "The requested communications port does not exist.";
  26. constant kMessage_OutputTooFast := "Synchronous outputs are occuring too quickly; some data was not output.";
  27. // End of text file Project Data
  28. // Beginning of file protoDisconnectSlip
  29.  
  30. // Before Script for "_userproto000"
  31. // Copyright © 1994-1995 Apple Computer, Inc. All rights reserved.
  32.  
  33.  
  34. _userproto000 :=
  35.     {viewBounds: {left: 0, top: 0, right: 108, bottom: 44},
  36.      viewJustify: 80,
  37.      ReorientToScreen: ROM_DefRotateFunc,
  38.      _proto: @179
  39.     };
  40.  
  41. _view000 :=
  42.     {viewBounds: {left: 8, top: 8, right: 104, bottom: 40},
  43.      viewJustify: 2,
  44.      text:
  45.        "Disconnecting...
  46.        Please Wait...",
  47.      _proto: @218
  48.     };
  49. AddStepForm(_userproto000, _view000);
  50.  
  51.  
  52.  
  53.  
  54. constant |layout_protoDisconnectSlip| := _userproto000;
  55. // End of file protoDisconnectSlip
  56. // Beginning of file Basic Serial.t
  57.  
  58. // Before Script for "vMainApp"
  59. // Copyright © 1994-1995 Apple Computer, Inc. All rights reserved.
  60.  
  61.  
  62. vMainApp :=
  63.     {
  64.      viewSetupDoneScript:
  65.        func()
  66.        begin
  67.            :MSetEndPointState(fEndPointState);        // do NOT change the endpoint state -- just update any views that depend on it
  68.            if fEndPointState = kState_Disconnected then
  69.                :MMessage(kMessage_Disconnected);
  70.            else
  71.                :MMessage("");
  72.        end,
  73.      MMessage:
  74.        func(message)        // this routine can be called regardless of the value of SELF
  75.        begin
  76.            local appBaseView := GetRoot().(kAppSymbol);
  77.            
  78.            if call kViewIsOpenFunc with (appBaseView) then
  79.                begin    
  80.                    SetValue(appBaseView.vMessage, 'text, Clone(message));
  81.                    RefreshViews();
  82.                end
  83.        end,
  84.      viewFormat: 83951953,
  85.      viewQuitScript:
  86.        func()
  87.        begin
  88.            :MDisconnect();
  89.            RemoveSlot(GetRoot().(kAppSymbol), 'fEndPoint);
  90.        end,
  91.      MConnect:
  92.        func(connectAction)
  93.        begin
  94.            if fEndPointState <> kState_Disconnected then
  95.                return;
  96.            
  97.            fEndPoint.fConnectAction := connectAction;
  98.            fEndPoint.fQuiet := nil;
  99.            
  100.            if connectAction = kAction_Listen then
  101.                :MSetEndPointState(kState_Listen);
  102.            else if connectAction = kAction_Connect then
  103.                :MSetEndPointState(kState_Connect);
  104.            else
  105.                return;
  106.            
  107.            fEndPoint:MConnectAction();
  108.        end,
  109.      MDisconnectCompProc:
  110.        func(options, result)    // SELF is the endpoint frame
  111.        begin
  112.            try
  113.                :UnBind(nil)
  114.            onexception |evt.ex.comm| do
  115.                nil;
  116.            
  117.            try
  118.                :Dispose()
  119.            onexception |evt.ex.comm| do
  120.                nil;
  121.            
  122.            if fDisconnectSlip then begin
  123.                    fDisconnectSlip:Close();
  124.                    fDisconnectSlip := nil;
  125.                end;
  126.            
  127.            :MMessage(kMessage_Disconnected);
  128.            :MSetEndPointState(kState_Disconnected);
  129.            
  130.            if fPowerOffState then
  131.                begin
  132.                    fPowerOffState := nil;
  133.                    PowerOffResume(kAppSymbol);
  134.                end;
  135.            UnRegPowerOff(kAppSymbol);
  136.        end,
  137.      MShowSerialInfo:
  138.        DefConst('kSerialInfoOptions,
  139.                [
  140.                    {    label:        kCMOSerialChipSpec,
  141.                        type:        'option,
  142.                        opCode:        opGetCurrent,
  143.                        result:        nil,
  144.                        form:        'template,
  145.                        data:    {
  146.                            arglist:    [
  147.                                0,                    // chip location
  148.                                0,                    // features supported by this chip
  149.                                0,                    // output signals supported by chip
  150.                                0,                    // input signals supported by chip
  151.                                0,                    // parity supported
  152.                                0,                    // data and stop bits supported
  153.                                0,                    // serial chip type
  154.                                nil,                // chip in use
  155.                                0,                    // reserved
  156.                                0,                    // reserved
  157.                                0,                    // PCMCIA card CIS manufacturer ID
  158.                                0,    ],                // PCMCIA card CIS manufacturer ID info
  159.                            typelist:    ['struct,
  160.                                'ulong,                // fHWLoc
  161.                                'ulong,                // fSerFeatures
  162.                                'byte,                // fSerOutSupported
  163.                                'byte,                // fSerInSupported
  164.                                'byte,                // fParitySupport
  165.                                'byte,                // fDataStopBitSupport
  166.                                'byte,                // fUARTType
  167.                                'boolean,            // fChipNotInUse
  168.                                'byte,                // reserved
  169.                                'byte,                // reserved
  170.                                'short,                // fCIS_ManFID
  171.                                'short,    ],    },    },    // fCIS_ManFIDInfo
  172.                ]);
  173.        
  174.        func()
  175.        begin
  176.            if fEndPointState <> kState_Connected then
  177.                return :MNotify("Not connected.");
  178.            
  179.            local option := fEndPoint:Option(kSerialInfoOptions, nil);
  180.            if not option then
  181.                return;
  182.            
  183.            local result, message := "";
  184.        
  185.            if (result := option[0].result) <> nil then
  186.                message := message & "Get serial chip info failed: (" & NumberStr(result) & ")" & unicodeCR;
  187.            else
  188.                begin
  189.                    local serialChipType := option[0].data.arglist[6];
  190.                    message := message & "Serial Chip: " &
  191.                                (     if serialChipType = 0x00 then "8250"
  192.                                else if serialChipType = 0x01 then "16450"
  193.                                else if serialChipType = 0x02 then "16550"
  194.                                else if serialChipType = 0x20 then "8530"
  195.                                else if serialChipType = 0x21 then "6850"
  196.                                else if serialChipType = 0x22 then "6402"
  197.                                else if serialChipType = 0x23 then "Reserved"
  198.                                else "Unknown"    ) & " UART" & unicodeCR;
  199.                end;
  200.            
  201.            :MMessage(message);
  202.        end,
  203.      fEndPointOptions:
  204.        nil        // see MBuildConfigOptions & MConnectAction for more info
  205.        ,
  206.      MDisconnectAction:
  207.        func(fromState)        // SELF is the endpoint frame
  208.        begin
  209.            try
  210.                :Cancel(nil)
  211.            onexception |evt.ex.comm| do
  212.                nil;
  213.            
  214.            if fromState = kState_Connected then
  215.                try
  216.                    :Disconnect(nil, {    async:                true,
  217.                                        // reqTimeout:        3600,
  218.                                        completionScript:    func(ep, options, result)
  219.                                                            ep:MDisconnectCompProc(options, result),    })
  220.                onexception |evt.ex.comm| do
  221.                    :MDisconnectCompProc(nil, CurrentException().error);
  222.            else
  223.                :MDisconnectCompProc(nil, nil);
  224.        end,
  225.      MBuildConfigOptions:
  226.        func()        // SELF can be any frame that inherits to the app base view
  227.        begin
  228.            local options :=
  229.                [
  230.                    {    label:        kCMSAsyncSerial,
  231.                        type:        'service,
  232.                        opCode:        opSetRequired,
  233.                        result:        nil,    },
  234.                    
  235.                    {    label:        kCMOSerialHWChipLoc,
  236.                        type:        'option,
  237.                        opCode:        opSetRequired,
  238.                        result:        nil,
  239.                        form:        'template,
  240.                        data:    {
  241.                            argList: [
  242.                                vPort.clusterValue,        // kHWLocExternalSerial, kHWLocBuiltInIR, kHWLocPCMCIASlot1
  243.                                0,    ],
  244.                            typeList: ['struct,
  245.                                ['array, 'char, 4],
  246.                                'ulong,    ],    },    },
  247.                    
  248.                    {    label:        kCMOSerialIOParms,
  249.                        type:        'option,
  250.                        opCode:        opSetRequired,
  251.                        result:        nil,
  252.                        form:        'template,
  253.                        data:    {
  254.                            arglist:    [
  255.                                k1StopBits,                // 1 stop bit
  256.                                kNoParity,                // no parity bit
  257.                                k8DataBits,                // 8 data bits
  258.                                k19200bps,    ],            // date rate in bps
  259.                            typelist:    ['struct,
  260.                                'long,                    // stop bits
  261.                                'long,                    // parity
  262.                                'long,                    // data bits
  263.                                'long,    ],    },    },        // bps
  264.                    
  265.                    {    label:        kCMOInputFlowControlParms,
  266.                        type:        'option,
  267.                        opCode:        opSetRequired,
  268.                        result:        nil,
  269.                        form:        'template,
  270.                        data:    {
  271.                            arglist:    [
  272.                                unicodeDC1,             // xonChar    
  273.                                unicodeDC3,             // xoffChar    
  274.                                nil,                     // useSoftFlowControl    
  275.                                nil,                     // useHardFlowControl    
  276.                                0,                         // not needed; returned    
  277.                                0,    ],                     // not needed; returned    
  278.                            typelist:    ['struct,
  279.                                'char,                    // XON character
  280.                                'char,                    // XOFF character
  281.                                'boolean,                // software flow control
  282.                                'boolean,                // hardware flow control
  283.                                'boolean,                // hardware flow blocked
  284.                                'boolean,    ],    },    },    // software flow blocked
  285.                    
  286.                    {    label:        kCMOOutputFlowControlParms,
  287.                        type:        'option,
  288.                        opCode:        opSetRequired,
  289.                        result:        nil,
  290.                        form:        'template,
  291.                        data:    {
  292.                            arglist:    [
  293.                                unicodeDC1,             // xonChar    
  294.                                unicodeDC3,             // xoffChar    
  295.                                nil,                     // useSoftFlowControl    
  296.                                nil,                     // useHardFlowControl    
  297.                                0,                         // not needed; returned    
  298.                                0,    ],                     // not needed; returned    
  299.                            typelist:    ['struct,
  300.                                'char,                    // XON character
  301.                                'char,                    // XOFF character
  302.                                'boolean,                // software flow control
  303.                                'boolean,                // hardware flow control
  304.                                'boolean,                // hardware flow blocked
  305.                                'boolean,    ],    },    },    // software flow blocked
  306.                ];
  307.            
  308.            options;
  309.        end,
  310.      viewBounds: {left: -2, top: -2, right: 230, bottom: 310},
  311.      MExceptionHandler:
  312.        func(exceptionFrame)        // SELF is the endpoint frame
  313.        begin
  314.            if exceptionFrame
  315.            and exceptionFrame.data
  316.            and exceptionFrame.data <> -16005 then                // ignore -16005 (just the result of calling Cancel)
  317.                if exceptionFrame.data = -18003 then            // I/O buffer overrun
  318.                    begin
  319.                        AddDeferredCall(func(ep) ep:MResetConnection(true), [self]);
  320.                        :MNotifyError(exceptionFrame.data);
  321.                    end;
  322.                else begin                                        // handle all other (unexptected) exceptions by disconnecting the endpoint
  323.                        AddDeferredCall(func(ep) ep:MDisconnect(), [self]);
  324.                        :MNotifyError(exceptionFrame.data);
  325.                    end;
  326.            
  327.            true;
  328.        end,
  329.      _proto: @157,
  330.      MNotifyError:
  331.        func(error)
  332.        begin
  333.            if not error
  334.            or (fEndPoint and fEndPoint.fQuiet) then
  335.                return;
  336.            
  337.            if error = -10017 then
  338.                :MNotify(kMessage_OutputTooFast);
  339.            
  340.            else if error = -10078 then
  341.                :MNotify(kMessage_PortInUse);
  342.            
  343.            else if error = -16013 then
  344.                :MNotify(kMessage_Timeout);
  345.            
  346.            else if error = -16022 then
  347.                :MNotify(kMessage_PortDoesNotExist);
  348.            
  349.            else if error = -18003 then
  350.                :MNotify(kMessage_BufferOverrun);
  351.            
  352.            else if error = -38001 then
  353.                :MNotify(kMessage_ConnectFailed);
  354.            
  355.            else
  356.                :MNotify("An unexpected error has occured.  Error code = " & NumberStr(error));
  357.        end,
  358.      MResetConnection:
  359.        func(cancel)        // SELF is the endpoint frame
  360.        begin
  361.            if fEndPointState <> kState_Connected then
  362.                return;
  363.            
  364.            if cancel then
  365.                try
  366.                    :Cancel(nil)
  367.                onexception |evt.ex.comm| do
  368.                    nil;
  369.            
  370.            :SetInputSpec(fEndPointInputSpec);
  371.        end,
  372.      viewJustify: 80,
  373.      title: kAppName,
  374.      fEndPointState: kState_Disconnected,
  375.      fEndPointOutputSpec:
  376.        {
  377.            form:        'string,
  378.        },
  379.      MDisconnect:
  380.        func()
  381.        begin
  382.            if not fEndPoint
  383.            or fEndPointState <> kState_Connected
  384.            and fEndPointState <> kState_Connecting
  385.            and fEndPointState <> kState_Listening then
  386.                return;
  387.            
  388.            fEndPoint.fQuiet := true;        // supress user alerts and other interactions while disconnecting
  389.            
  390.            local fromState := fEndPointState;
  391.            :MSetEndPointState(kState_Disconnecting);
  392.            :MMessage(kMessage_Disconnecting);
  393.            
  394.            fEndPoint.fDisconnectSlip := BuildContext(GetLayout("protoDisconnectSlip"));
  395.            fEndPoint.fDisconnectSlip:Open();
  396.            
  397.            fEndPoint:MDisconnectAction(fromState);    
  398.        end,
  399.      fEndPoint: nil,
  400.      fEndPointInputSpec:
  401.        {
  402.            form:            'string,
  403.            termination:    {    endSequence:    [unicodeCR],    },
  404.            discardAfter:    256,
  405.            inputScript:    func(ep, data, terminator, options)
  406.                            ep:MInput(data),
  407.        },
  408.      viewSetupFormScript:
  409.        func()
  410.        begin
  411.            // make view no bigger than the original MP
  412.            local b := GetAppParams();
  413.            viewBounds := RelBounds( b.appAreaLeft,    b.appAreaTop,
  414.                                MIN( b.appAreaWidth, 240 ),
  415.                                MIN( b.appAreaHeight, 336 ));
  416.            
  417.            self.fEndPoint :=    {    _proto:                protoBasicEndPoint,
  418.                                    _parent:            self,
  419.                                    exceptionHandler:    MExceptionHandler,
  420.                                    fConnectAction:        nil,
  421.                                    fConnectAddress:    nil,
  422.                                    fDisconnectSlip:    nil,
  423.                                    fPowerOffState:        nil,
  424.                                    fQuiet:                nil,    };
  425.        end,
  426.      MOutput:
  427.        func(data)        // SELF can be any frame that inherits to the base app view
  428.        begin
  429.            if fEndPointState = kState_Connected then
  430.                try
  431.                    fEndPoint:Output(data & unicodeCR, nil, fEndPointOutputSpec)
  432.                onexception |evt.ex.comm| do
  433.                    :MExceptionHandler(CurrentException());
  434.            else
  435.                :MNotify("Not connected.");
  436.        end,
  437.      MSetEndpointState:
  438.        func(newState)        // this routine can be called regardless of the value of SELF
  439.        begin
  440.            local appBaseView := GetRoot().(kAppSymbol);
  441.            
  442.            //    NOTE: We must be absolutely certain fEndPointState gets created/overridden in the app base view frame!
  443.            appBaseView.fEndPointState := newState;
  444.            
  445.            if not call kViewIsOpenFunc with (appBaseView) then
  446.                return;
  447.            
  448.            if appBaseView.fEndPointState = kState_Disconnected then begin
  449.                    appBaseView.vConnect:Show();
  450.                    appBaseView.vListen:Show();
  451.                    appBaseView:MSetButtons("Connect", "Listen");
  452.                end;
  453.            
  454.            else if appBaseView.fEndPointState = kState_Listen then begin
  455.                    appBaseView.vConnect:Hide();
  456.                    appBaseView:MSetButtons("Listening", nil);
  457.                end;
  458.            
  459.            else if appBaseView.fEndPointState = kState_Listening then
  460.                    appBaseView:MSetButtons("Stop Listening", nil);
  461.            
  462.            else if appBaseView.fEndPointState = kState_Connect then begin
  463.                    appBaseView.vListen:Hide();
  464.                    appBaseView:MSetButtons("Connecting", nil);
  465.                end;
  466.            
  467.            else if appBaseView.fEndPointState = kState_Connecting then
  468.                    appBaseView:MSetButtons("Stop Connecting", nil);
  469.            
  470.            else if appBaseView.fEndPointState = kState_Connected then
  471.                    appBaseView:MSetButtons("Disconnect", nil);
  472.            
  473.            else if appBaseView.fEndPointState = kState_Disconnecting then
  474.                    appBaseView:MSetButtons("Disconnecting", nil);
  475.            
  476.            else
  477.                    appBaseView:MSetButtons("I Am Confused", nil);
  478.            
  479.            RefreshViews();
  480.        end,
  481.      MInput:
  482.        func(data)        // SELF is the endpoint frame
  483.        begin
  484.            PlaySound(ROM_PlinkBeep);
  485.            :MMessage(data);
  486.        end,
  487.      MConnectCompProc:
  488.        func(options, result)    // SELF is the endpoint frame
  489.        begin
  490.            if result then
  491.                begin
  492.                    :MNotifyError(result);
  493.                    :MDisconnect();
  494.                    return;
  495.                end;
  496.            
  497.            if fConnectAction = kAction_Listen then
  498.                try
  499.                    :Accept(nil, nil)
  500.                onexception |evt.ex.comm| do
  501.                    begin
  502.                        :MNotifyError(CurrentException().error);
  503.                        :MDisconnect();
  504.                        return;
  505.                    end;
  506.            
  507.            :MSetEndPointState(kState_Connected);
  508.            :MMessage(kMessage_Connected);
  509.            :MResetConnection(nil);
  510.            :MShowSerialInfo();
  511.        end,
  512.      MConnectAction:
  513.        func()        // SELF is the endpoint frame
  514.        begin
  515.            fEndPointOptions := :MBuildConfigOptions();
  516.            
  517.            try
  518.                :Instantiate(self, fEndPointOptions)
  519.            onexception |evt.ex.comm| do
  520.                begin
  521.                    :MNotifyError(CurrentException().error);
  522.                    :MSetEndPointState(kState_Disconnected);
  523.                    return;
  524.                end;
  525.            
  526.            try
  527.                :Bind(nil, nil)
  528.            onexception |evt.ex.comm| do
  529.                begin
  530.                    :MNotifyError(CurrentException().error);
  531.                    :MSetEndPointState(kState_Disconnected);
  532.                    :Dispose();
  533.                    return;
  534.                end;
  535.            
  536.            RegPowerOff(kAppSymbol,
  537.                        func(what, why)        // we create the closure here so as to set up SELF as the endpoint frame in the closure
  538.                        begin
  539.                            if what = 'okToPowerOff then
  540.                                begin
  541.                                    if why <> 'idle                                    // keep the unit awake whenever we're connected
  542.                                    or fEndPointState = kState_Disconnected then    // unless the user or an application explicitly
  543.                                        return true;                                // wants it to sleep
  544.                                end;
  545.                            
  546.                            else if what = 'powerOff then
  547.                                begin
  548.                                    if why <> 'idle                                    // if we simply must go to sleep but we're still
  549.                                    and fEndPointState <> kState_Disconnected then    // connected then begin the disconnect process
  550.                                        begin
  551.                                            fPowerOffState := 'holdYourHorses;        // set a flag to indicate we're powering down
  552.                                            :MDisconnect();
  553.                                            return 'holdYourHorses;
  554.                                        end;
  555.                                end;
  556.                            
  557.                            nil;    // ALWAYS return nil here!
  558.                        end    );
  559.            
  560.            try
  561.                begin
  562.                    if fConnectAction = kAction_Listen then
  563.                        begin
  564.                            :MSetEndPointState(kState_Listening);
  565.                            :MMessage(kMessage_Listening);
  566.                            :Listen( nil,
  567.                                    {    async:                true,
  568.                                        reqTimeout:            90000,    // 90 seconds -- for DEMO purposes only
  569.                                        completionScript:    func(ep, options, result)
  570.                                                            ep:MConnectCompProc(options, result)    });
  571.                        end;
  572.                    else if fConnectAction = kAction_Connect then
  573.                        begin
  574.                            :MSetEndPointState(kState_Connecting);
  575.                            :MMessage(kMessage_Connecting);
  576.                            :Connect( [ fConnectAddress ],
  577.                                    {    async:                true,
  578.                                        reqTimeout:            45000,    // 45 seconds -- for DEMO purposes only
  579.                                        completionScript:    func(ep, options, result)
  580.                                                            ep:MConnectCompProc(options, result),    });
  581.                        end;
  582.                end
  583.            onexception |evt.ex.comm| do
  584.                begin
  585.                    :MNotifyError(CurrentException().error);
  586.                    :MDisconnect();
  587.                end;
  588.        end,
  589.      debug: "vMainApp",
  590.      MNotify:
  591.        func(message)
  592.        begin
  593.            GetRoot():Notify(kNotifyAlert, kAppName, message);    // no longer necessary to EnsureInternal params
  594.        end,
  595.      MSetButtons:
  596.        func(connectText, listenText)
  597.        begin
  598.            SetValue(vConnect, 'text, connectText);
  599.            if listenText then
  600.                SetValue(vListen, 'text, listenText);
  601.            else
  602.                SetValue(vListen, 'text, connectText);
  603.        end
  604.     };
  605.  
  606. _view001 :=
  607.     {viewBounds: {left: 8, top: 16, right: 224, bottom: 32},
  608.      text: "Messages & Received Data:",
  609.      _proto: @218
  610.     };
  611. AddStepForm(vMainApp, _view001);
  612.  
  613.  
  614.  
  615. vMessage :=
  616.     {viewBounds: {left: 9, top: 33, right: 223, bottom: 119},
  617.      viewJustify: 0,
  618.      viewFormat: 337,
  619.      viewFont: simpleFont12,
  620.      text: "",
  621.      viewClickScript:
  622.        func(unit)
  623.        begin
  624.            SetValue(self, 'text, "");
  625.            true;
  626.        end,
  627.      viewFlags: 515,
  628.      debug: "vMessage",
  629.      _proto: @218
  630.     };
  631. AddStepForm(vMainApp, vMessage);
  632. StepDeclare(vMainApp, vMessage, 'vMessage);
  633.  
  634.  
  635.  
  636. _view002 :=
  637.     {viewBounds: {left: 8, top: 128, right: 168, bottom: 144},
  638.      text: "Message To Send:",
  639.      _proto: @218
  640.     };
  641. AddStepForm(vMainApp, _view002);
  642.  
  643.  
  644.  
  645. vInputArea :=
  646.     {viewFlags: 64001,
  647.      viewFormat: 12625,
  648.      viewLineSpacing: 20,
  649.      viewFont: 18434,
  650.      viewBounds: {left: 9, top: 145, right: 167, bottom: 195},
  651.      text: "This is a test!",
  652.      debug: "vInputArea",
  653.      viewClass: 81
  654.     };
  655. AddStepForm(vMainApp, vInputArea);
  656. StepDeclare(vMainApp, vInputArea, 'vInputArea);
  657.  
  658.  
  659.  
  660. vConnect :=
  661.     {
  662.      buttonClickScript:
  663.        func()
  664.        begin
  665.            if fEndPointState = kState_Disconnected then
  666.                :MConnect(kAction_Connect);
  667.            else
  668.                :MDisconnect();
  669.        end,
  670.      viewBounds: {left: 122, top: 214, right: 222, bottom: 234},
  671.      text: ""
  672.      ,
  673.      debug: "vConnect",
  674.      _proto: @226
  675.     };
  676. AddStepForm(vMainApp, vConnect);
  677. StepDeclare(vMainApp, vConnect, 'vConnect);
  678.  
  679.  
  680.  
  681. vListen :=
  682.     {
  683.      buttonClickScript:
  684.        func()
  685.        begin
  686.            if fEndPointState = kState_Disconnected then
  687.                :MConnect(kAction_Listen);
  688.            else
  689.                :MDisconnect();
  690.        end,
  691.      viewBounds: {left: 122, top: 242, right: 222, bottom: 262},
  692.      text: ""
  693.      ,
  694.      debug: "vListen",
  695.      _proto: @226
  696.     };
  697. AddStepForm(vMainApp, vListen);
  698. StepDeclare(vMainApp, vListen, 'vListen);
  699.  
  700.  
  701.  
  702. vSend :=
  703.     {
  704.      buttonClickScript:
  705.        func()
  706.        begin
  707.            :MOutput(if vInputArea.text then vInputArea.text else "");
  708.        end,
  709.      viewBounds: {left: 178, top: 146, right: 222, bottom: 166},
  710.      text: "Send",
  711.      debug: "vSend",
  712.      _proto: @226
  713.     };
  714. AddStepForm(vMainApp, vSend);
  715. StepDeclare(vMainApp, vSend, 'vSend);
  716.  
  717.  
  718.  
  719. _view003 :=
  720.     {viewBounds: {left: 8, top: 204, right: 112, bottom: 220},
  721.      text: "Serial Port To Use:",
  722.      _proto: @218
  723.     };
  724. AddStepForm(vMainApp, _view003);
  725.  
  726.  
  727.  
  728. vPort :=
  729.     {viewBounds: {left: 16, top: 220, right: 112, bottom: 276},
  730.      clusterValue: kHWLocExternalSerial,
  731.      debug: "vPort",
  732.      _proto: @203
  733.     };
  734. AddStepForm(vMainApp, vPort);
  735. StepDeclare(vMainApp, vPort, 'vPort);
  736.  
  737. _view004 :=
  738.     {buttonValue: kHWLocExternalSerial,
  739.      viewBounds: {left: 0, top: 0, right: 96, bottom: 16},
  740.      text: "RS422 (Port A)",
  741.      _proto: @202
  742.     };
  743. AddStepForm(vPort, _view004);
  744.  
  745.  
  746.  
  747. _view005 :=
  748.     {buttonValue: kHWLocBuiltInIR,
  749.      viewBounds: {left: 0, top: 16, right: 96, bottom: 32},
  750.      text: "IR (Port B)",
  751.      _proto: @202
  752.     };
  753. AddStepForm(vPort, _view005);
  754.  
  755.  
  756.  
  757. _view006 :=
  758.     {buttonValue: kHWLocPCMCIASlot1,
  759.      viewBounds: {left: 0, top: 32, right: 96, bottom: 48},
  760.      text: "Serial Card In Slot 1",
  761.      _proto: @202
  762.     };
  763. AddStepForm(vPort, _view006);
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770. constant |layout_Basic Serial.t| := vMainApp;
  771. // End of file Basic Serial.t
  772.  
  773.  
  774.  
  775.