public override bool initialize()
        {
            if (!verifyInputCount())
                return false;

            String value = null;
            switch (numComponents)
            {
                case 1: if (IsVectorType)
                        value = "{ [ 0 ] }";
                    else
                        value = "{ 0 }";
                    break;
                case 2: value = "{ [ 0 0 ] }"; break;
                case 3: value = "{ [ 0 0 0 ] }"; break;
                default: Debug.Assert(false); break;
            }
            if ((setOutputValue(1, value, DXTypeVals.UndefinedType, false) ==
                DXTypeVals.UndefinedType) ||
                !setDefaultAttributes())
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Error setting default attributes for {0} interactor, check ui.mdf",
                    NameString);
                return false;
            }

            // Make the shadows defaulting (even though we have a current output)
            // so that the executive module can tell when it is executing a just
            // placed module and one that is read in from a .net or .cfg file.
            // When read in, the output will be set again which should make the
            // corresponding shadowing input be non-defaulting.
            setShadowingInputsDefaulting();
            return true;
        }
 protected override Node newNode(Network net, int instance)
 {
     String node_name = NameString;
     if (net.findNode(SymbolManager.theSymbolManager.registerSymbol(node_name), 0) != null)
     {
         ErrorDialog ed = new ErrorDialog();
         ed.post("Only one {0} is allowed in a network.", node_name);
         return null;
     }
     SequencerNode d = new SequencerNode(this, net, instance);
     return d;
 }
 protected override Node newNode(Network net, int instance)
 {
     if (!net.CanBeMacro)
     {
         ErrorDialog ed = new ErrorDialog();
         ed.post("The {0} tool, which converts this network to a macro, is not " +
             "allowed in the current network. It is likely that one or more " +
             "of the tools in the current network is not allowed in a macro.",
             NameString);
         return null;
     }
     MacroParameterNode d = new MacroParameterNode(this, net, instance);
     return d;
 }
        public override bool cfgParseComment(string comment, string file, int lineno)
        {
            if (!comment.StartsWith(" filter = "))
            {
                return base.cfgParseComment(comment, file, lineno);
            }

            int instance = getInstanceCount();
            FileSelectorInstance fsi = (FileSelectorInstance)getInstance(instance);

            if (fsi == null)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("'filter' comment out of order (file {0}, line {1})",
                    file, lineno);
            }
            else
            {
                fsi.FileFilter = comment.Substring(10);
            }
            return true;
        }
        public bool parseComment(String comment, String filename, int lineno)
        {
            if (!comment.StartsWith(" layout"))
                return false;

            Regex regex = new Regex(@" layout: snap = (\d+), width = (\d+), height = (\d+), align = (.*)");
            Match m = regex.Match(comment);
            if (!m.Success)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Bad 'layout' panel comment (file {0}, line {1})", filename, lineno);
                return true;
            }
            int snap = Int32.Parse(m.Groups[1].ToString());
            int width = Int32.Parse(m.Groups[2].ToString());
            int height = Int32.Parse(m.Groups[3].ToString());
            String align = m.Groups[4].ToString();

            Active = (snap > 0);
            setSpacing(width, height);
            parseAlignment(align);

            return true;
        }
Example #6
0
        public override bool setLabelString(string label)
        {
            if (label == LabelString)
                return true;

            if (initializing && getNetwork().IsReadingNetwork)
                return base.setLabelString(label);

            if (!verifyRestrictedLabel(label))
                return false;

            // Skip the conflict check when reading in a newer style net since
            // there can't be any conflict in these nets.
            String conflict = null;
            if (getNetwork().IsReadingNetwork)
            {
                int net_major = getNetwork().getNetMajorVersion();
                int net_minor = getNetwork().getNetMinorVersion();
                int net_micro = getNetwork().getNetMicroVersion();

                int net_version = Utils.VersionNumber(net_major, net_minor, net_micro);
                if (net_version < Utils.VersionNumber(3, 1, 1))
                    conflict = getNetwork().nameConflictExists(this, label);
            }

            // If there is a name conflict while reading a network, it's important to try
            // to continue in spite of the conflict and fix things up later.  Reason: older
            // versions of dx allowed the name conflict and we would like to try and fix
            // things and report what happened rather than read the net incorrectly.
            if (conflict != null && getNetwork().IsReadingNetwork == false)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("A {0} with name \"{1}\" already exists.", conflict, label);
                return false;
            }

            bool found = false;
            List<Ark> ia = getInputArks(1);
            if (ia != null && ia.Count > 0)
            {
                Ark a = ia[0];
                int dummy;
                if (a.getSourceNode(out dummy).LabelString == label)
                    found = true;
            }
            ia = null;

            if (!found)
            {
                List<Node> l = getNetwork().makeClassifiedNodeList(typeof(TransmitterNode), false);
                if (l != null && (getNetwork().IsReadingNetwork == false))
                {
                    // Before creating any Arks, check for cycles.
                    foreach (Node n in l)
                    {
                        if (n.LabelString == label)
                        {
                            Network net = getNetwork();
                            if (net.checkForCycle(n, this))
                            {
                                ErrorDialog ed = new ErrorDialog();
                                ed.post("Unable to rename Receiver \"{0}\" to \"{1}\" " +
                                    "because that would cause a cyclic connection.", LabelString,
                                    label);
                                return false;
                            }
                        }
                    }
                }
                if (l != null)
                {
                    foreach (Node n in l)
                    {
                        if (label == n.LabelString)
                        {
                            found = true;
                            new Ark(n, 1, this, 1);
                        }
                    }
                }
            }

            // There was a name conflict because earlier versions of dx were less restrictive.
            // Record the transmitter for later fixup.  When the transmitter is fixed up,
            // then we'll automatically get fixed up also.  Caveat:  if there is no transmitter
            // connected, then it's cool to refuse the name because then we're not breaking
            // anything.
            if (conflict != null)
            {
                Debug.Assert(getNetwork().IsReadingNetwork);
                if (IsTransmitterConnected == false)
                {
                    ErrorDialog ed = new ErrorDialog();
                    ed.post("A {0} with name \"{1}\" already exists.", conflict, label);
                    return false;
                }
                List<Ark> l = getInputArks(1);
                Debug.Assert(l.Count>0);
                Ark a = l[0];
                int dummy;
                TransmitterNode tn = (TransmitterNode) a.getSourceNode(out dummy);
                getNetwork().fixupTransmitter(tn);
            }
            return base.setLabelString(label);
        }
Example #7
0
 protected override bool netParseAuxComment(string comment, string filename, int lineno)
 {
     // Compute comments are of the form
     // expression: value = a*0.1
     // name[2]: value = a
     if (comment.StartsWith(" expression:"))
     {
         setExpression(comment.Substring(comment.IndexOf('=') + 2), false);
         return true;
     }
     else if (comment.StartsWith(" name["))
     {
         Regex regex = new Regex(@" name\[(\d+)\]: value = (.+)");
         Match m = regex.Match(comment);
         if (m.Success)
         {
             int i = Int32.Parse(m.Groups[1].Value);
             setName(m.Groups[2].Value, i, false);
         }
         else
         {
             ErrorDialog ed = new ErrorDialog();
             ed.post("Erroneous 'name' comment file {0}, line {1}", filename, lineno);
         }
         return true;
     }
     else
         return base.netParseAuxComment(comment, filename, lineno);
 }
        public int connectToServer(int port, DXChild c)
        {
            bool wasQueued = false;
            String server;

            if (c != null)
            {
                server = c.getServer();
                if (!c.IsQueued)
                {
                    serverInfo.children.Remove(c);
                    c.unQueue();
                }
            }
            else
            {
                server = serverInfo.server;
            }
            DXPacketIF p = new DXPacketIF(server, port, DXChild.HostIsLocal(server));
            if (DXApplication.resource.debugMode)
                p.setEchoCallback(DXApplication.DebugEchoCallback, "need to get stderr");

            if (p.Error)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Connection to {0} failed.", server);
                p = null;
                return 0;
            }

            clearErrorList();
            if (serverInfo.packet == null)
            {
                if (wasQueued)
                {
                    InfoDialog id = new InfoDialog();
                    id.post("Your connection to {0} has been accepted.", server);
                }
                packetIFAccept(p);
            }
            else
            {
                serverInfo.queuedPackets.Insert(0, p);
                QuestionDialog qd = new QuestionDialog();
                String s = String.Format("Your connection to server {0} has been accepted. Do you want to disconnect from {0} and connect to it?",
                    server, serverInfo.server);
                qd.modalPost(this.getAnchorForm(), s, null, p, DXApplication.QueuedPacketAccept,
                    DXApplication.QueuedPacketCancel, null, "Yes", "No", null, 2);

            }
            return 1;
        }
