JaMIDunnImpl.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Last edited by: Mik Lamming - June 18, 1986 11:37:42 am PDT
DIRECTORY ThisMachine, IO, ImagerPixelArray, ImagerSample, Terminal, InterminalBackdoor, ImagerSmoothContext, DicentraRS232CAsync, MessageWindow, JaM, JaMIPrivate, Imager, Rope;
JaMIDunnImpl:
CEDAR MONITOR
IMPORTS IO, ThisMachine, ImagerPixelArray, ImagerSample, Rope, Terminal, InterminalBackdoor, ImagerSmoothContext, DicentraRS232CAsync, MessageWindow, JaM, JaMIPrivate
EXPORTS JaMIPrivate
DunnHost: Rope.ROPE ¬ "York";
DunnWS: Rope.ROPE ¬ "Reprisal";
Map: TYPE = ARRAY [0..255] OF NAT;
cmdCode: TYPE = MACHINE DEPENDENT {
from RS232 Interface Specs for Dunn Models 631 and 632 Color Camera Systems
videoInvertHigh (2EH),
videoInvertLow (2FH),
readyTest (3AH),
statusRequest (3BH),
expose8x5TimeReq (3CH),
exposeAuxTimeReq (3DH),
exposeAdjFactorReq (3EH),
advAuxFrameCnt (3FH),
reset8x10ExposeStat (40H),
restoreFilterWheel (41H),
recovDefaultVals (42H),
select8x10Mode (43H),
selectAuxMode (44H),
selectBW (45H),
selectColor (46H),
selectNrmSeqMode (47H),
selectSepSeqMode (48H),
exposeSeq (49H),
selectVidAndExpose (4AH),
set8x10ExposeTimes (4BH),
setAuxExposeTimes (4CH),
setExposeAdjFactors (4DH),
openAuxShutter (4EH),
closeAuxShutter (4FH),
unblankMonitor (50H),
blankMonitor (51H),
selectVideoChannel (52H),
positionFilterWheel (53H),
immExposeNoVidSw (54H),
yAxisRasterCompOn (55H),
yAxisRasterCompOff (56H),
clearYAxisOffset (57H),
stepYAxisOffset (58H),
clearXAxisOffset (59H),
stepXAxisOffset (5AH),
select35mmAuxCam (5BH),
select16mmAuxCam (5CH),
select4x5AuxCam (5DH),
selectSX70AuxCam (5EH),
setNumPadChars (5FH),
resetAuxNoFilmStats (60H),
fastOn (61H),
fastOff (62H)
};
BuildFrame:
PROC [action:
PROC[Imager.Context]]
RETURNS [pa: ImagerPixelArray.PixelArray] ~ {
pa ¬ ImagerSmoothContext.MakePixelArray[
action: action,
size: ImagerSample.MapFromFrameBuffer[
Terminal.GetColorFrameBufferA[
InterminalBackdoor.terminal
]].GetSize[],
components: LIST[$Red, $Green, $Blue],
blackBackground: TRUE
];
};
ApplyBuildFrame:
PROC [self: JaM.State] ~ {
action:
PROC [ctx: Imager.Context] ~ {
{
ENABLE UNWIND => { info.ipenabled¬ FALSE };
info.ipenabled¬ TRUE;
info.ipdc¬ ctx;
JaM.Execute[self, x];
info.ipenabled¬ FALSE;
};
};
info: JaMIPrivate.Info ¬ JaMIPrivate.GetInfo[self];
x: JaM.Any ~ JaM.Pop[self];
IF info = NIL THEN ERROR;
JaM.Push[self, BuildFrame[action]];
};
SnapFrame:
ENTRY
PROC [self: JaM.State, copies:
NAT, pa: ImagerPixelArray.PixelArray] ~ {
ENABLE UNWIND => NULL;
Open:
PROC [host: Rope.
ROPE ¬
NIL]
RETURNS [stream:
IO.
STREAM] ~ {
simulate ¬ TRUE;
MessageWindow.Clear[];
IF ThisMachine.Name[].Equal[DunnWS,
FALSE]
THEN {
MessageWindow.Append[" Opening connection.."];
stream ¬ DicentraRS232CAsync.CreateStream[host: host !
IO.Error, IO.EndOfStream => ERROR;
DicentraRS232CAsync.CommError => ERROR;
DicentraRS232CAsync.CommBusy => ERROR;
];
MessageWindow.Append[" Open"];
simulate ¬ FALSE
}
ELSE
MessageWindow.Append[" Simulation"];
};
Close:
PROC [stream:
IO.
STREAM] ~ {
IF
NOT simulate
THEN {
MessageWindow.Append[" Closing"];
IO.Flush[stream];
IO.Close[stream];
};
MessageWindow.Append[" Done"];
};
Cmd:
PROC [code:
cmdCode] ~ {
IF simulate THEN RETURN [];
IO.PutChar[s, LOOPHOLE[code, CHAR]];
IO.Flush[s];
IF NOT CheckReady[s] THEN ERROR;
};
CheckReady:
PROC [s:
IO.
STREAM]
RETURNS [ok:
BOOL ¬
TRUE] ~ {
IO.PutChar[s, LOOPHOLE[cmdCode[readyTest], CHAR]];
IO.Flush[s];
IF
IO.GetChar[s] # 'R
THEN
{
MessageWindow.Append[" Not Ready"];
RETURN [FALSE];
};
IF
IO.GetChar[s] # '\n
THEN
{
MessageWindow.Append[" Not OK"];
RETURN [FALSE];
};
};
s: IO.STREAM;
simulate: BOOLEAN ¬ FALSE;
saveR, saveG, saveB: Map;
vt: Terminal.Virtual ¬ InterminalBackdoor.terminal;
screenSM: ImagerSample.SampleMap ¬ ImagerSample.MapFromFrameBuffer[Terminal.GetColorFrameBufferA[vt]];
oldScreenContentsSM: ImagerSample.SampleMap ¬ screenSM.Copy[];
{
-- extra block to make vt in scope for abort
ENABLE
UNWIND => {
FOR i:
NAT
IN [0..255]
DO
Terminal.SetColor[vt, i, 0, saveR[i], saveG[i], saveB[i]];
ENDLOOP;
IF NOT simulate THEN Close[s];
};
-- Open a stream to the Dunn camera
-- set up the color map as per user's spec.
FOR i:
NAT
IN [0..255]
DO
[saveR[i], saveG[i], saveB[i]] ¬ Terminal.GetColor[vt, i, 0];
ENDLOOP;
{
ENABLE
UNWIND => {
Cmd[cmdCode[selectNrmSeqMode]];
Cmd[cmdCode[exposeSeq]];
Cmd[cmdCode[restoreFilterWheel]];
MessageWindow.Append[" aborted"];
screenSM.Transfer[oldScreenContentsSM];
};
MessageWindow.Append[" Snapping "];
Cmd[cmdCode[closeAuxShutter]];
Cmd[cmdCode[restoreFilterWheel]];
Cmd[cmdCode[selectSepSeqMode]];
-- set up red color map, restore image and expose it
THROUGH [1..copies]
DO
IF JaM.GetAbort[self] THEN JaM.Error[Unimplemented, "Snapping ABORTED"];
FOR i:
NAT
IN [0..255]
DO
Terminal.SetColor[vt, i, 0, i, 0, 0];
ENDLOOP;
pa.Transfer[i:0, dst: screenSM];
Cmd[cmdCode[exposeSeq]];
MessageWindow.Append[" R"];
-- set up green color map, restore image and expose it
FOR i:
NAT
IN [0..255]
DO
Terminal.SetColor[vt, i, 0, 0, i, 0];
ENDLOOP;
pa.Transfer[i:1, dst: screenSM];
Cmd[cmdCode[exposeSeq]];
MessageWindow.Append["G"];
-- set up blue color map, restore image and expose it
FOR i:
NAT
IN [0..255]
DO
Terminal.SetColor[vt, i, 0, 0, 0, i];
ENDLOOP;
pa.Transfer[i:2, dst: screenSM];
Cmd[cmdCode[exposeSeq]];
MessageWindow.Append["B"];
ENDLOOP;
screenSM.Transfer[oldScreenContentsSM];
};
-- Close down the Dunn channel
Close[s];
-- Reset the color maps as we found them
FOR i:
NAT
IN [0..255]
DO
Terminal.SetColor[vt, i, 0, saveR[i], saveG[i], saveB[i]];
ENDLOOP;
};
};
ApplySnapFrame: PROC [self: JaM.State] ~ {
WITH JaM.Pop[self]
SELECT
FROM
pa: ImagerPixelArray.PixelArray => SnapFrame[self, JaM.PopInt[self], pa];
ENDCASE => ERROR JaM.Error[InvalidArgs, "SnapFrame needs a pixelarray as argument"];
};
RegisterDunn:
PUBLIC
PROC [self: JaM.State] ~ {
JaM.Register[self, ".snapframe", ApplySnapFrame];
JaM.Register[self, ".buildframe", ApplyBuildFrame];
};