home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-22 | 22.3 KB | 857 lines | [TEXT/MPS ] |
- // Constants good to have.
- constant kAppSymbol := '|ADSP:PIEDTS|;
- constant kAppName := "ADSP";
-
- // We don't use any install or remove scripts here
-
- // ---- End Project Data ----
-
- // ---- Beginning of Print templates ----
-
- // ---- End of Print templates ----
-
- ADSPSample :=
- {title: "ADSP Sample",
- viewBounds: {top: 0, left: 0, right: 240, bottom: 336},
- InitConnection:
- func()
- begin
- SetValue(StatusArea,'text, "Connecting...\n");
- RefreshViews();
-
- ep := {_proto: baseEndpoint, _parent: self}; // make a RAM copy so we can modify it
-
- local err := ep:Instantiate(ep, nil);
-
- if err then
- begin
- EnsureInternal(:Notify(kNotifyAlert, "ADSP Sample", "Sorry, can't open AppleTalk!"));
- SetValue(StatusArea, 'text, "Unable to initialize...");
- return;
- end;
-
- err := ep:Connect(LiveremoteAddress, nil); // always check for results from Connect
-
- if err then
- begin
- EnsureInternal(:Notify(kNotifyAlert, "ADSP Sample", "Couldn't connect..." & NumberStr(err)));
- SetValue(StatusArea, 'text, "Unable to connect...");
- return;
- end;
-
- ep.myBase := _parent;
- ep:SetInputSpec(ep.doInput); // set up first inputSpec
- SetValue(StatusArea,'text, "Connected, Waiting for Disconnect...");
- connected := true;
- end,
- ReleaseConnection:
- func()
- begin
- if (connected) then
- begin
- ep.nextInputSpec := nil; // no more input
- ep:SetInputSpec(nil); // kill the current inputSpec
- ep:Abort(); // asynchronously abort any pending I/O
-
- // must use a delayed action to dispose
- AddDelayedAction(DisposeConnection, [], 100);
- end;
- end,
- PutDataInStatusArea:
- func(s)
- begin
- SetValue(StatusArea, 'text, s);
- end,
- PutDataInReceivedArea:
- func(s)
- begin
- SetValue(ReceivedArea, 'text, s);
- end,
- viewSetupDoneScript:
- func()
- begin
- ActiveConnection := 0;
- ActiveListenConnection := 0;
-
- LiveRemoteAddress := DeepClone(remoteAddress); // clone so we could modify this one
- end,
- SendDataInSendField:
- func()
- begin
- ep:Output(SendDataField.entryLine.text, kMore);
- ep:Output([unicodeCR,unicodeLF], kMore);
- ep:FlushOutput();
- end,
- connected: nil,
- remoteAddress:
- {
- type: 'address,
- label: kCMARouteLabel,
- opCode: opSetRequired,
- data : {
- addressType: kNamedAppleTalkAddress,
- addressData: "Sandvik:ADSP@RD5/2" // hard coded value, change if needed
- }
- },
- baseEndpoint:
- {
- //_proto: @174, // ROM protoEndpoint
- _proto: protoEndpoint, // NTK protoEndpoint
-
- configOptions:
- [
- // adsp tool
- { label: "atlk", type: 'service, opCode: opSetRequired },
-
- { label: "atlk", type: 'option, opCode: opSetRequired,
- data: [97, 100, 115, 112] }, // 'adsp' (can't use "adsp" because it includes a null terminator)
-
- { label: "endp", type: 'option, opCode: opSetRequired,
- data: "TADSPEndpoint" },
- ],
-
- myBase: nil,
-
- // All endpoint related exceptions end up here, catch them.
- exceptionHandler: func(exception)
- begin
- EnsureInternal(GetRoot():Notify(kNotifyAlert, "ADSP Sample", "Exception: " & exception.data));
- return true;
- end,
-
- doInput:
- {
- InputForm: 'string,
- endCharacter: unicodeCR,
-
- InputScript: func(endpoint, s)
- begin
- Perform(endpoint.myBase, 'PutDataInStatusArea, [Clone("Data Received...")]);
-
- Perform(endpoint.myBase, 'PutDataInReceivedArea, [Clone(s)]);
-
- end,
-
- discardAfter: 200,
- },
- },
- ep: nil,
- DisposeConnection:
- func()
- begin
- ep:Disconnect();
- ep:Dispose();
- connected := nil;
- :PutDataInStatusArea("Ready to connect...");
- end,
- LiveRemoteAddress:
- // the ADSP address frame, in memory, so we could modify this one
- nil,
- _proto: protoApp,
- debug: "ADSPSample"
- };
-
- _view000 := /* child of ADSPSample */
- {viewFlags: 1,
- viewFormat: 304,
- viewBounds: {left: 11, top: 219, right: 233, bottom: 297},
- viewclass: 74
- };
-
-
-
- StatusArea := /* child of ADSPSample */
- {text: "",
- viewBounds: {left: 10, top: 26, right: 232, bottom: 64},
- viewJustify: 0,
- viewFormat: 67436880,
- _proto: protoStaticText,
- debug: "StatusArea"
- };
- // View StatusArea is declared to ADSPSample
-
-
-
- ReceivedArea := /* child of ADSPSample */
- {text: "",
- viewBounds: {left: 10, top: 82, right: 232, bottom: 176},
- viewJustify: 0,
- viewFormat: 67436880,
- _proto: protoStaticText,
- debug: "ReceivedArea"
- };
- // View ReceivedArea is declared to ADSPSample
-
-
-
- Status := /* child of ADSPSample */
- {text: "Status",
- viewBounds: {left: 18, top: 18, right: 114, bottom: 34},
- viewTransferMode: 0
- ,
- _proto: protoStaticText,
- debug: "Status"
- };
-
-
-
- Received := /* child of ADSPSample */
- {text: "Received Data",
- viewBounds: {left: 18, top: 74, right: 114, bottom: 90},
- viewTransferMode: 0
- ,
- _proto: protoStaticText,
- debug: "Received"
- };
-
-
-
- Connect := /* child of ADSPSample */
- {text: "Connect",
- buttonClickScript:
- func()
- begin
- if not connected then
- :InitConnection();
- else
- EnsureInternal(:Notify(kNotifyAlert, "ADSP Sample", "already connected!"));
- end,
- viewBounds: {left: 12, top: 188, right: 120, bottom: 208},
- viewSetupDoneScript:
- func()
- begin
- :PutDataInStatusArea("Ready to Connect...");
- end,
- _proto: protoTextButton,
- debug: "Connect"
- };
- // View Connect is declared to ADSPSample
-
-
-
- Disconnect := /* child of ADSPSample */
- {text: "Disconnect",
- buttonClickScript:
- func()
- begin
- if connected then
- begin
- :ReleaseConnection();
- :PutDataInStatusArea("Disconnecting...");
- end;
- else
- EnsureInternal(:Notify(kNotifyAlert, "ADSP Sample", "not connected!"));
- end,
- viewBounds: {left: 132, top: 188, right: 232, bottom: 208},
- viewQuitScript:
- func()
- begin
- :ReleaseConnection();
- end,
- _proto: protoTextButton,
- debug: "Disconnect"
- };
- // View Disconnect is declared to ADSPSample
-
-
-
- SendDataField := /* child of ADSPSample */
- {viewBounds: {top: 226, left: 18, right: 226, bottom: 290},
- viewFormat: 256,
- viewlinespacing: 16,
- label: "Data:",
- textSetup:
- func()
- begin
- return "this is a test";
- end,
- indent: 80,
- _proto: protoLabelInputLine,
- debug: "SendDataField"
- };
- // View SendDataField is declared to ADSPSample
-
-
-
- SendButton := /* child of ADSPSample */
- {text: "Send",
- buttonClickScript:
- func()
- begin
- if connected then
- :SendDataInSendField();
- else
- EnsureInternal(:Notify(kNotifyAlert, "ADSP Sample", "not connected!"));
- end,
- viewBounds: {left: 36, top: 308, right: 104, bottom: 328},
- _proto: protoTextButton,
- debug: "SendButton"
- };
- // View SendButton is declared to ADSPSample
-
-
-
- configureButton := /* child of ADSPSample */
- {text: "Configure",
- buttonClickScript:
- func()
- begin
- // Open a view that will ask for the type and name info, and the zone info as well.
- ConfigureView:Open();
- end,
- viewBounds: {left: 128, top: 308, right: 196, bottom: 328},
- _proto: protoTextButton,
- debug: "configureButton"
- };
-
-
-
- ConfigureView := /* child of ADSPSample */
- {viewBounds: {left: 0, top: 46, right: 228, bottom: 194},
- viewSetupFormScript:
- func()
- begin
- addressData := GetRoot().|ADSP:PIEDTS|.LiveRemoteAddress.data.addressData;
-
- // Start munging so the stuff looks real
- // First the zone.
- local pos := StrPos(addressData, "@", 0);
- ADSPZone := SubStr(addressData, pos+1, 32);
-
- // Then the name.
- local pos2 := StrPos(addressData, ":", 0);
- ADSPName := SubStr(addressData, 0, pos2);
-
- // Finally the type
- ADSPType := SubStr(addressData, pos2 + 1, pos - pos2 - 1);
-
- end,
- ADSPName: nil,
- ADSPType: nil,
- ADSPZone: nil,
- adressData: nil,
- viewQuitScript:
- func()
- begin
- // The Deeds are done, update the address info in the app base view.
- GetRoot().|ADSP:PIEDTS|.LiveRemoteAddress.data.addressData :=
- Stringer([ADSPName, ":", ADSPType, "@", ADSPZone]);
- end,
- _proto: protoFloatNGo,
- debug: "ConfigureView"
- };
- // View ConfigureView is declared to ADSPSample
-
- mainLabel := /* child of ConfigureView */
- {text: "Specify ADSP Server info:",
- viewBounds: {left: 32, top: 8, right: 216, bottom: 32},
- _proto: protoStaticText,
- debug: "mainLabel"
- };
-
-
-
- NameInput := /* child of ConfigureView */
- {viewBounds: {left: 0, top: 40, right: 224, bottom: 64},
- label: "Server Name:",
- viewSetupFormScript:
- func()
- begin
- // get the address data string
- local x := GetRoot().kAppSymbol.liveRemoteAddress.data.addressData;
-
- //SetValue(entry, 'text, GetRoot()kAppSymbol.LiveRemoteAddress
- end,
- textSetup:
- func()
- begin
- // Return the ADSP name stored in the parent view for default setup.
- return ADSPName;
- end,
- textChanged:
- func()
- begin
- // We did something with the values, update parent.
- ADSPName := entryline.text;
- end,
- _proto: protoLabelInputLine,
- debug: "NameInput"
- };
- // View NameInput is declared to ConfigureView
-
-
-
- TypeInput := /* child of ConfigureView */
- {viewBounds: {left: 0, top: 72, right: 224, bottom: 96},
- label: "Server Type:",
- textSetup:
- func()
- begin
- // Return the ADSP Type in the parent view as the default value.
- return ADSPType;
- end,
- textChanged:
- func()
- begin
- // We did something with the values, update parent.
- ADSPType := entryline.text;
- end,
- _proto: protoLabelInputLine,
- debug: "TypeInput"
- };
- // View TypeInput is declared to ConfigureView
-
-
-
- ZoneInput := /* child of ConfigureView */
- {viewBounds: {left: 0, top: 104, right: 224, bottom: 128},
- label: "Server Zone:",
- textSetup:
- func()
- begin
- // Return the ADSP Zone string stored in the parent view as the default value.
- return ADSPZone;
- end,
- textChanged:
- func()
- begin
- // We did something with the values, update parent.
- ADSPZone := entryline.text;
- end,
- _proto: protoLabelInputLine,
- debug: "ZoneInput"
- };
- // View ZoneInput is declared to ConfigureView
-
-
-
-
-
-
- // ---- Beginning of non-used User Protos ----
-
- // ---- End of non-used User Protos ----
-
-
-
- // ---- Beginning of section for non used Layout files ----
-
- ADSPSample :=
- {title: "ADSP Sample",
- viewBounds: {top: 0, left: 0, right: 240, bottom: 336},
- InitConnection:
- func()
- begin
- SetValue(StatusArea,'text, "Connecting...\n");
- RefreshViews();
-
- ep := {_proto: baseEndpoint, _parent: self}; // make a RAM copy so we can modify it
-
- local err := ep:Instantiate(ep, nil);
-
- if err then
- begin
- EnsureInternal(:Notify(kNotifyAlert, "ADSP Sample", "Sorry, can't open AppleTalk!"));
- SetValue(StatusArea, 'text, "Unable to initialize...");
- return;
- end;
-
- err := ep:Connect(LiveremoteAddress, nil); // always check for results from Connect
-
- if err then
- begin
- EnsureInternal(:Notify(kNotifyAlert, "ADSP Sample", "Couldn't connect..." & NumberStr(err)));
- SetValue(StatusArea, 'text, "Unable to connect...");
- return;
- end;
-
- ep.myBase := _parent;
- ep:SetInputSpec(ep.doInput); // set up first inputSpec
- SetValue(StatusArea,'text, "Connected, Waiting for Disconnect...");
- connected := true;
- end,
- ReleaseConnection:
- func()
- begin
- if (connected) then
- begin
- ep.nextInputSpec := nil; // no more input
- ep:SetInputSpec(nil); // kill the current inputSpec
- ep:Abort(); // asynchronously abort any pending I/O
-
- // must use a delayed action to dispose
- AddDelayedAction(DisposeConnection, [], 100);
- end;
- end,
- PutDataInStatusArea:
- func(s)
- begin
- SetValue(StatusArea, 'text, s);
- end,
- PutDataInReceivedArea:
- func(s)
- begin
- SetValue(ReceivedArea, 'text, s);
- end,
- viewSetupDoneScript:
- func()
- begin
- ActiveConnection := 0;
- ActiveListenConnection := 0;
-
- LiveRemoteAddress := DeepClone(remoteAddress); // clone so we could modify this one
- end,
- SendDataInSendField:
- func()
- begin
- ep:Output(SendDataField.entryLine.text, kMore);
- ep:Output([unicodeCR,unicodeLF], kMore);
- ep:FlushOutput();
- end,
- connected: nil,
- remoteAddress:
- {
- type: 'address,
- label: kCMARouteLabel,
- opCode: opSetRequired,
- data : {
- addressType: kNamedAppleTalkAddress,
- addressData: "Sandvik:ADSP@RD5/2" // hard coded value, change if needed
- }
- },
- baseEndpoint:
- {
- //_proto: @174, // ROM protoEndpoint
- _proto: protoEndpoint, // NTK protoEndpoint
-
- configOptions:
- [
- // adsp tool
- { label: "atlk", type: 'service, opCode: opSetRequired },
-
- { label: "atlk", type: 'option, opCode: opSetRequired,
- data: [97, 100, 115, 112] }, // 'adsp' (can't use "adsp" because it includes a null terminator)
-
- { label: "endp", type: 'option, opCode: opSetRequired,
- data: "TADSPEndpoint" },
- ],
-
- myBase: nil,
-
- // All endpoint related exceptions end up here, catch them.
- exceptionHandler: func(exception)
- begin
- EnsureInternal(GetRoot():Notify(kNotifyAlert, "ADSP Sample", "Exception: " & exception.data));
- return true;
- end,
-
- doInput:
- {
- InputForm: 'string,
- endCharacter: unicodeCR,
-
- InputScript: func(endpoint, s)
- begin
- Perform(endpoint.myBase, 'PutDataInStatusArea, [Clone("Data Received...")]);
-
- Perform(endpoint.myBase, 'PutDataInReceivedArea, [Clone(s)]);
-
- end,
-
- discardAfter: 200,
- },
- },
- ep: nil,
- DisposeConnection:
- func()
- begin
- ep:Disconnect();
- ep:Dispose();
- connected := nil;
- :PutDataInStatusArea("Ready to connect...");
- end,
- LiveRemoteAddress:
- // the ADSP address frame, in memory, so we could modify this one
- nil,
- _proto: protoApp,
- debug: "ADSPSample"
- };
-
- _view001 := /* child of ADSPSample */
- {viewFlags: 1,
- viewFormat: 304,
- viewBounds: {left: 11, top: 219, right: 233, bottom: 297},
- viewclass: 74
- };
-
-
-
- StatusArea := /* child of ADSPSample */
- {text: "",
- viewBounds: {left: 10, top: 26, right: 232, bottom: 64},
- viewJustify: 0,
- viewFormat: 67436880,
- _proto: protoStaticText,
- debug: "StatusArea"
- };
- // View StatusArea is declared to ADSPSample
-
-
-
- ReceivedArea := /* child of ADSPSample */
- {text: "",
- viewBounds: {left: 10, top: 82, right: 232, bottom: 176},
- viewJustify: 0,
- viewFormat: 67436880,
- _proto: protoStaticText,
- debug: "ReceivedArea"
- };
- // View ReceivedArea is declared to ADSPSample
-
-
-
- Status := /* child of ADSPSample */
- {text: "Status",
- viewBounds: {left: 18, top: 18, right: 114, bottom: 34},
- viewTransferMode: 0
- ,
- _proto: protoStaticText,
- debug: "Status"
- };
-
-
-
- Received := /* child of ADSPSample */
- {text: "Received Data",
- viewBounds: {left: 18, top: 74, right: 114, bottom: 90},
- viewTransferMode: 0
- ,
- _proto: protoStaticText,
- debug: "Received"
- };
-
-
-
- Connect := /* child of ADSPSample */
- {text: "Connect",
- buttonClickScript:
- func()
- begin
- if not connected then
- :InitConnection();
- else
- EnsureInternal(:Notify(kNotifyAlert, "ADSP Sample", "already connected!"));
- end,
- viewBounds: {left: 12, top: 188, right: 120, bottom: 208},
- viewSetupDoneScript:
- func()
- begin
- :PutDataInStatusArea("Ready to Connect...");
- end,
- _proto: protoTextButton,
- debug: "Connect"
- };
- // View Connect is declared to ADSPSample
-
-
-
- Disconnect := /* child of ADSPSample */
- {text: "Disconnect",
- buttonClickScript:
- func()
- begin
- if connected then
- begin
- :ReleaseConnection();
- :PutDataInStatusArea("Disconnecting...");
- end;
- else
- EnsureInternal(:Notify(kNotifyAlert, "ADSP Sample", "not connected!"));
- end,
- viewBounds: {left: 132, top: 188, right: 232, bottom: 208},
- viewQuitScript:
- func()
- begin
- :ReleaseConnection();
- end,
- _proto: protoTextButton,
- debug: "Disconnect"
- };
- // View Disconnect is declared to ADSPSample
-
-
-
- SendDataField := /* child of ADSPSample */
- {viewBounds: {top: 226, left: 18, right: 226, bottom: 290},
- viewFormat: 256,
- viewlinespacing: 16,
- label: "Data:",
- textSetup:
- func()
- begin
- return "this is a test";
- end,
- indent: 80,
- _proto: protoLabelInputLine,
- debug: "SendDataField"
- };
- // View SendDataField is declared to ADSPSample
-
-
-
- SendButton := /* child of ADSPSample */
- {text: "Send",
- buttonClickScript:
- func()
- begin
- if connected then
- :SendDataInSendField();
- else
- EnsureInternal(:Notify(kNotifyAlert, "ADSP Sample", "not connected!"));
- end,
- viewBounds: {left: 36, top: 308, right: 104, bottom: 328},
- _proto: protoTextButton,
- debug: "SendButton"
- };
- // View SendButton is declared to ADSPSample
-
-
-
- configureButton := /* child of ADSPSample */
- {text: "Configure",
- buttonClickScript:
- func()
- begin
- // Open a view that will ask for the type and name info, and the zone info as well.
- ConfigureView:Open();
- end,
- viewBounds: {left: 128, top: 308, right: 196, bottom: 328},
- _proto: protoTextButton,
- debug: "configureButton"
- };
-
-
-
- ConfigureView := /* child of ADSPSample */
- {viewBounds: {left: 0, top: 46, right: 228, bottom: 194},
- viewSetupFormScript:
- func()
- begin
- addressData := GetRoot().|ADSP:PIEDTS|.LiveRemoteAddress.data.addressData;
-
- // Start munging so the stuff looks real
- // First the zone.
- local pos := StrPos(addressData, "@", 0);
- ADSPZone := SubStr(addressData, pos+1, 32);
-
- // Then the name.
- local pos2 := StrPos(addressData, ":", 0);
- ADSPName := SubStr(addressData, 0, pos2);
-
- // Finally the type
- ADSPType := SubStr(addressData, pos2 + 1, pos - pos2 - 1);
-
- end,
- ADSPName: nil,
- ADSPType: nil,
- ADSPZone: nil,
- adressData: nil,
- viewQuitScript:
- func()
- begin
- // The Deeds are done, update the address info in the app base view.
- GetRoot().|ADSP:PIEDTS|.LiveRemoteAddress.data.addressData :=
- Stringer([ADSPName, ":", ADSPType, "@", ADSPZone]);
- end,
- _proto: protoFloatNGo,
- debug: "ConfigureView"
- };
- // View ConfigureView is declared to ADSPSample
-
- mainLabel := /* child of ConfigureView */
- {text: "Specify ADSP Server info:",
- viewBounds: {left: 32, top: 8, right: 216, bottom: 32},
- _proto: protoStaticText,
- debug: "mainLabel"
- };
-
-
-
- NameInput := /* child of ConfigureView */
- {viewBounds: {left: 0, top: 40, right: 224, bottom: 64},
- label: "Server Name:",
- viewSetupFormScript:
- func()
- begin
- // get the address data string
- local x := GetRoot().kAppSymbol.liveRemoteAddress.data.addressData;
-
- //SetValue(entry, 'text, GetRoot()kAppSymbol.LiveRemoteAddress
- end,
- textSetup:
- func()
- begin
- // Return the ADSP name stored in the parent view for default setup.
- return ADSPName;
- end,
- textChanged:
- func()
- begin
- // We did something with the values, update parent.
- ADSPName := entryline.text;
- end,
- _proto: protoLabelInputLine,
- debug: "NameInput"
- };
- // View NameInput is declared to ConfigureView
-
-
-
- TypeInput := /* child of ConfigureView */
- {viewBounds: {left: 0, top: 72, right: 224, bottom: 96},
- label: "Server Type:",
- textSetup:
- func()
- begin
- // Return the ADSP Type in the parent view as the default value.
- return ADSPType;
- end,
- textChanged:
- func()
- begin
- // We did something with the values, update parent.
- ADSPType := entryline.text;
- end,
- _proto: protoLabelInputLine,
- debug: "TypeInput"
- };
- // View TypeInput is declared to ConfigureView
-
-
-
- ZoneInput := /* child of ConfigureView */
- {viewBounds: {left: 0, top: 104, right: 224, bottom: 128},
- label: "Server Zone:",
- textSetup:
- func()
- begin
- // Return the ADSP Zone string stored in the parent view as the default value.
- return ADSPZone;
- end,
- textChanged:
- func()
- begin
- // We did something with the values, update parent.
- ADSPZone := entryline.text;
- end,
- _proto: protoLabelInputLine,
- debug: "ZoneInput"
- };
- // View ZoneInput is declared to ConfigureView
-
-
-
-
-
-
- // End of output