Example #9
0
        protected virtual bool parseIOComment(bool input, String comment, 
            String filename, int lineno, bool valueOnly)
        {
            Regex regex;
            Match m;

            int defaulting = 0, allowed_params, ionum = 0;
            bool visible = true;
            DXTypeVals type = DXTypeVals.UndefinedType, r = DXTypeVals.UndefinedType;
            String ioname;
            bool parse_error = false;

            Debug.Assert(comment != null);

            if (input)
            {
                if (!comment.StartsWith(" input["))
                    return false;

                if (valueOnly)
                {
                    regex = new Regex(@" input\[(\d+)\]: defaulting = (\d+)");
                    m = regex.Match(comment);
                    if (!m.Success)
                        parse_error = true;
                    else
                    {
                        ionum = Int32.Parse(m.Groups[1].ToString());
                        defaulting = Int32.Parse(m.Groups[2].ToString());
                    }
                    type = DXTypeVals.UndefinedType;
                }
                else
                {
                    regex = new Regex(@" input\[(\d+)\]: defaulting = (\d+), visible = (\d+), type = (\d+)");
                    m = regex.Match(comment);
                    if (!m.Success)
                    {
                        regex = new Regex(@" input\[(\d+)\]: visible = (\d+)");
                        m = regex.Match(comment);
                        if (!m.Success)
                        {
                            regex = new Regex(@" input\[(\d+)\]: type = (\d+)");
                            m = regex.Match(comment);
                            if (!m.Success)
                            {
                                regex = new Regex(@" input\[(\d+)\]: defaulting (\d+), type = (\d+)");
                                m = regex.Match(comment);
                                if (!m.Success)
                                    parse_error = true;
                                else
                                {
                                    ionum = Int32.Parse(m.Groups[1].ToString());
                                    defaulting = Int32.Parse(m.Groups[2].ToString());
                                    type = (DXTypeVals)long.Parse(m.Groups[3].ToString());
                                }
                            }
                            else
                            {
                                ionum = Int32.Parse(m.Groups[1].ToString());
                                type = (DXTypeVals)long.Parse(m.Groups[2].ToString());
                            }
                        }
                        else
                        {
                            ionum = Int32.Parse(m.Groups[1].ToString());
                            visible = Int32.Parse(m.Groups[2].ToString()) > 0;
                            defaulting = 1;
                        }
                    }
                    else
                    {
                        ionum = Int32.Parse(m.Groups[1].ToString());
                        defaulting = Int32.Parse(m.Groups[2].ToString());
                        visible = Int32.Parse(m.Groups[3].ToString()) > 0;
                        type = (DXTypeVals)long.Parse(m.Groups[4].ToString());
                    }
                }
                ioname = "input";
                allowed_params = InputCount;
            }
            else // An output
            {
                if (!comment.StartsWith(" output["))
                    return false;

                if (valueOnly)
                {
                    regex = new Regex(@" output\[(\d+)\]: defaulting = (\d+)");
                    m = regex.Match(comment);
                    if (!m.Success)
                        parse_error = true;
                    type = DXTypeVals.UndefinedType;
                }
                else
                {
                    regex = new Regex(@" output\[(\d+)\]: visible = (\d+), type = (\d+)");
                    m = regex.Match(comment);
                    if (!m.Success)
                    {
                        regex = new Regex(@" output\[(\d+)\]: type = (\d+)");
                        m = regex.Match(comment);
                        if (!m.Success)
                        {
                            regex = new Regex(@" output\[(\d+)\]: visible = (\d+)");
                            m = regex.Match(comment);
                            if (!m.Success)
                                parse_error = true;
                            else
                            {
                                ionum = Int32.Parse(m.Groups[1].ToString());
                                visible = Int32.Parse(m.Groups[2].ToString())>0;
                            }
                        }
                        else
                        {
                            ionum = Int32.Parse(m.Groups[1].ToString());
                            type = (DXTypeVals)long.Parse(m.Groups[2].ToString());
                        }
                    }
                    else
                    {
                        ionum = Int32.Parse(m.Groups[1].ToString());
                        visible = Int32.Parse(m.Groups[2].ToString())>0;
                        type = (DXTypeVals)long.Parse(m.Groups[3].ToString());
                    }
                }
                ioname = "output";
                allowed_params = OutputCount;
            }
            if (parse_error)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Can't parse {0} comment file {1} line {2}", ioname,
                    filename, lineno);
                return true;
            }

            // If the input paramter is out of bounds, then something is wrong...
            if (ionum > allowed_params)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Bad {0} number ({1}) file {2} line {3}", input? "input":"output", ionum,
                    filename, lineno);
                return true;
            }

            // If parsed ok and node exists, convert value.
            if (comment.Contains("value ="))
            {
                String value = comment.Substring(comment.IndexOf("value =") + 8).Trim();

                if (value != null && value != "")
                {
                    if (getNetwork().getNetMajorVersion() <= 1)
                        type = DXType.ConvertVersionType(type);

                    if (input)
                    {
                        if (value.StartsWith("(") && value.EndsWith(")"))
                        {
                            // Skip descriptive settings
                            defaulting = 1;
                            r = DXTypeVals.ObjectType;
                        }
                        else if (defaulting > 0)
                        {
                            r = setInputSetValue(ionum, value, type, false);
                            if (r == DXTypeVals.UndefinedType &&
                                type != DXTypeVals.UndefinedType)
                                r = setInputSetValue(ionum, value, DXTypeVals.UndefinedType, false);
                        }
                        else
                        {
                            r = setInputValue(ionum, value, type, false);
                            if (r == DXTypeVals.UndefinedType &&
                                type != DXTypeVals.UndefinedType)
                                r = setInputValue(ionum, value, DXTypeVals.UndefinedType, false);
                        }
                    }
                    else
                    {
                        r = setOutputValue(ionum, value, type, false);
                        if (r == DXTypeVals.UndefinedType &&
                            type != DXTypeVals.UndefinedType)
                            r = setOutputValue(ionum, value, DXTypeVals.UndefinedType, false);
                    }
                }

                if (r == DXTypeVals.UndefinedType)
                {
                    ErrorDialog ed = new ErrorDialog();
                    ed.post("Encountered an erroneous input value (file {0}, line {1})",
                        filename, lineno);
                    return true;
                }
            }

            if (!valueOnly)
            {
                if (input)
                {
                    setInputVisibility(ionum, visible);
                }
                else
                {
                    useAssignedOutputValue(ionum, false);
                    setOutputVisibility(ionum, visible);
                }
            }

            return true;
        }
Example #10
0
        public static bool LoadMDFFile(String file, String mdftype,
            ref Dictionary<Symbol, NodeDefinition> mdf, bool uionly)
        {
            StreamReader input;
            bool parsed;

            if (file == null || file.Length == 0)
                return true;

            try
            {
                input = new StreamReader(file);
                parsed = ReadMDF(ref mdf, input, uionly);
                input.Close();

                if (!parsed)
                {
                    ErrorDialog ed = new ErrorDialog();
                    ed.post("Error found in {0} module definition file \"{1}\".",
                        mdftype, file);
                    return false;
                }
            }
            catch (System.IO.IOException e)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Cannot open {0} module description file \"{1}\".",
                    mdftype, file);
                return false;
            }
            return true;
        }
