public PacketHandler(bool plinger, PacketIF.PacketType ptype, int pnumber) { linger = plinger; type = ptype; number = pnumber; callback = null; clientData = null; matchString = null; }
public PacketHandler(bool plinger, PacketIF.PacketType ptype, int pnumber, PacketIF.PacketHandlerCallback pcallback, Object pclientData) { linger = plinger; type = ptype; number = pnumber; callback = pcallback; clientData = pclientData; matchString = null; }
public void setHandler(PacketIF.PacketType type, PacketHandlerCallback callback, Object clientdata) { this.setHandler(type, callback, clientdata, null); }
public ThreadWorker(PacketIF pin) { p = pin; }
public ThreadSender(PacketIF pin) { p = pin; }
public bool netPrintEndOfMacroNode(StreamWriter sw, PrintType destination, String prefix, PacketIF.PacketIFCallback callback, Object clientdata) { bool r = true; String s = netEndOfMacroNodeString(prefix); if (s == null) return true; if (destination == PrintType.PrintFile || destination == PrintType.PrintCut || destination == PrintType.PrintCPBuffer) { sw.Write(s); if (callback != null) callback(clientdata, s); } else { Debug.Assert(destination == PrintType.PrintExec); DXPacketIF pif = DXApplication.theDXApplication.getPacketIF(); pif.sendBytes(s); } return r; }
public void sendPacket(PacketIF.PacketType packetType, int packetId, String data) { packetIF.sendPacket(packetType, packetId, data); }
private static bool SendString(Object callbackData, PacketIF.PacketIFCallback callback, StreamWriter sw, String str, bool viasocket) { if (!viasocket) { sw.Write(str); if (callback != null) callback(callbackData, str); } else { DXApplication.theDXApplication.getPacketIF().sendBytes(str); } return true; }
protected bool printMacro(StreamWriter sw, PacketIF.PacketIFCallback pif, Object callbackData, bool viasocket) { Cacheability cacheability = InternalCacheability; int cacheflag = (cacheability == Cacheability.InternalsNotCached) ? 0 : (cacheability == Cacheability.InternalsFullyCached) ? 1 : 2; // If the network is intended for use under DXServer use the // new image macro. Using the old image macro is a cheap way // of avoiding bugs in the new image macro. A better way // to handle this is to make sure the new one doesn't have any // bugs in it. Problem is the new is so big that it will // probably be a performance hit. if (getNetwork().isJavified()) { FormatMacro(sw, pif, callbackData, ImageNode.ImageMacroTxt, viasocket); } else { String str = "macro Image(\n" + " id,\n" + " object,\n" + " where,\n" + " useVector,\n" + " to,\n" + " from,\n" + " width,\n" + " resolution,\n" + " aspect,\n" + " up,\n" + " viewAngle,\n" + " perspective,\n" + " options,\n" + " buttonState = 1,\n" + " buttonUpApprox = \"none\",\n" + " buttonDownApprox = \"none\",\n" + " buttonUpDensity = 1,\n" + " buttonDownDensity = 1,\n" + " renderMode = 0,\n"; SendString(callbackData, pif, sw, str, viasocket); str = " defaultCamera,\n" + " reset,\n" + " backgroundColor,\n" + " throttle,\n" + " RECenable = 0,\n" + " RECfile,\n" + " RECformat,\n" + " RECresolution,\n" + " RECaspect,\n" + " AAenable = 0,\n" + " AAlabels,\n" + " AAticks,\n" + " AAcorners,\n" + " AAframe,\n" + " AAadjust,\n" + " AAcursor,\n" + " AAgrid,\n" + " AAcolors,\n" + " AAannotation,\n" + " AAlabelscale,\n"; SendString(callbackData, pif, sw, str, viasocket); str = " AAfont,\n" + " interactionMode,\n" + " title,\n" + " AAxTickLocs,\n" + " AAyTickLocs,\n" + " AAzTickLocs,\n" + " AAxTickLabels,\n" + " AAyTickLabels,\n" + " AAzTickLabels,\n" + " webOptions) -> (\n" + " object,\n" + " camera,\n" + " where)\n{\n"; SendString(callbackData, pif, sw, str, viasocket); // Begin macro body. str = " ImageMessage(\n" + " id,\n" + " backgroundColor,\n" + " throttle,\n" + " RECenable,\n" + " RECfile,\n" + " RECformat,\n" + " RECresolution,\n" + " RECaspect,\n" + " AAenable,\n" + " AAlabels,\n" + " AAticks,\n" + " AAcorners,\n" + " AAframe,\n" + " AAadjust,\n" + " AAcursor,\n" + " AAgrid,\n" + " AAcolors,\n" + " AAannotation,\n" + " AAlabelscale,\n"; SendString(callbackData, pif, sw, str, viasocket); str = " AAfont,\n" + " AAxTickLocs,\n" + " AAyTickLocs,\n" + " AAzTickLocs,\n" + " AAxTickLabels,\n" + " AAyTickLabels,\n" + " AAzTickLabels,\n" + " interactionMode,\n" + " title,\n" + " renderMode,\n" + " buttonUpApprox,\n" + " buttonDownApprox,\n" + " buttonUpDensity,\n" + String.Format(" buttonDownDensity) [instance: 1, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); // Generate a call to Camera or AutoCamera module. str = " autoCamera =\n" + " AutoCamera(\n" + " object,\n" + " \"front\",\n" + " object,\n" + " resolution,\n" + " aspect,\n" + " [0,1,0],\n" + " perspective,\n" + " viewAngle,\n" + String.Format(" backgroundColor) [instance: 1, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); str = " realCamera =\n" + " Camera(\n" + " to,\n" + " from,\n" + " width,\n" + " resolution,\n" + " aspect,\n" + " up,\n" + " perspective,\n" + " viewAngle,\n" + String.Format(" backgroundColor) [instance: 1, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); str = " coloredDefaultCamera = \n" + " UpdateCamera(defaultCamera,\n" + String.Format(" background=backgroundColor) [instance: 1, cache: {0}];\n", cacheflag) + " nullDefaultCamera =\n" + " Inquire(defaultCamera,\n" + String.Format(" \"is null + 1\") [instance: 1, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); str = " resetCamera =\n" + " Switch(\n" + " nullDefaultCamera,\n" + " coloredDefaultCamera,\n" + String.Format(" autoCamera) [instance: 1, cache: {0}];\n", cacheflag) + " resetNull = \n" + " Inquire(\n" + " reset,\n" + String.Format(" \"is null + 1\") [instance: 2, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); str = " reset =\n" + " Switch(\n" + " resetNull,\n" + " reset,\n" + String.Format(" 0) [instance: 2, cache: {0}];\n", cacheflag) + " whichCamera =\n" + " Compute(\n" + " \"($0 != 0 || $1 == 0) ? 1 : 2\",\n" + " reset,\n" + String.Format(" useVector) [instance: 1, cache: {0}];\n", cacheflag) + " camera = Switch(\n" + " whichCamera,\n" + " resetCamera,\n" + String.Format(" realCamera) [instance: 3, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); /* * Generate a call to AutoAxes module. */ str = " AAobject =\n" + " AutoAxes(\n" + " object,\n" + " camera,\n" + " AAlabels,\n" + " AAticks,\n" + " AAcorners,\n" + " AAframe,\n" + " AAadjust,\n" + " AAcursor,\n" + " AAgrid,\n" + " AAcolors,\n" + " AAannotation,\n" + " AAlabelscale,\n" + " AAfont,\n" + " AAxTickLocs,\n" + " AAyTickLocs,\n" + " AAzTickLocs,\n" + " AAxTickLabels,\n" + " AAyTickLabels,\n"; SendString(callbackData, pif, sw, str, viasocket); str = String.Format(" AAzTickLabels) [instance: 1, cache: {0}];\n", cacheflag)+ " switchAAenable = Compute(\"$0+1\",\n" + String.Format(" AAenable) [instance: 2, cache: {0}];\n", cacheflag) + " object = Switch(\n" + " switchAAenable,\n" + " object,\n" + String.Format(" AAobject) [instance:4, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); /* * Generate a call to the Approximation Switch module. */ str = " SWapproximation_options =\n" + " Switch(\n" + " buttonState,\n" + " buttonUpApprox,\n" + String.Format(" buttonDownApprox) [instance: 5, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); /* * Generate a call to the Density Switch module. */ str = " SWdensity_options =\n" + " Switch(\n" + " buttonState,\n" + " buttonUpDensity,\n" + String.Format(" buttonDownDensity) [instance: 6, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); /* * Generate a call to the Approximation Format module. */ str = " HWapproximation_options =\n" + " Format(\n" + " \"%s,%s\",\n" + " buttonDownApprox,\n" + String.Format(" buttonUpApprox) [instance: 1, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); /* * Generate a call to the Density Format module. */ str = " HWdensity_options =\n" + " Format(\n" + " \"%d,%d\",\n" + " buttonDownDensity,\n" + String.Format(" buttonUpDensity) [instance: 2, cache: {0}];\n", cacheflag) + " switchRenderMode = Compute(\n" + " \"$0+1\",\n" + String.Format(" renderMode) [instance: 3, cache: {0}];\n", cacheflag) + " approximation_options = Switch(\n" + " switchRenderMode,\n" + " SWapproximation_options,\n" + " HWapproximation_options)" + String.Format(" [instance: 7, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); str = " density_options = Switch(\n" + " switchRenderMode,\n" + " SWdensity_options,\n" + String.Format(" HWdensity_options) [instance: 8, cache: {0}];\n", cacheflag) + " renderModeString = Switch(\n" + " switchRenderMode,\n" + " \"software\",\n" + String.Format(" \"hardware\")[instance: 9, cache: {0}];\n", cacheflag) + " object_tag = Inquire(\n" + " object,\n" + String.Format(" \"object tag\")[instance: 3, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); /* * Generate a call to Options module. */ str = " annoted_object =\n" + " Options(\n" + " object,\n" + " \"send boxes\",\n" + " 0,\n" + " \"cache\",\n" + String.Format(" {0},\n", (cacheflag == (int)Cacheability.InternalsFullyCached ? 1 : 0))+ " \"object tag\",\n" + " object_tag,\n" + " \"ddcamera\",\n" + " whichCamera,\n" + " \"rendering approximation\",\n" + " approximation_options,\n" + " \"render every\",\n" + " density_options,\n" + " \"button state\",\n" + " buttonState,\n" + " \"rendering mode\",\n" + String.Format(" renderModeString) [instance: 1, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); str = " RECresNull =\n" + " Inquire(\n" + " RECresolution,\n" + String.Format(" \"is null + 1\") [instance: 4, cache: {0}];\n", cacheflag) + " ImageResolution =\n" + " Inquire(\n" + " camera,\n" + String.Format(" \"camera resolution\") [instance: 5, cache: {0}];\n", cacheflag)+ " RECresolution =\n" + " Switch(\n" + " RECresNull,\n" + " RECresolution,\n"; SendString(callbackData, pif, sw, str, viasocket); str = String.Format(" ImageResolution) [instance: 10, cache: {0}];\n", cacheflag) + " RECaspectNull =\n" + " Inquire(\n" + " RECaspect,\n" + String.Format(" \"is null + 1\") [instance: 6, cache: {0}];\n", cacheflag) + " ImageAspect =\n" + " Inquire(\n" + " camera,\n" + String.Format(" \"camera aspect\") [instance: 7, cache: {0}];\n", cacheflag) + " RECaspect =\n" + " Switch(\n" + " RECaspectNull,\n" + " RECaspect,\n" + String.Format(" ImageAspect) [instance: 11, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); str = " switchRECenable = Compute(\n" + " \"$0 == 0 ? 1 : (($2 == $3) && ($4 == $5)) ? ($1 == 1 ? 2 : 3) : 4\",\n" + " RECenable,\n" + " switchRenderMode,\n" + " RECresolution,\n" + " ImageResolution,\n" + " RECaspect,\n" + String.Format(" ImageAspect) [instance: 4, cache: {0}];\n", cacheflag) + " NoRECobject, RECNoRerenderObject, RECNoRerHW, RECRerenderObject = " + "Route(switchRECenable, annoted_object);\n"; SendString(callbackData, pif, sw, str, viasocket); /* * If no recording is specified, just use Display */ str = " Display(\n" + " NoRECobject,\n" + " camera,\n" + " where,\n" + String.Format(" throttle) [instance: 1, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); /* * If recording is used, but no rerendering is required, * use Render followed by DIsplay and Write Image */ str = " image =\n" + " Render(\n" + " RECNoRerenderObject,\n" + String.Format(" camera) [instance: 1, cache: {0}];\n", cacheflag) + " Display(\n" + " image,\n" + " NULL,\n" + " where,\n" + String.Format(" throttle) [instance: 2, cache: {0}];\n", cacheflag) + " WriteImage(\n" + " image,\n" + " RECfile,\n" + String.Format(" RECformat) [instance: 1, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); /* * If recording is used in a hardware window, but no rerendering is required, * use Display and ReadImageWindow. */ str = " rec_where = Display(\n" + " RECNoRerHW,\n" + " camera,\n" + " where,\n" + String.Format(" throttle) [instance: 1, cache: {0}];\n", 0/*cacheflag*/) + " rec_image = ReadImageWindow(\n" + String.Format(" rec_where) [instance: 1, cache: {0}];\n", cacheflag) + " WriteImage(\n" + " rec_image,\n" + " RECfile,\n" + String.Format(" RECformat) [instance: 1, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); /* * If recording, and rerendering *is* required, use Display * for the image window and Render and WriteImage along with * the updated camera for the saved image */ str = " RECupdateCamera =\n" + " UpdateCamera(\n" + " camera,\n" + " resolution=RECresolution,\n" + String.Format(" aspect=RECaspect) [instance: 2, cache: {0}];\n", cacheflag) + " Display(\n" + " RECRerenderObject,\n" + " camera,\n" + " where,\n" + String.Format(" throttle) [instance: 1, cache: {0}];\n", cacheflag); SendString(callbackData, pif, sw, str, viasocket); str = " RECRerenderObject =\n" + " ScaleScreen(\n" + " RECRerenderObject,\n" + " NULL,\n" + " RECresolution,\n" + String.Format(" camera) [instance: 1, cache: {0}];\n", cacheflag) + " image =\n" + " Render(\n" + " RECRerenderObject,\n" + String.Format(" RECupdateCamera) [instance: 2, cache: {0}];\n", cacheflag) + " WriteImage(\n" + " image,\n" + " RECfile,\n" + String.Format(" RECformat) [instance: 2, cache: {0}];\n", cacheflag) + // // End macro body. // "}\n"; SendString(callbackData, pif, sw, str, viasocket); } return true; }
public virtual void send(PacketIF pif) { pif._sendBytes(data); }
public override void send(PacketIF pif) { pif._sendPacket(type, packetId, data); }
private int stallCount; // For implementing StallNTimes(). #endregion Fields #region Constructors public DXLinkHandler(PacketIF pif) : base(pif) { this.addCommand("set", (Command) null); this.addSubCommand("set", "tab", SetTabValue); this.addSubCommand("set", "value", SetGlobalValue); this.addSubCommand("set", "probevalue", SetProbePoint); this.addSubCommand("set", "activeprobe", SelectProbe); this.addCommand("execute", (Command) null); this.addSubCommand("execute", "once", DXLinkHandler.ExecOnce); this.addSubCommand("execute", "onchange", DXLinkHandler.ExecOnChange); this.addSubCommand("execute", "end", DXLinkHandler.EndExecution); this.addSubCommand("execute", "endEOC", DXLinkHandler.EndExecOnChange); this.addCommand("StartServer", DXLinkHandler.StartServer); this.addCommand("ConnectToServer", DXLinkHandler.ConnectToServer); this.addCommand("disconnect", DXLinkHandler.Disconnect); this.addCommand("exit", DXLinkHandler.Terminate); this.addCommand("quit", DXLinkHandler.Terminate); this.addCommand("save", (Command) null); this.addSubCommand("save", "network", DXLinkHandler.SaveNetwork); this.addCommand("open", (Command) null); this.addSubCommand("open", "networkNoReset", DXLinkHandler.OpenNetworkNoReset); this.addSubCommand("open", "network", DXLinkHandler.OpenNetwork); this.addSubCommand("open", "config", DXLinkHandler.OpenConfig); this.addSubCommand("open", "controlpanel", DXLinkHandler.OpenControlPanel); this.addSubCommand("open", "VPE", DXLinkHandler.OpenVPE); this.addSubCommand("open", "sequencer", DXLinkHandler.OpenSequencer); this.addSubCommand("open", "image", DXLinkHandler.OpenImage); this.addSubCommand("open", "colormapEditor", DXLinkHandler.OpenColormapEditor); this.addCommand("query", (Command) null); this.addSubCommand("query", "value", DXLinkHandler.QueryValue); this.addSubCommand("query", "sync", DXLinkHandler.Sync); this.addSubCommand("query", "sync-exec", DXLinkHandler.SyncExec); this.addSubCommand("query", "execution", DXLinkHandler.QueryExecution); this.addCommand("close", (Command) null); this.addSubCommand("close", "controlpanel", DXLinkHandler.CloseControlPanel); this.addSubCommand("close", "VPE", DXLinkHandler.CloseVPE); this.addSubCommand("close", "colormapEditor", DXLinkHandler.CloseColormapEditor); this.addSubCommand("close", "image", DXLinkHandler.CloseImage); this.addSubCommand("close", "sequencer", DXLinkHandler.CloseSequencer); this.addCommand("sequencer", (Command) null); this.addSubCommand("sequencer", "play", DXLinkHandler.SequencerPlay); this.addSubCommand("sequencer", "pause", DXLinkHandler.SequencerPause); this.addSubCommand("sequencer", "step", DXLinkHandler.SequencerStep); this.addSubCommand("sequencer", "stop", DXLinkHandler.SequencerStop); this.addSubCommand("sequencer", "palindrome", DXLinkHandler.SequencerPalindrome); this.addSubCommand("sequencer", "loop", DXLinkHandler.SequencerLoop); this.addCommand("load", (Command) null); this.addSubCommand("load", "macroFile", DXLinkHandler.LoadMacroFile); this.addSubCommand("load", "macroDirectory", DXLinkHandler.LoadMacroDirectory); this.addCommand("$version", DXLinkHandler.Version); this.addCommand("resend", DXLinkHandler.ResendParameters); this.addCommand("interactionMode", DXLinkHandler.SetInteractionMode); this.addCommand("reset", DXLinkHandler.ResetServer); this.addCommand("save", (Command) null); this.addSubCommand("save", "config", DXLinkHandler.SaveConfig); this.addCommand("render-mode", (Command) null); this.addSubCommand("render-mode", "hw", DXLinkHandler.SetHWRendering); this.addSubCommand("render-mode", "sw", DXLinkHandler.SetSWRendering); // // As of 6/12/95, we aren't using this in DXLink, but it may come in // handy for fixing bugs and may be of general utility. // this.addCommand("stall", (Command) null); this.addSubCommand("stall", "until", DXLinkHandler.StallUntil); }
public bool netPrintNode(StreamWriter sw, PrintType destination, String prefix, PacketIF.PacketIFCallback callback, Object clientdata) { DXPacketIF pif = DXApplication.theDXApplication.getPacketIF(); bool r = true; if (destination == PrintType.PrintFile || destination == PrintType.PrintCut || destination == PrintType.PrintCPBuffer) { if (!netPrintCommentHeader(sw)) return false; } else if (pif != null) { // We have a connection to the executive/server // // If this node has a message protocol with the executive, then // update any state associated with the protocol. if (hasModuleMessageProtocol()) updateModuleMessageProtocol(pif); prepareToSendNode(); } String s = netNodeString(prefix); if (destination == PrintType.PrintFile || destination == PrintType.PrintCut || destination == PrintType.PrintCPBuffer) { sw.Write(s); if (callback != null) callback(clientdata, s); } else { Debug.Assert(destination == PrintType.PrintExec); if (s.Length > 0) pif.sendBytes(s); } return r; }
public bool netPrintNode(StreamWriter sw, PrintType destination, String prefix, PacketIF.PacketIFCallback callback) { return netPrintNode(sw, destination, prefix, callback, null); }
public void setHandler(PacketIF.PacketType type, PacketHandlerCallback callback, Object clientData, String matchString) { if (clientData == null) Console.WriteLine("null client data\n"); PacketHandler pexist = null; foreach (PacketHandler p in handlers) { if (p.Type == type && p.match(matchString)) { pexist = p; break; } } if (callback == null) { if (pexist != null) { handlers.Remove(pexist); } } else { PacketHandler h = new PacketHandler(true, type, 0, callback, clientData, matchString); if (pexist != null) { handlers.Remove(pexist); handlers.Add(h); } else handlers.Add(h); } }
public override void send(PacketIF pif) { pif._sendImmediate(data); }
public PacketIF(String server, int port, bool local, bool asClient) { Debug.Assert(server != null); wpClientData = this; workProcInstalled = false; socket = null; error = false; deferPacketHandling = false; deleting = false; packetSender = false; line = ""; echoCallback = null; echoClientData = null; endReceiving = true; linkHandler = null; stallingWorker = null; stallingWorkerData = null; if (asClient) connectAsClient(server, port, local); else connectAsServer(port); output_queue = new List<QueuedBytes>(); if (!error) { installInputHandler(); } }
public QueuedPacket(PacketIF.PacketType type, int packetId, String data) : base(data) { this.type = type; this.packetId = packetId; }
private static void FormatMacro(StreamWriter sw, PacketIF.PacketIFCallback callback, Object callbackData, String[] s, bool viasocket) { foreach (String str in s) { SendString(callbackData, callback, sw, str, viasocket); } }
protected virtual bool printMacroReferences(Stream s, bool inline_define, PacketIF.PacketIFCallback echoCallback, Object echoClientData) { throw new Exception("Not Yet Implemented"); }
public void sendPacket(PacketIF.PacketType packetType, int packetId) { sendPacket(packetType, packetId, null); }
public void send(PacketIF.PacketType type, String data) { this.sendPacket(type, 0, data); }
public LinkHandler(PacketIF pif) { this.packetIF = pif; Dictionary<String, CmdEntry> dict = new Dictionary<String, CmdEntry>(); commandEntry = new CmdEntry(dict, this); }
public bool netPrintBeginningOfMacroNode(StreamWriter sw, PrintType destination, String prefix, PacketIF.PacketIFCallback callback, Object clientdata) { String s = netBeginningOfMacroNodeString(prefix); if (s == null) return true; if (destination == PrintType.PrintFile || destination == PrintType.PrintCut || destination == PrintType.PrintCPBuffer) { sw.Write(s); if (callback != null) callback(clientdata, s); } else { DXApplication.theDXApplication.getPacketIF().sendBytes(s); } return true; }