예제 #1
0
파일: Component.cs 프로젝트: krattai/flosh
        void ProcIptx(string s, InPort ipt)
        {
            int    i = ipt.setDimension;
            String t = s;

            if (!s.EndsWith("*"))
            {
                i = 0;
            }
            else
            {
                t = s.Substring(0, s.Length - 1);
                if (i == 0)
                {
                    FlowError.Complain(_name + "." + s
                                       + ": Asterisk specified on input port name, but setDimension was not specified");
                }
            }

            if (i == 0)
            {
                ProcIpty(t, ipt);
            }
            else
            {
                for (int j = 0; j < i; j++)
                {
                    ProcIpty(t + j, ipt);
                }
            }
        }
예제 #2
0
        public void InitBlock()
        {
            _inputPorts  = new Dictionary <string, IInputPort>();
            _outputPorts = new Dictionary <string, OutputPort>();
            //_inputPortAttrs = new Dictionary<string, InPort>();
            //_outputPortAttrs = new Dictionary<string, OutPort>();
            _status      = States.NotStarted;
            _stack       = new Stack();
            _packetCount = 0;
            MustRun      = false;
            SelfStarting = false;
            _timeout     = null;
            //_event_dormant = new AutoResetEvent(false);
            _lockObject = new Object();
            //_compLog = new Logger();
            _mother       = null;
            _autoStarting = false;

            System.Reflection.MemberInfo info = GetType();
            object[] attributes = info.GetCustomAttributes(true);
            foreach (object at in attributes)
            {
                if (at is MustRun)
                {
                    MustRun mr = at as MustRun;
                    MustRun = mr.value;
                }
                if (at is SelfStarting)
                {
                    SelfStarting sst = at as SelfStarting;
                    SelfStarting = sst.value;
                }
                if (at is OutPort)
                {
                    OutPort op = at as OutPort;
                    ProcOpt(op);
                }
                if (at is InPort)
                {
                    InPort ip = at as InPort;
                    ProcIpt(ip);
                }
                if (at is PriorityAttribute)
                {
                    PriorityAttribute p = at as PriorityAttribute;
                    Priority = p.value;
                }
            }
        }
예제 #3
0
        protected internal void ProcIpt(InPort ipt)
        {
            if (!(ipt.value.Equals("") ^ ipt.valueList == null))
            {
                FlowError.Complain(_name + ": @InPort must have value or valueList, but not both");
            }
            String s;

            if (!ipt.value.Equals(""))
            {
                s = ipt.value;
            }
            else
            {
                s = ipt.valueList[0];
            }
            if (ipt.fixedSize && !ipt.arrayPort)
            {
                FlowError.Complain(_name + "." + s + ": @InPort specified fixedSize but not arrayPort");
            }
            if (!ipt.value.Equals(""))
            {
                if (ipt.setDimension > 0 && !ipt.value.EndsWith("*"))
                {
                    FlowError.Complain(_name + "." + s
                                       + ": @InPort specified setDimension but value string did not end with asterisk");
                }
                ProcIptx(ipt.value, ipt);
            }
            else
            {
                bool asterisk_found = false;
                foreach (String t in ipt.valueList)
                {
                    if (t.EndsWith("*"))
                    {
                        asterisk_found = true;
                    }
                    ProcIptx(t, ipt);
                }
                if (!asterisk_found && ipt.setDimension > 0)
                {
                    FlowError.Complain(_name + "." + s
                                       + ": @InPort specified setDimension but valueList did not contain any strings ending with asterisks");
                }
            }
        }
예제 #4
0
        protected internal void ProcIpty(string s, InPort ipt)
        {
            ConnArray ca = null;

            if (ipt.arrayPort)
            {
                ca = new ConnArray();
                _inputPorts.Add(s, ca);
                ca._fixedSize = ipt.fixedSize;
                ca._name      = s;
            }
            else
            {
                NullConnection nc = new NullConnection();
                nc._name = s;
                _inputPorts.Add(s, nc);
            }
        }