Example #11
0
        /// <summary>
        /// These are called when a 'node' comment is found in the .net.
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="filename"></param>
        /// <param name="lineno"></param>
        /// <returns></returns>
        protected bool netParseNodeComment(String comment, String filename,
            int lineno)
        {
            String node_name, labelstr;
            int instance, x, y, n_inputs, n_outputs;

            if (!comment.StartsWith(" node "))
                return false;

            Regex regex = new Regex(@" node (.*)\[(\d+)\]: x = (\d+), y = (\d+), inputs = (\d+), outputs = (\d+), label = (.*)");
            Match m = regex.Match(comment);
            if (!m.Success)
            {
                regex = new Regex(@" node (.*)\[(\d+)\]: x = (\d+), y = (\d+), inputs = (\d+), label = (.*)");
                m = regex.Match(comment);
                if (!m.Success)
                {
                    regex = new Regex(@" node (.*)\[(\d+)\]: x = (\d+), y = (\d+), label = (.*)");
                    m = regex.Match(comment);
                    if (!m.Success)
                    {
                        ErrorDialog ed = new ErrorDialog();
                        ed.post("Can not parse node comment at line {0} in file {1}", lineno, filename);
                        return true;
                    }
                    else
                    {
                        node_name = m.Groups[1].ToString();
                        instance = Int32.Parse(m.Groups[2].ToString());
                        x = Int32.Parse(m.Groups[3].ToString());
                        y = Int32.Parse(m.Groups[4].ToString());
                        labelstr = m.Groups[5].ToString();
                        n_inputs = InputCount;
                        n_outputs = OutputCount;
                    }
                }
                else
                {
                    node_name = m.Groups[1].ToString();
                    instance = Int32.Parse(m.Groups[2].ToString());
                    x = Int32.Parse(m.Groups[3].ToString());
                    y = Int32.Parse(m.Groups[4].ToString());
                    n_inputs = Int32.Parse(m.Groups[5].ToString());
                    labelstr = m.Groups[6].ToString();
                    n_outputs = OutputCount;
                }
            }
            else
            {
                node_name = m.Groups[1].ToString();
                instance = Int32.Parse(m.Groups[2].ToString());
                x = Int32.Parse(m.Groups[3].ToString());
                y = Int32.Parse(m.Groups[4].ToString());
                n_inputs = Int32.Parse(m.Groups[5].ToString());
                n_outputs = Int32.Parse(m.Groups[6].ToString());
                labelstr = m.Groups[7].ToString();
            }

            Symbol s = SymbolManager.theSymbolManager.registerSymbol(node_name);
            NodeDefinition nd;
            if (!NodeDefinition.theNodeDefinitionDictionary.TryGetValue(s, out nd) || nd == null)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Undefined module {0} at line {1} in file {2}",
                    node_name, lineno, filename);
                return false;
            }

            setLabelString(labelstr);

            setInstanceNumber(instance);
            setVpePosition(x, y);

            // Count the inputs, if not the default and the inputs are repeatable
            // then add some inputs. If there are fewer inputs in the file, silently
            // assume that this is an old network.

            if (n_inputs != InputCount)
            {
                if (isInputRepeatable())
                {
                    int delta_inputs = n_inputs - InputCount;
                    bool adding = delta_inputs > 0;
                    if (!adding)
                        delta_inputs = -delta_inputs;
                    int sets;
                    if (delta_inputs % InputRepeatCount != 0)
                    {
                        ErrorDialog ed = new ErrorDialog();
                        ed.post("Number of repeatable input parameters does not " +
                            "divide number of parameters for module {0}", NameString);
                        return true;
                    }
                    sets = delta_inputs / InputRepeatCount;
                    for (int i = 0; i < sets; i++)
                    {
                        if (adding)
                        {
                            if (!addInputRepeats())
                            {
                                ErrorDialog ed = new ErrorDialog();
                                ed.post("Can't add repeated input parameters");
                                return true;
                            }
                        }
                        else
                        {
                            if (!removeInputRepeats())
                            {
                                ErrorDialog ed = new ErrorDialog();
                                ed.post("Can't remove repeated input parameters");
                                return true;
                            }
                        }
                    }
                }
            }
            if (n_outputs != OutputCount)
            {
                if (isOutputRepeatable())
                {
                    int delta_outputs = n_outputs - OutputCount;
                    bool adding = delta_outputs > 0;
                    if (!adding)
                        delta_outputs = -delta_outputs;
                    int sets;
                    if (delta_outputs % OutputRepeatCount != 0)
                    {
                        ErrorDialog ed = new ErrorDialog();
                        ed.post("Number of repeatable output parameters does not " +
                            "divide number of parameters for module {0}", NameString);
                        return true;
                    }
                    sets = delta_outputs / OutputRepeatCount;
                    for (int i = 0; i < sets; i++)
                    {
                        if (adding)
                        {
                            if (!addOutputRepeats())
                            {
                                ErrorDialog ed = new ErrorDialog();
                                ed.post("Can't add repeated output parameters");
                                return true;
                            }
                        }
                        else
                        {
                            if (!removeOutputRepeats())
                            {
                                ErrorDialog ed = new ErrorDialog();
                                ed.post("Can't remove repeated output parameters");
                                return true;
                            }
                        }
                    }
                }
            }

            // Increment the module instance count if the current node
            // instance count is higher
            if (instance > definition.getCurrentInstance())
                definition.setNextInstance(instance + 1);

            return true;
        }
Example #12
0
        public static NodeDefinition ParseModuleLine(Dictionary<Symbol, NodeDefinition> mdf,
            String line, int lineNumber)
        {
            int current;
            int temp;
            String function;
            NodeDefinition module = null;

            Debug.Assert(mdf != null);
            Debug.Assert(line != null);
            Debug.Assert(lineNumber > 0);

            line = line.Trim();

            Regex rx = new Regex(@"^MODULE\s+([a-zA-Z_]\w*)$");
            Match m = rx.Match(line);
            if (!m.Success)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Invalid module name: {0} must start with a letter and contain only letters and numbers (line {1})",
                    line, lineNumber);
                return null;
            }
            function = m.Groups[1].Value;
            Symbol s = SymbolManager.theSymbolManager.registerSymbol(function);
            if (mdf.ContainsKey(s))
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Encountered another definition of module \"{0}\" on line {1}",
                    function, lineNumber);
                return null;
            }

            // Get a new NodeDefinition by name
            module = NDAllocatorDictionary.theNDAllocatorDictionary.allocate(function);
            if (module == null)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Can not find NodeDefinition allocator for module '{0}'",
                    function);
                return null;
            }
            module.setName(function);
            return module;
        }
Example #13
0
        public static bool ParseOutputLine(Dictionary<Symbol, NodeDefinition> mdf,
            ref NodeDefinition module, String line, int lineNumber)
        {
            Debug.Assert(mdf != null);
            Debug.Assert(module != null);
            Debug.Assert(line != null);
            Debug.Assert(lineNumber > 0);

            Symbol symbol;
            ParameterDefinition output;

            List<String> toks = Utils.StringTokenizer(line, ";", new String[] { "" });

            if (toks.Count < 3)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Encountered an erroneous OUTPUT specification on line {0}.", lineNumber);
                return false;
            }

            // Parse the first substring: NAME and optional attributes
            String iname;
            int bracketStart = toks[0].IndexOf('[');
            if (bracketStart >= 0)
                iname = toks[0].Substring(0, bracketStart);
            else
                iname = toks[0];

            iname = iname.Trim();
            Regex rx = new Regex(@"^([a-zA-Z_][0-9a-zA-Z_]*)$");
            Match m = rx.Match(iname);
            if (!m.Success)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Invalid output name: {0} line {1}",
                    iname, lineNumber);
                return false;
            }

            symbol = SymbolManager.theSymbolManager.registerSymbol(iname);
            output = new ParameterDefinition(symbol);
            output.markAsOutput();
            output.setDefaultVisibility();

            if (toks[0].Contains("["))
            {
                int begin_att = toks[0].IndexOf('[');
                int end_att = toks[0].Substring(begin_att).IndexOf(']');
                String atts = null;
                if (end_att > 0)
                    atts = toks[0].Substring(begin_att, end_att);
                if (atts != null)
                    if (!ParseParameterAttributes(ref output, atts))
                    {
                        ErrorDialog ed = new ErrorDialog();
                        ed.post("Unrecognized input attribute(s) ({0}) in MDF line {1}",
                            atts, lineNumber);
                        return false;
                    }
            }

            // Parse the second substring: TYPE.
            if (!ParseMDFTypes(ref output, toks[1], lineNumber))
                return false;

            // Parse the third substring:  DESCRIPTION

            output.setDescription(toks[2]);

            module.addOutput(output);
            return true;
        }
Example #14
0
 /// <summary>
 /// See if the given string is a viable label to be used as an identifier.
 /// Also make sure it is not a reserved script language word.
 /// Return TRUE if ok, FALSE otherwise and issue and error message.
 /// </summary>
 /// <param name="label"></param>
 /// <returns></returns>
 protected bool verifyRestrictedLabel(String label)
 {
     int junk = 0;
     if (!Utils.IsIdentifier(label))
     {
         ErrorDialog ed = new ErrorDialog();
         ed.post("{0} name \"{1}\" must consist of letters, numbers, or the " +
             "character '_', and begin with a letter", NameString, label);
         return false;
     }
     if (Utils.IsReservedScriptingWord(label))
     {
         ErrorDialog ed = new ErrorDialog();
         ed.post("{0} name \"{1}\" is a reserved word", NameString, label);
         return false;
     }
     return true;
 }
Example #15
0
        public static bool ParseLoadableLine(ref NodeDefinition module, String line,
            int lineNumber)
        {
            Debug.Assert(module != null);
            Debug.Assert(line != null);
            Debug.Assert(lineNumber > 0);

            line = line.Trim();
            int sem = line.IndexOf(';');
            if (sem >= 0)
                line = line.Substring(0, sem);

            if (line.Length == 0)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Encountered an erroneous LOADABLE specification on line {0}.", lineNumber);
                return false;
            }
            module.DynamicLoadFile = line;
            return true;
        }
Example #16
0
        public bool setMessageIdParameter(int id_index)
        {
            String id = getModuleMessageIdString();

            if (id_index == 0)
            {
                id_index = getMessageIdParamNumber();
                if (id_index == 0)
                    return true;
            }

            if (setInputValue(id_index, id, DXTypeVals.StringType, false) ==
                DXTypeVals.UndefinedType)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Error setting message id string for node {0}, check ui.mdf",
                    NameString);
            }
            return true;
        }
