AlpineControlPanelImpl.mesa
Carl Hauser, March 30, 1987 10:21:32 am PST
DIRECTORY
AlpineControl,
AlpineIdentity,
AlpineFTPCmds,
Commander,
File,
LogBasic,
Process,
Rope,
ViewRec,
VolumeGroup;
AlpineControlPanelImpl: CEDAR PROGRAM
IMPORTS AlpineControl, AlpineFTPCmds, AlpineIdentity, Commander, File, LogBasic, Process, ViewRec, VolumeGroup
EXPORTS
~ BEGIN
Context: TYPE = RECORD[
panel: REF Panel ← NEW[Panel],
volumes: ARRAY [0..3] OF File.Volume ← ALL[NIL],
rv: ViewRec.RecordViewer];
Panel: TYPE = RECORD [
StartFTP: PROC RETURNS[result: Rope.ROPE] ← StartFTPProc,
StopFTP: PROC RETURNS[result: Rope.ROPE] ← StopFTPProc,
ExportInterfaces: PROC RETURNS[result: Rope.ROPE] ← ExportInterfacesProc,
UnExportInterfaces: PROC RETURNS[result: Rope.ROPE] ← UnExportInterfacesProc,
Shutdown: PROC RETURNS[result: Rope.ROPE] ← ShutdownProc,
sampleDelay: CARDINAL ← 10,
volumeInfo: ARRAY [0..3] OF RECORD [
name: Rope.ROPENIL,
totalSpace: LONG CARDINAL ← 0,
freeSpace: LONG CARDINAL ← 0],
logInfo: RECORD [
totalSize: LONG CARDINAL ← 0,
spaceUsed: LONG CARDINAL ← 0,
percentUsed: CARDINAL ← 0]
];
StartFTPProc: PROC [] RETURNS [result: Rope.ROPE] ~ {
[msg: result] ← AlpineFTPCmds.StartAlpineFTPServer[ volGroup: AlpineIdentity.myFileStore ];
};
StopFTPProc: PROC [] RETURNS [result: Rope.ROPE] ~ {
[msg: result] ← AlpineFTPCmds.StopAlpineFTPServer[ volGroup: AlpineIdentity.myFileStore ];
};
ExportInterfacesProc: PROC [] RETURNS [result: Rope.ROPE ← "done"] ~ TRUSTED {
AlpineControl.ExportInterfaces[];
};
UnExportInterfacesProc: PROC [] RETURNS [result: Rope.ROPE ← "done"] ~ TRUSTED {
AlpineControl.UnexportInterfaces[];
};
ShutdownProc: PROC [] RETURNS [result: Rope.ROPE ← "done"] ~ TRUSTED {
[] ← AlpineControl.Halt[1];
};
MakeAlpineControlPanel: Commander.CommandProc = TRUSTED {
[cmd: REF CommandObject] RETURNS [result: REFNIL, msg: ROPENIL]
CommandObject = [
in, out, err: STREAM, commandLine, command: ROPE,
propertyList: List.AList, procData: CommandProcHandle]
context: REF Context ← NEW[Context];
panel: REF Panel ← context.panel;
i: [0..4);
volumeGroupID: VolumeGroup.VolumeGroupID ← VolumeGroup.GetNext[VolumeGroup.nullVolumeGroupID];
i ← 0;
FOR volList: LIST OF VolumeGroup.VolumeID ← VolumeGroup.GetVolumes[volumeGroupID], volList.rest WHILE volList # NIL DO
volume: File.Volume;
context.volumes[i] ← volume ← File.FindVolumeFromID[volList.first];
[name: panel.volumeInfo[i].name, size: panel.volumeInfo[i].totalSpace] ← File.LogicalInfo[volume];
i ← i+1;
ENDLOOP;
panel.logInfo.totalSize ← LogBasic.LogFileSize[];
context.rv ← ViewRec.ViewRef[agg: panel, sample: FALSE, viewerInit: [name: AlpineIdentity.myFileStore]];
ViewRec.SetBehavior[ newBehavior: [[min: 10000, max:10000]] ];
TRUSTED { Process.Detach[ FORK Sampler[context] ] };
};
Sampler: PROC [context: REF Context] RETURNS [] ~ {
panel: REF Panel ← context.panel;
DO
FOR i: [0..4) IN [0..4) DO
IF context.volumes[i] # NIL THEN [free: panel.volumeInfo[i].freeSpace] ← File.LogicalInfo[context.volumes[i]];
ENDLOOP;
TRUSTED {panel.logInfo.spaceUsed ← LogBasic.LogUsage[]};
panel.logInfo.percentUsed ← (100*panel.logInfo.spaceUsed) / panel.logInfo.totalSize;
ViewRec.SampleRV[context.rv];
Process.Pause[Process.SecondsToTicks[panel.sampleDelay]];
ENDLOOP;
};
Init: PROC [] RETURNS [] ~ {
Commander.Register[
"AlpineControlPanel", MakeAlpineControlPanel,
"Makes a control viewer for the running Alpine Server"];
};
Init[];
END.