swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Do I understand MessageProbe correctly ?( was Re: EZGraph Query


From: Paul E Johnson
Subject: Do I understand MessageProbe correctly ?( was Re: EZGraph Query
Date: Tue, 16 Jan 2001 08:59:27 -0600

OK, concerning the EZGraph extension to allow users to specify
arguments. I narrowed the task to allow users to pass only an integer
along with a selector of their choice.  The new method in EZGraph is
only trivially different than the current
createSequence:withFeedFrom:andSelector: method. (see item 1. below).  

The part that had me stuck was how to marry the argument to the
selector, but when I awoke from my long slumber, I realized MessageProbe
had that facility already, so what if I just change ActiveGraph to use
it. In ActiveGraph.m, add this method:

- setDataKey: (unsigned) x
{
  if (key < 0)
    [InvalidCombination raiseEvent: "Data Key for Graph must be 0 or
greater"];
    //will the runtime make this check for me if x is typed "unsigned" ?
  else
    {
      char aString[5];
      key = x;
      sprintf ( aString,"%d",x );
      [self setArg: 0  ToString: aString];
    }
  return self;
}


If I understand the MessageProbe class correctly, this should put the
key into the ActiveGraph (subclass of MessageProbe) and the
doubleDynamicCallOn will automatically find that argument and pass it
back when the ActiveGraph's step method is called.

If that's right, is the first argument to the selector to be numbered
"0" or "1"?


Like the Model 6 guy says, So long, and thanks for all  your support.

pj

1.
- (id <EZSequence>)createSequence: (const char *)aName
                     withFeedFrom: anObj 
                      andSelector: (SEL)aSel
                       andDataKey: (unsigned) x
{

  id aSeq;
  id aGrapher;
  id aZone = getZone (self);

  aSeq = [EZSequence create: getZone (self)];
  if (graphics)
    {
      id anElement;
      
      anElement = [graph createElement];
      [anElement setLabel: aName];
      [anElement setColor: graphColors[colorIdx % colorCount]];
      colorIdx++;

      aGrapher = [ActiveGraph createBegin: aZone];
      [aGrapher setElement: anElement];
      [aGrapher setDataFeed: anObj]; 
      [aGrapher setProbedSelector: aSel];
      [aGrapher setDataKey: x];
      aGrapher = [aGrapher createEnd];
      
      [aSeq setActiveGrapher: aGrapher];    
    }
 
  if (fileOutput)
    {
      id aFileObj;
      const char *fName;

      fName = sequence_graph_filename (aZone, fileName, aName);
      aFileObj = [OutFile create: aZone setName: fName];
      
      aGrapher = [ActiveOutFile createBegin: aZone];
      [aGrapher setFileObject: aFileObj];
      [aGrapher setDataFeed: anObj]; 
      [aGrapher setProbedSelector: aSel];
      [aGrapher setDataKey: x];
      aGrapher = [aGrapher createEnd];
      
      [aSeq setActiveOutFile: aGrapher];    
    }
  
  [sequenceList addLast: aSeq];
  
  return aSeq;
}
  


-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]