Example #17
0
 /// <summary>
 /// Make sure the number of inputs is the number expected.
 /// </summary>
 /// <returns></returns>
 protected bool verifyInputCount()
 {
     if (InputCount != EXPECTED_SCALAR_INPUTS)
     {
         ErrorDialog ed = new ErrorDialog();
         ed.post("Expected {0} inputs for {1} interactor, please check the mdf file.",
             EXPECTED_SCALAR_INPUTS,
             NameString);
         return false;
     }
     return true;
 }
        public override bool setLabelString(String label)
        {
            if (label == LabelString)
                return true;

            List<Node> rnl = this.getNetwork().makeClassifiedNodeList(typeof(ReceiverNode), false);

            if (initializing || getNetwork().IsReadingNetwork)
            {
                if (!initializing)
                {
                    //
                    // Because of an old bug (hopefully fixed in 3.1.4), we need to scan
                    // for existing receivers with the same name.  These receivers are supposed
                    // to be placed later in the .net file than the transmitter.  Network::
                    // mergeNetworks() was not connecting up transmitters and receivers properly
                    // until 3.1.4.  So this check will work around a bug.
                    //
                    Network net = this.getNetwork();
                    int net_major = net.getNetMajorVersion();
                    int net_minor = net.getNetMinorVersion();
                    int net_micro = net.getNetMicroVersion();
                    int net_version = Utils.VersionNumber(net_major, net_minor, net_micro);
                    int fixed_version = Utils.VersionNumber(3, 1, 1);
                    if (net_version < fixed_version)
                    {
                        // grab up any receivers that already have this name
                        if (rnl != null)
                        {
                            foreach (Node node in rnl)
                            {
                                ReceiverNode rn = (ReceiverNode)node;
                                if (!rn.IsTransmitterConnected &&
                                    node.LabelString == label)
                                {
                                    Network lnet = getNetwork();
                                    if (!lnet.checkForCycle(this, node))
                                    {
                                        new Ark(this, 0, node, 0);
                                    }
                                    else
                                    {
                                        WarningDialog wd = new WarningDialog();
                                        String msg = "This network contains Transmitter/Receiver " +
                                            "pair \"{0}\" which would cause a cyclic " +
                                            "connection. Executing this network will yield " +
                                            "unpredictable results until this is fixed.";
                                        wd.post(msg, LabelString);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                return base.setLabelString(label);
            }
            if (!verifyRestrictedLabel(label))
                return false;

            String conflict = getNetwork().nameConflictExists(this, label);
            if (conflict != null)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("A {0} with name \"{1}\" already exists.", conflict, label);
                return false;
            }

            if (!getNetwork().IsReadingNetwork)
            {
                if (rnl != null)
                {
                    foreach (Node nd in rnl)
                    {
                        ReceiverNode rn = (ReceiverNode)nd;
                        if (!rn.IsTransmitterConnected &&
                            rn.LabelString == label)
                        {
                            if (getNetwork().checkForCycle(this, rn))
                            {
                                ErrorDialog ed = new ErrorDialog();
                                ed.post("Unable to rename Transmitter \"{0}\" to \"{1}\" because it would create a cyclic connection.",
                                    LabelString, label);
                                return false;
                            }
                        }
                    }
                }
            }

            if (!base.setLabelString(label))
                return false;

            // Rename receivers
            List<Ark> reclist = getOutputArks(0);
            foreach (Ark a in reclist)
            {
                int dummy;
                Node rcvr = a.getDestinationNode(out dummy);
                rcvr.setLabelString(label);
            }

            // grab up any receivers that already have this name
            // We've already done the check for cyclic connections.
            if (rnl != null)
            {
                foreach (Node nd in rnl)
                {
                    ReceiverNode rn = (ReceiverNode)nd;
                    if (!rn.IsTransmitterConnected &&
                        LabelString == label)
                    {
                        new Ark(this, 0, rn, 0);
                    }
                }
            }
            return true;
        }
Example #19
0
        protected virtual void parsePacket()
        {
            int id;
            int type;
            int data_length;
            int i = 0;
            int j;
            int k;

            List<String> toks = Utils.StringTokenizer(line, "|", null);

            if (toks.Count < 4)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Format error encountered in packet.");
                return;
            }

            id = Convert.ToInt32(toks[0]);

            for (type = 0; i < PacketTypes.Length; type++)
            {
                if (toks[1] == PacketTypes[type])
                    break;
            }
            if (type >= PacketTypes.Length)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Unknown packet type \"{0}\" encountered", toks[1]);
                return;
            }

            data_length = Convert.ToInt32(toks[2]);

            // Skip past the fourth vertical bar and extract the data.
            bool iocerr = false;
            int ioc = line.IndexOf('|');
            if (ioc < 0)
                iocerr = true;
            ioc = line.IndexOf('|', ioc + 1);
            if (ioc < 0)
                iocerr = true;
            ioc = line.IndexOf('|', ioc + 1);
            if (ioc < 0)
                iocerr = true;
            ioc = line.IndexOf('|', ioc + 1);
            if (ioc < 0)
                iocerr = true;

            String data = line.Substring(ioc+1, data_length);

            if ((line.ToCharArray())[ioc + data_length + 1] != '|' || iocerr)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Unknown packet type \"{0}\" encountered", toks[1]);
                return;
            }

            if (echoCallback != null)
            {
                String s = String.Format("Received {0}:{1}: {2}",
                    PacketIF.PacketTypes[type], id, data);
                echoCallback(echoClientData, s);
            }

            char [] pakws = {' ', ':'};
            data.TrimStart(pakws);

            PacketHandler ph = null;

            //
            // Check for strings that exactly match the handler's match string
            // (In the case of data-driven interactors, there will never be an
            // exact match.)
            //
            foreach (PacketHandler h in handlers)
            {
                if (h.MatchString != null &&
                    ((h.Number == id && ((int) h.Type == type || (int) h.Type == -1)) ||
                    (h.Number == 0 && (int) h.Type == type)) &&
                    h.match(data))
                {
                    ph = h;
                    break;
                }
            }

            //
            // If we didn't find an exact match, then check for strings that match
            // the handler's match string for the length of the match string.
            //
            if (ph == null)
            {
                int longest_match_so_far = 0;
                PacketHandler best_handler = null;
                foreach (PacketHandler h in handlers)
                {
                    if (h.MatchString != null &&
                        (((int) h.Type == id && ((int)h.Type == type || (int)h.Type == -1)) ||
                        (h.Number == 0 && (int)h.Type == type)) &&
                        h.matchFirst(data))
                    {
                        int len = h.MatchString.Length;
                        if (len > longest_match_so_far)
                        {
                            best_handler = h;
                            longest_match_so_far = len;
                        }
                    }
                }
                ph = best_handler;
            }

            //
            // If we still didn't find an match, then check for handlers that don't
            // have match string specified, implying they match any string.
            //
            if (ph == null)
            {
                foreach (PacketHandler h in handlers)
                {
                    if (h.MatchString == null &&
                        ((h.Number == id && ((int)h.Type == type || (int)h.Type == -1)) ||
                        (h.Number == 0 && (int)h.Type == type)))
                    {
                        ph = h;
                        break;
                    }
                }
            }

            if (ph != null)
            {
                ph.callCallback(id, data);
                if (!ph.Linger)
                {
                    handlers.Remove(ph);
                }
            }
        }
Example #20
0
 protected static void HandleApplicationError(Object clientData, String message)
 {
     DXApplication app = (DXApplication)clientData;
     if (app != null)
     {
         ErrorDialog ed = new ErrorDialog();
         ed.post(message, null);
         app.disconnectFromApplication(true);
     }
 }
Example #21
0
        public static bool ParseInputLine(Dictionary<Symbol, NodeDefinition> mdf,
            ref NodeDefinition module, String line, int lineNumber)
        {
            Debug.Assert(mdf != null);
            Debug.Assert(module != null);
            Debug.Assert(line != null);
            Debug.Assert(lineNumber > 0);
            ParameterDefinition input = null;
            Symbol symbol;

            List<String> toks = Utils.StringTokenizer(line, ";", new String[] { "" });

            if (toks.Count < 3)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Encountered an erroneous INPUT specification on line {0}.", lineNumber);
                return false;
            }

            // Parse the first substring: NAME and optional attributes
            String iname;
            int bracketStart = toks[0].IndexOf('[');
            if (bracketStart >= 0)
                iname = toks[0].Substring(0, bracketStart);
            else
                iname = toks[0];

            iname = iname.Trim();
            Regex rx = new Regex(@"^([a-zA-Z_]\w*)$");
            Match m = rx.Match(iname);
            if (!m.Success)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Invalid input name: {0} line {1}",
                    iname, lineNumber);
                return false;
            }

            symbol = SymbolManager.theSymbolManager.registerSymbol(iname);
            input = new ParameterDefinition(symbol);
            input.markAsInput();
            input.setDefaultVisibility();

            if (toks[0].Contains("["))
            {
                int begin_att = toks[0].IndexOf('[');
                int end_att = toks[0].Substring(begin_att).IndexOf(']');
                String atts = null;
                if (end_att > 0)
                    atts = toks[0].Substring(begin_att, end_att);
                if (atts != null)
                    if (!ParseParameterAttributes(ref input, atts))
                    {
                        ErrorDialog ed = new ErrorDialog();
                        ed.post("Unrecognized input attribute(s) ({0}) in MDF line {1}",
                            atts, lineNumber);
                        return false;
                    }
            }

            // Parse the second substring: TYPE.
            if (!ParseMDFTypes(ref input, toks[1], lineNumber))
                return false;

            // Parse the third substring:  DEFAULT VALUE.

            // If the value is equal to "(none)", then mark this parameter
            // as a required parameter.

            toks[2] = toks[2].Trim();
            if (toks[2].StartsWith("("))
            { // A descriptive value
                if (toks[2] == "(none)")
                    input.setRequired();
                else
                    input.setNotRequired();
                input.setDescriptiveValue(toks[2]);
            }
            else if (!input.setDefaultValue(toks[2]))
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Default value given on line {0} not one of given types.", lineNumber);
                return false;
            }

            // Add the fourth substring:  DESCRIPTION
            // Description can be blank
            if (toks.Count == 3)
                input.setDescription("");
            else
                input.setDescription(toks[3]);

            module.addInput(input);
            return true;
        }
 public virtual bool moveIndex(int index, bool issue_error)
 {
     if (index == this.index)
         return true;
     if (this.index == -1)
     {
         setIndex(index);
         return true;
     }
     bool result;
     if (IsInput)
         result = getNetwork().moveInputPosition(this, index);
     else
         result = getNetwork().moveOutputPosition(this, index);
     if (result)
         setIndex(index);
     else if (issue_error)
     {
         ErrorDialog ed = new ErrorDialog();
         ed.post("Cannot move {0} {1} to {2}, it would overwrite another {3}.",
             NameString, this.index, index, NameString);
     }
     if (getConfigurationDialog() != null)
     {
         if (IsInput)
             getConfigurationDialog().changeInput(1);
         else
             getConfigurationDialog().changeOutput(1);
     }
     return result;
 }
Example #23
0
        public static bool ParseMDFTypes(ref ParameterDefinition param, String p, int lineNumber)
        {
            DXType input_type;
            Regex reg = new Regex(" or ");
            p = reg.Replace(p, " | ");

            List<String> types = Utils.StringTokenizer(p, "|", new String[] { "" });
            DXTypeVals type;
            foreach (String str in types)
            {
                String sstr = str.Trim();
                type = DXType.StringToType(sstr);
                if (type == DXTypeVals.UndefinedType)
                {
                    ErrorDialog ed = new ErrorDialog();
                    ed.post("Erroneous parameter type encountered in line {0}.", lineNumber);
                    return false;
                }

                input_type = new DXType(type);
                bool r = param.addType(input_type);
                Debug.Assert(r);
            }
            return true;
        }
        /// <summary>
        /// Based on the node's connectivity, select values for OPTIONS
        /// automatically.  The strategy is
        /// - Try to keep the OPTIONS the node already has.
        /// - look for OPTIONS in the next connected downstream node(s)
        /// - for each value in OPTIONS, see if the value can be coerced
        ///   to our current type(s)
        /// - Prefer to use OPTIONS from the node at the other end of 
        ///   prefer because it's probably the node were adding via ::addIOArk().
        ///
        /// At this point in the code, our new list of types has already been
        /// computed based on our new connectivity.
        /// </summary>
        /// <param name="pref"></param>
        private void setTypeSafeOptions(Ark pref)
        {
            // This method is nonsense in the case of an Output tool.
            Debug.Assert(IsInput);

            // If we have OPTIONS && any item in OPTION is illegal input given
            // our new type, then remove all the OPTIONS.
            ParameterDefinition macroPd = getParameterDefinition();
            String[] options = macroPd.getValueOptions();
            List<DXType> types = macroPd.getTypes();
            bool can_coerce = true;
            if (options != null && options.Length > 0)
            {
                can_coerce = true;
                for (int i = 0; i < options.Length && can_coerce; i++)
                {
                    can_coerce = can_coerce && canCoerceValue(options[i], types);
                }
                if (!can_coerce)
                {
                    macroPd.removeValueOptions();
                    options = null;
                }
            }

            //If our current OPTIONS are safe to keep using...
            if (options != null && options.Length > 0)
                return;

            // If the parameter has no option values, then check each downstream
            // input tab.  If any has option values, then try to use those but
            // only if each of the option values is legal given our new type.
            Node destination;
            NodeDefinition destinationDef;
            ParameterDefinition destinationParamDef;
            int paramIndex;

            // First check the new ark to see if it gave give us
            // option values.  option strings are stored as a null-terminated
            // array of char*.
            String[] dest_option_values = null;
            can_coerce = true;
            if (pref != null)
            {
                destination = pref.getDestinationNode(out paramIndex);
                destinationDef = destination.Definition;
                destinationParamDef = destinationDef.getInputDefinition(paramIndex);
                dest_option_values = destinationParamDef.getValueOptions();

                if (dest_option_values != null && dest_option_values.Length > 0)
                {
                    for (int i = 0; i < dest_option_values.Length && can_coerce; i++)
                    {
                        can_coerce = can_coerce && canCoerceValue(dest_option_values[i], types);
                    }
                }
            }

            if (can_coerce && dest_option_values != null && dest_option_values.Length > 0)
            {
                for (int i = 0; i < dest_option_values.Length; i++)
                {
                    if (!macroPd.addValueOption(dest_option_values[i]))
                    {
                        ErrorDialog ed = new ErrorDialog();
                        ed.post("Cannot add {0} to Options values", dest_option_values[i]);
                        break;
                    }
                }
            }
            else
            {
                // get all the destination nodes  When we're called as via ::addIOArk(),
                // the new connection has not yet been added to our list
                // of downstream nodes.
                List<Ark> arks = getOutputArks(1);
                foreach (Ark ark in arks)
                {
                    destination = ark.getDestinationNode(out paramIndex);
                    destinationDef = destination.Definition;
                    destinationParamDef = destinationDef.getInputDefinition(paramIndex);

                    // for each option value see, see if it can be coerced.
                    dest_option_values = destinationParamDef.getValueOptions();
                    if (dest_option_values == null || dest_option_values.Length == 0) continue;

                    can_coerce = true;
                    for (int i = 0; i < dest_option_values.Length && can_coerce; i++)
                    {
                        can_coerce = can_coerce && canCoerceValue(dest_option_values[i], types);
                    }
                    if (can_coerce)
                    {
                        for (int i = 0; i < dest_option_values.Length; i++)
                        {
                            if (!macroPd.addValueOption(dest_option_values[i]))
                            {
                                ErrorDialog ed = new ErrorDialog();
                                ed.post("Cannot add {0} to Options values",
                                    dest_option_values[i]);
                                break;
                            }
                        }
                        break;
                    }
                }
            }
        }
Example #25
0
        public static bool ParseOutboardLine(ref NodeDefinition module, String line,
            int lineNumber)
        {
            Debug.Assert(module != null);
            Debug.Assert(line != null);
            Debug.Assert(lineNumber > 0);

            line = line.Trim();
            List<String> toks = Utils.StringTokenizer(line, ";", null);
            if (toks.Count < 1)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Encountered an erroneous OUTBOARD specification on line {0}", lineNumber);
                return false;
            }
            module.OutboardCommand = toks[0];
            if (toks.Count > 1)
                module.DefaultOutboardHost = toks[1];

            return true;
        }
Example #26
0
        public override bool initialize(ref string[] argv)
        {
            bool wasSetBusy = false;

            base.initialize(ref argv);

            if (!DXApplication.DXApplicationClassInitialized)
            {
                installDefaultResources();
                DXApplicationClassInitialized = true;
            }

            if (resource.executiveModule == null)
                resource.executiveModule = "lib/dx.mdf";
            if (resource.uiModule == null)
                resource.uiModule = "ui/ui.mdf";
            if (resource.userModules == null)
                resource.userModules = Environment.GetEnvironmentVariable("DXMDF");
            if (resource.macros == null)
                resource.macros = Environment.GetEnvironmentVariable("DXMACROS");
            if (resource.server == null)
                resource.server = Environment.GetEnvironmentVariable("DXHOST");
            if (resource.server == null)
                resource.server = "localhost";
            if (resource.server.Contains(","))
            {
                // Remove the port number if it exists (i.e DXHOST=slope,1920)
                resource.server = resource.server.Substring(0, resource.server.IndexOf(','));
            }
            if (resource.netPath == null)
                resource.netPath = Environment.GetEnvironmentVariable("DXNETPATH");
            if (resource.cryptKey == null)
                resource.cryptKey = Environment.GetEnvironmentVariable("DXCRYPTKEY");

            // If the app does not allow editor access or we are starting up without
            // displaying the anchor window, force one of (image or menubar) mode.
            if ((InEditMode && !appAllowsEditorAccess()) ||
                resource.noAnchorAtStartup)
            {
                if (InMenuBarMode)
                    resource.anchorMode = MENUBAR_ANCHOR_MODE;
                else
                    resource.anchorMode = IMAGE_ANCHOR_MODE;
            }

            // Echo the resources.
            if (resource.debugMode)
            {
                if (resource.port != 0)
                    Console.WriteLine("port        = {0}", resource.port);
                if (resource.memorySize != 0)
                    Console.WriteLine("memory size = {0}", resource.memorySize);
                if (resource.server != null)
                    Console.WriteLine("server = {0}", resource.server);
                if (resource.executive != null)
                    Console.WriteLine("executive = {0}", resource.executive);
                if (resource.workingDirectory != null)
                    Console.WriteLine("working directory = {0}",
                     resource.workingDirectory);
                if (resource.netPath != null)
                    Console.WriteLine("net path = {0}", resource.netPath);
                if (resource.program != null)
                    Console.WriteLine("program = {0}", resource.program);
                if (resource.cfgfile != null)
                    Console.WriteLine("cfgfile = {0}", resource.cfgfile);
                if (getUIRoot() != null)
                    Console.WriteLine("root = {0}", getUIRoot());
                if (resource.macros != null)
                    Console.WriteLine("macros = {0}", resource.macros);
                if (resource.errorPath != null)
                    Console.WriteLine("error path = {0}", resource.errorPath);
                if (resource.echoVersion)
                    Console.WriteLine("echo version");
                if (resource.anchorMode != null)
                    Console.WriteLine("anchor mode = {0}", resource.anchorMode);
                if (resource.noAnchorAtStartup)
                    Console.WriteLine("hiding anchor at startup");
                if (resource.debugMode)
                    Console.WriteLine("debug mode");
                if (resource.runUIOnly)
                    Console.WriteLine("run UI only");
                if (resource.showHelpMessage)
                    Console.WriteLine("show help message");
                if (resource.userModules != null)
                    Console.WriteLine("user mdf = {0}", resource.userModules);
                if (resource.executiveModule != null)
                    Console.WriteLine("executive mdf = {0}", resource.executiveModule);
                if (resource.uiModule != null)
                    Console.WriteLine("ui mdf = {0}", resource.uiModule);
                if (resource.suppressStartupWindows)
                    Console.WriteLine("suppress startup windows");

                if (resource.applicationPort != 0)
                    Console.WriteLine("application port = {0}", resource.applicationPort);
                if (resource.applicationHost != null)
                    Console.WriteLine("application host = {0}", resource.applicationHost);

                //
                // Image printing resources.
                //
                if (resource.printImageCommand != null)
                    Console.WriteLine("print image command = '{0}'",
                        resource.printImageCommand);
                if (resource.printImageFormat != null)
                    Console.WriteLine("print image format = '{0}'",
                        resource.printImageFormat);
                if (resource.printImagePageSize != null)
                    Console.WriteLine("print image page size = '{0}'",
                        resource.printImagePageSize);
                Console.WriteLine("print image resolution = {0}",
                        resource.printImageResolution);

                //
                // Image saving resources.
                //
                if (resource.saveImageFormat != null)
                    Console.WriteLine("save image format = '{0}'",
                        resource.saveImageFormat);
                if (resource.saveImagePageSize != null)
                    Console.WriteLine("save image page size = '{0}'",
                        resource.saveImagePageSize);
                Console.WriteLine("save image resolution = {0}",
                        resource.saveImageResolution);

                //
                // UI restrictions
                //
                if (resource.restrictionLevel != null)
                    Console.WriteLine("restriction level {0}",
                            resource.restrictionLevel);
                if (resource.noEditorAccess)
                    Console.WriteLine("no editor access");
                if (resource.limitedNetFileSelection)
                    Console.WriteLine("limited network file selection");
                if (resource.noImageRWNetFile)
                    Console.WriteLine("no net file read/write");
                if (resource.noImageSaving)
                    Console.WriteLine("no image saving");
                if (resource.noImagePrinting)
                    Console.WriteLine("no image printing");
                if (resource.noImageLoad)
                    Console.WriteLine("no image load ");
                if (resource.limitImageOptions)
                    Console.WriteLine("limit image options");
                if (resource.noRWConfig)
                    Console.WriteLine("no cfg save");
                if (resource.noPanelEdit)
                    Console.WriteLine("no panel edit");
                if (resource.noInteractorEdits)
                    Console.WriteLine("no interactor style");
                if (resource.noInteractorAttributes)
                    Console.WriteLine("no interactor attributes");
                if (resource.noInteractorMovement)
                    Console.WriteLine("no interactor movement");
                if (resource.noOpenAllPanels)
                    Console.WriteLine("no open all panels");
                if (resource.noPanelAccess)
                    Console.WriteLine("no panel access");
                if (resource.noPanelOptions)
                    Console.WriteLine("no panel options");
                if (resource.noMessageInfoOption)
                    Console.WriteLine("no message info option");
                if (resource.noMessageWarningOption)
                    Console.WriteLine("no message warning option");
                if (resource.noDXHelp)
                    Console.WriteLine("no DX help");

                //
                // automatic graph layout
                //
                if (resource.autoLayoutHeight > 0)
                    Console.WriteLine("automatic graph layout height = {0}",
                    resource.autoLayoutHeight);
                if (resource.autoLayoutGroupSpacing > 0)
                    Console.WriteLine("automatic graph layout group spacing = {0}",
                    resource.autoLayoutGroupSpacing);
                if (resource.autoLayoutNodeSpacing > 0)
                    Console.WriteLine("automatic graph layout node spacing = {0}",
                    resource.autoLayoutNodeSpacing);
            }

            if (resource.echoVersion)
            {
                String vers = String.Format("{0} User Interface, version {1}.{2}.{3} ({4})",
                    getFormalName(), global::WinDX.UI.Resources.MAJOR_VERSION,
                global::WinDX.UI.Resources.MINOR_VERSION,
                global::WinDX.UI.Resources.MICRO_VERSION,
                File.GetLastWriteTime(Application.ExecutablePath));

                MessageBox.Show(vers, "Version");
                Application.Exit();
            }

            // Fix me! May need to turn off help here.

            // Validate and set automatic graph layout values
            if (resource.autoLayoutHeight > 0)
            {
                String errmsg = GraphLayout.SetHeightPerLevel(resource.autoLayoutHeight);
                if (errmsg != null)
                {
                    MessageBox.Show(errmsg, "Startup Error");
                    return false;
                }
            }
            if (resource.autoLayoutGroupSpacing > 0)
            {
                String errmsg = GraphLayout.SetGroupSpacing(resource.autoLayoutGroupSpacing);
                if (errmsg != null)
                {
                    MessageBox.Show(errmsg, "Startup Error");
                    return false;
                }
            }
            if (resource.autoLayoutNodeSpacing > 0)
            {
                String errmsg = GraphLayout.SetNodeSpacing(resource.autoLayoutNodeSpacing);
                if (errmsg != null)
                {
                    MessageBox.Show(errmsg, "Startup Error");
                    return false;
                }
            }

            // Post the copyright message if the anchor window came up.
            if (!resource.noAnchorAtStartup)
                postCopyrightNotice();

            // Validate the resources and options
            if (InEditMode && !appAllowsEditorAccess())
            {
                MessageBox.Show("-edit and -noEditorAccess options are incompatible.", "Startup Error");
                return false;
            }

            if (appAllowsImageRWNetFile() && appLimitsNetFileSelection() &&
                resource.netPath == null)
            {
                MessageBox.Show("The \"limitedNetFileSelection\" or \"noImageRWNetFile\" " +
                    "option requires\na directory pathname specified by " +
                    "the \"DXNETPATH\" environment variable, \n" +
                    "the -netPath command line option, or\n" +
                    "the *netPath resource.", "Startup Error");
                return false;
            }

            // Setup Server Information
            serverInfo.autoStart = (resource.port <= 0);
            serverInfo.server = resource.server;
            serverInfo.executive = resource.executive;
            serverInfo.workingDirectory = resource.workingDirectory;
            serverInfo.userModules = resource.userModules;
            serverInfo.port = (resource.port == 0 ? 1900 : resource.port);
            serverInfo.memorySize = resource.memorySize;
            serverInfo.executiveFlags = "";
            serverInfo.children = new List<DXChild>();
            serverInfo.queuedPackets = new List<DXPacketIF>();

            if (argv != null)
            {
                foreach (String arg in argv)
                {
                    serverInfo.executiveFlags += arg + " ";
                }
            }

            if (InDataViewerMode)
            {
                resource.executeOnChange = true;
                resource.noImageRWNetFile = true;
                resource.noRWConfig = true;
                resource.noImageLoad = true;
                resource.noDXHelp = true;
                resource.noPGroupAssignment = true;
                resource.limitImageOptions = true;
                resource.noScriptCommands = true;
                resource.noConnectionMenus = true;
                resource.noWindowsMenus = true;
                resource.anchorMode = IMAGE_ANCHOR_MODE;
                resource.noAnchorAtStartup = true;
                resource.suppressStartupWindows = true;
                resource.noConfirmedQuit = true;
            }

            // Create the first/root/anchor network and place it in the
            // network list.
            network = newNetwork();

            if (appAllowsEditorAccess())
            {
                // Initialize the ConfigurationDialog allocator for the editor
                CDBAllocatorDictionary.theCDBAllocatorDictionary = new CDBAllocatorDictionary();

                // Initialize the StandIn allocator for the editor.
                SIAllocatorDictionary.theSIAllocatorDictionary = new SIAllocatorDictionary();
            }
            // Move to the indicated directory
            if (serverInfo.workingDirectory != null)
            {
                try
                {
                    Directory.SetCurrentDirectory(serverInfo.workingDirectory);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Unable to set Working Directory");
                }
            }

            loadMDF();
            loadIDF();
            if (resource.userModules != null)
                loadUDF(resource.userModules, null, false);

            // Decorator Styles
            DecoratorStyle.BuildtheDecoratorStyleDictionary();

            // load the initial set of user macros.
            MacroDefinition.LoadMacroDirectories(resource.macros);

            // Create the anchor window
            if (!InEditMode)
            {
                if (InImageMode)
                    anchor = newImageWindow(network);
                else if (InMenuBarMode)
                    anchor = new DXAnchorWindow("dxAnchor", true, true);
                else
                {
                    MessageBox.Show("Unrecognized anchor mode.", "Startup Error");
                    Application.Exit();
                }
                // Initialize the anchor window so it can handle reading in the network
                // before being managed.
                if (applyWindowPlacements() ||
                    resource.noAnchorAtStartup)
                {
                    anchor.Show();
                    anchor.Visible = true;
                }
                else
                {
                    anchor.Show();
                    anchor.Visible = true;
                    setBusyCursor(true);
                    wasSetBusy = true;
                }
            }
            else
            {
                anchor = newNetworkEditor(network);
                if (anchor == null)
                    return false;

                anchor.Show();
                setBusyCursor(true);
                wasSetBusy = true;
            }

            // Create the message and debug windows
            messageWindow = newMsgWin();

            // If quested, read in the network.  This is after opening the anchor
            // window because image nodes may wish to bind with the initial image
            // window, etc.
            if (resource.program != null)
                openFile(resource.program, resource.cfgfile);

            if (InDataViewerMode)
            {
                Node n = network.findNode("Import");
                if (n == null)
                {
                    ErrorDialog ed = new ErrorDialog();
                    ed.post("Can not find Import tool in viewing program.");
                }
                else
                {
                    String s = resource.viewDataFile;
                    Debug.Assert(s != null);
                    n.setInputValue(1, s);
                }
            }

            if (resource.noAnchorAtStartup)
            {
                anchor.Show();
            }
            else if (!anchor.Visible)
            {
                anchor.Show();
                setBusyCursor(true);
                wasSetBusy = true;
            }

            if (!resource.runUIOnly)
            {
                // Connect to exec first
                DXChild c = startServer();

                completeConnection(c);
            }

            // If there is an application to talk to, connect to it.
            if (resource.applicationPort != 0)
                connectToApplication(resource.applicationHost,
                    resource.applicationPort);

            if (wasSetBusy)
                setBusyCursor(false);

            return true;
        }
Example #27
0
        public static bool ReadMDF(ref Dictionary<Symbol, NodeDefinition> mdf, 
            StreamReader input, bool uionly)
        {
            NodeDefinition module;
            Symbol category;
            StateConstants state, last_iostate;
            bool parsed_flags, checked_flags, finished, parsed_category,
                parsed_description, parsed_outboard, checked_category,
                checked_description, checked_outboard, parsed_loadable,
                checked_loadable, checked_repeat, get_another_line;
            int line_number;
            String p = null;

            Debug.Assert(mdf != null);
            Debug.Assert(input != null);

            module = null;
            line_number = 0;
            state = StateConstants.Package;
            last_iostate = StateConstants.None;

            finished = false;
            get_another_line = true;
            parsed_description = false;
            parsed_outboard = false;
            parsed_loadable = false;
            parsed_category = false;
            parsed_flags = false;

            checked_category = false;
            checked_description = false;
            checked_outboard = false;
            checked_flags = false;
            checked_loadable = false;
            checked_repeat = false;

            for (; ; )
            {
                if (get_another_line)
                {
                    checked_description = parsed_description;
                    checked_repeat = false;
                    checked_loadable = parsed_loadable;
                    checked_outboard = parsed_outboard;
                    checked_category = parsed_category;
                    checked_flags = parsed_flags;

                    for (; ; )
                    {
                        // Get a line to parse
                        p = input.ReadLine();
                        line_number++;

                        if (p == null)
                        {
                            finished = true;
                            break;
                        }

                        p = p.Trim();

                        if (p.Length > 0 && p.ToCharArray()[0] != '#')
                            break;
                    }
                }
                else
                {
                    get_another_line = true;
                }

                // If no more input, i.e. finished, then exit loop.
                if (finished)
                    break;

                // Otherwise, parse according to the current state.
                switch (state)
                {
                    case StateConstants.Package:
                        // Parse the standalone "PACKAGE" keyword
                        if (p.StartsWith("PACKAGE"))
                        {
                            p = p.Substring(7);
                            p = p.TrimStart();
                            theDynamicPackageDictionary[p] = null;
                        }
                        else
                        {
                            // Don't get another line yet
                            get_another_line = false;
                            state = StateConstants.Module;
                        }
                        break;
                    case StateConstants.Module:
                        // Parse MODULE keyword
                        if (!p.StartsWith("MODULE"))
                        {
                            ErrorDialog ed = new ErrorDialog();
                            ed.post("Encountered error when expecting \"MODULE\" keyword on line {0}.",
                                line_number);
                            return false;
                        }

                        if (module != null)
                        {
                            if(!FinishNodeDefinition(ref mdf, ref module))
                                module = null;
                        }

                        checked_description = parsed_description = false;
                        checked_outboard = parsed_outboard = false;
                        checked_loadable = parsed_loadable = false;
                        checked_category = parsed_category = false;
                        checked_flags = parsed_flags = false;
                        checked_repeat = false;

                        // Add the module index to the module index list.

                        module = ParseModuleLine(mdf, p, line_number);
                        if (module != null)
                        {
                            state = StateConstants.Category;
                            if (uionly)
                                module.UILoadedOnly = true;
                        }
                        else
                            return false;
                        break;
                    case StateConstants.Category:
                        checked_category = true;
                        if (p.StartsWith("CATEGORY"))
                        {
                            String cat = p.Substring(8);
                            cat = cat.TrimStart();
                            category = SymbolManager.theSymbolManager.registerSymbol(cat);
                            if (module == null)
                            {
                                ErrorDialog ed = new ErrorDialog();
                                ed.post("Encountered unexpected \"CATEGORY\" on line {0}.",
                                    line_number);
                                return false;
                            }
                            module.Category = category;
                            parsed_category = true;
                            if (!parsed_description)
                                state = StateConstants.Description;
                            else if (!parsed_outboard)
                                state = StateConstants.Outboard;
                            else if (!parsed_flags)
                                state = StateConstants.Flags;
                            else
                                state = StateConstants.Input;
                        }
                        else
                        {
                            module.Category = Symbol.zero;

                            get_another_line = false;
                            if (!checked_description)
                                state = StateConstants.Description;
                            else if (!checked_outboard)
                                state = StateConstants.Outboard;
                            else if (!checked_flags)
                                state = StateConstants.Flags;
                            else
                                state = StateConstants.Input;
                        }
                        break;
                    case StateConstants.Description:
                        checked_description = true;

                        if (p.StartsWith("DESCRIPTION"))
                        {
                            String desc = p.Substring(11);
                            desc = desc.TrimStart();

                            module.Description = desc;
                            parsed_description = true;
                            if (!parsed_category)
                                state = StateConstants.Category;
                            else if (!parsed_outboard)
                                state = StateConstants.Outboard;
                            else if (!parsed_flags)
                                state = StateConstants.Flags;
                            else
                                state = StateConstants.Input;
                        }
                        else
                        {
                            get_another_line = false;
                            if (!checked_category)
                                state = StateConstants.Category;
                            else if (!checked_outboard)
                                state = StateConstants.Outboard;
                            else if (!checked_flags)
                                state = StateConstants.Flags;
                            else
                                state = StateConstants.Input;
                        }
                        break;
                    case StateConstants.Loadable:
                        checked_loadable = true;
                        if (p.StartsWith("LOADABLE"))
                        {
                            String load = p.Substring(8);
                            load = load.TrimStart();

                            if (!ParseLoadableLine(ref module, load, line_number))
                                return false;
                            parsed_loadable = true;

                            if (!parsed_category)
                                state = StateConstants.Category;
                            else if (!parsed_description)
                                state = StateConstants.Description;
                            else if (!parsed_flags)
                                state = StateConstants.Flags;
                            else
                                state = StateConstants.Input;
                        }
                        else
                        {
                            get_another_line = false;

                            if (!checked_category)
                                state = StateConstants.Category;
                            else if (!checked_description)
                                state = StateConstants.Description;
                            else if (!checked_flags)
                                state = StateConstants.Flags;
                            else if (!checked_outboard)
                                state = StateConstants.Outboard;
                            else
                                state = StateConstants.Input;
                        }
                        break;
                    case StateConstants.Outboard:
                        checked_outboard = true;
                        if (p.StartsWith("OUTBOARD"))
                        {
                            String outb = p.Substring(8);
                            outb = outb.TrimStart();
                            if (!ParseOutboardLine(ref module, outb, line_number))
                                return false;
                            parsed_outboard = true;

                            if (!parsed_category)
                                state = StateConstants.Category;
                            else if (!parsed_description)
                                state = StateConstants.Description;
                            else if (!parsed_flags)
                                state = StateConstants.Flags;
                            else
                                state = StateConstants.Input;
                        }
                        else
                        {
                            get_another_line = false;

                            if (!checked_loadable)
                                state = StateConstants.Loadable;
                            else if (!checked_category)
                                state = StateConstants.Category;
                            else if (!checked_description)
                                state = StateConstants.Description;
                            else if (!checked_flags)
                                state = StateConstants.Flags;
                            else
                                state = StateConstants.Input;
                        }
                        break;
                    case StateConstants.Flags:
                        checked_flags = true;
                        if (p.StartsWith("FLAGS"))
                        {
                            parsed_flags = true;

                            if (p.Contains("SWITCH")) module.setMDFFlagSWITCH();
                            if (p.Contains("ERR_CONT")) module.setMDFFlagERR_CONT();
                            if (p.Contains("PIN")) module.setMDFFlagPIN();
                            if (p.Contains("SIDE_EFFECT")) module.setMDFFlagSIDE_EFFECT();
                            if (p.Contains("PERSISTENT")) module.setMDFFlagPERSISTENT();
                            if (p.Contains("ASYNC")) module.setMDFFlagASYNCHRONOUS();
                            if (p.Contains("REROUTABLE")) module.setMDFFlagREROUTABLE();
                            if (p.Contains("REACH")) module.setMDFFlagREACH();
                            if (p.Contains("LOOP")) module.setMDFFlagLOOP();

                            if (!parsed_category)
                                state = StateConstants.Category;
                            else if (!parsed_description)
                                state = StateConstants.Description;
                            else if (!parsed_outboard)
                                state = StateConstants.Outboard;
                            else
                                state = StateConstants.Input;
                        }
                        else
                        {
                            get_another_line = false;

                            if (!parsed_category)
                                state = StateConstants.Category;
                            else if (!parsed_description)
                                state = StateConstants.Description;
                            else if (!parsed_outboard)
                                state = StateConstants.Outboard;
                            else
                                state = StateConstants.Input;
                        }
                        break;
                    case StateConstants.Input:
                        last_iostate = StateConstants.Input;
                        if (p.StartsWith("INPUT"))
                        {
                            String inp = p.Substring(5);
                            inp = inp.TrimStart();
                            if (ParseInputLine(mdf, ref module, inp, line_number))
                                state = StateConstants.Input;
                            else
                                return false;
                        }
                        else
                        {
                            get_another_line = false;

                            if (checked_repeat)
                                state = StateConstants.Output;
                            else
                                state = StateConstants.Options;
                        }
                        break;
                    case StateConstants.Output:
                        last_iostate = StateConstants.Output;
                        if (p.StartsWith("OUTPUT"))
                        {
                            String outp = p.Substring(6);
                            outp = outp.TrimStart();
                            if (ParseOutputLine(mdf, ref module, outp, line_number))
                                state = StateConstants.Output;
                            else
                                return false;
                        }
                        else
                        {
                            get_another_line = false;
                            state = StateConstants.Repeat;
                        }
                        break;
                    case StateConstants.Repeat:
                        checked_repeat = true;
                        if (p.StartsWith("REPEAT"))
                        {
                            String rep = p.Substring(6);
                            rep = rep.TrimStart();
                            if (ParseRepeatLine(mdf, ref module, rep, line_number, last_iostate))
                            {
                                // Next, parse output or module line.
                                if (last_iostate == StateConstants.Input)
                                    state = StateConstants.Output;
                                else if (last_iostate == StateConstants.Output)
                                    state = StateConstants.Package;
                                else
                                    Debug.Assert(false);
                                get_another_line = true;
                            }
                            else
                                return false;
                        }
                        else
                        {
                            get_another_line = false;
                            // If not successful, try parsing output or module line.
                            if (last_iostate == StateConstants.Input)
                                state = StateConstants.Input;
                            else if (last_iostate == StateConstants.Output)
                                state = StateConstants.Package;
                            else
                                Debug.Assert(false);
                        }
                        break;
                    case StateConstants.Options:
                        Debug.Assert(last_iostate == StateConstants.Input);
                        if (p.StartsWith("OPTIONS"))
                        {
                            String opts = p.Substring(7);
                            opts = opts.TrimStart();
                            if (ParseOptionsLine(mdf, ref module, opts, line_number))
                            {
                                state = StateConstants.Options;
                                get_another_line = true;
                            }
                            else
                                return false;
                        }
                        else
                        {
                            get_another_line = false;
                            // If not successful, try parsing output or module line.
                            if (!checked_repeat)
                                state = StateConstants.Repeat;
                            else
                                state = StateConstants.Input;
                        }
                        break;

                    default:
                        Debug.Assert(false);
                        break;
                }
            }

            if (module != null)
                FinishNodeDefinition(ref mdf, ref module);

            return true;
        }
Example #28
0
        public virtual void addErrorList(String line)
        {
            int chr = line.IndexOf('/');
            int second_slash = -1;
            String newline = null;
            if(chr >= 0)
                newline = line.Substring(chr);

            if (newline != null && (second_slash = newline.IndexOf('/')) >= 0)
            {
                String name = network.getNameString();
                if (!newline.StartsWith(name))
                    return;

                String node_id = newline.Substring(second_slash);
                errorList.Add(node_id);

                // Don't highlight until after execution.
                // Highlighting is now done in DXExecCtl::endLastExecution() by
                // calling this->refreshErrorIndicators().
                if (!getExecCtl().isExecuting())
                    highlightNodes(node_id, HighlightType.ERRORHIGHLIGHT);
            }
            else if (line.Contains("PEER ABORT - "))
            {
                // One of the distributed peers aborted abnormally.
                // Unhighlight all the modules.
                // FIXME: If we don't unhighlight, the aborted module is still
                // highlighted green, so we could go through the process group
                // and mark the greens modules as error modules.
                Network n = this.network;
                EditorWindow e = n.getEditor();
                if (e != null)
                    e.highlightNodes(HighlightType.REMOVEHIGHLIGHT);

                foreach (Network mn in macroList)
                {
                    e = mn.getEditor();
                    if (e != null)
                        e.highlightNodes(HighlightType.REMOVEHIGHLIGHT);
                }

                // This is similar to a disconnect, so make sure the user knows.
                ErrorDialog ed = new ErrorDialog();
                ed.post(line.Substring(line.IndexOf("PEER ABORT - ") + 13));
            }
        }
Example #29
0
        private static bool ParseRepeatLine(Dictionary<Symbol, NodeDefinition> mdf,
            ref NodeDefinition module, String line, int lineNumber, StateConstants io_state)
        {
            Debug.Assert(mdf != null);
            Debug.Assert(module != null);
            Debug.Assert(line != null);
            Debug.Assert(lineNumber > 0);
            Debug.Assert(io_state == StateConstants.Input || io_state == StateConstants.Output);

            line = line.Trim();
            Regex rx = new Regex(@"^([0-9]+)$");
            Match m = rx.Match(line);
            if (!m.Success)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("Encountered error when expecting a repeat value on line {0}.",
                    lineNumber);
                return false;
            }

            int value = Int32.Parse(line);

            int cnt;
            String ioname;

            if (io_state == StateConstants.Input)
            {
                cnt = module.InputCount;
                ioname = "input";
                module.InputRepeatCount = value;
            }
            else
            {
                cnt = module.OutputCount;
                ioname = "output";
                module.OutputRepeatCount = value;
            }

            if (value > cnt)
            {
                ErrorDialog ed = new ErrorDialog();
                ed.post("The repeat value on line {0} is greater than the number of prior {1} paramaters.",
                    lineNumber, ioname);
                if (io_state == StateConstants.Input)
                    module.InputRepeatCount = 0;
                else
                    module.OutputRepeatCount = 0;
                return false;
            }
            return true;
        }
Example #30
0
        public void completeConnection(DXChild c)
        {
            if (c != null)
            {
                switch (c.waitForConnection())
                {
                    case -1:
                        ErrorDialog ed = new ErrorDialog();
                        ed.post("Connection to server {0} failed: {1}",
                            c.getServer(), c.failed());
                        closeConnection(c);
                        break;
                    case 0:
                        if (resource.executeProgram)
                            getExecCtl().executeOnce();
                        break;
                    case 1:
                        InfoDialog id = new InfoDialog();
                        id.post("Connection to server {0} has been queued", c.getServer());
                        break;
                }
            }
            else if (!serverInfo.autoStart)
            {
                connectToServer(serverInfo.port, null);
            }

            // Let the application packet know that a new connection to
            // the server has been created.
            if (applicationPacket != null)
                applicationPacket.handleServerConnection();

            if (resource.executeOnChange)
                getExecCtl().enableExecOnChange();
        }