Ejemplo n.º 1
0
        public static void UndumpModel(StringTokenizer st)
        {
            string name = CustomLogicModel.unescape(st.nextToken());
            var    dm   = getModelWithName(name);

            dm.undump(st);
        }
Ejemplo n.º 2
0
 public string Dump()
 {
     return(CirSim.Sim.LocateElm(Elm)
            + " " + EditItem
            + " " + MinValue
            + " " + MaxValue
            + " " + CustomLogicModel.escape(SliderText));
 }
Ejemplo n.º 3
0
 public string Dump()
 {
     Dumped = true;
     return("34 " + CustomLogicModel.escape(Name)
            + " " + flags
            + " " + SaturationCurrent
            + " " + SeriesResistance
            + " " + EmissionCoefficient
            + " " + BreakdownVoltage);
 }
Ejemplo n.º 4
0
 CustomLogicModel(CustomLogicModel copy)
 {
     flags      = copy.flags;
     inputs     = copy.inputs;
     outputs    = copy.outputs;
     infoText   = copy.infoText;
     rules      = copy.rules;
     rulesLeft  = copy.rulesLeft;
     rulesRight = copy.rulesRight;
 }
Ejemplo n.º 5
0
        public Adjustable(StringTokenizer st, CirSim sim)
        {
            int e = st.nextTokenInt();

            if (e == -1)
            {
                return;
            }
            Elm        = sim.getElm(e);
            EditItem   = st.nextTokenInt();
            MinValue   = st.nextTokenDouble();
            MaxValue   = st.nextTokenDouble();
            SliderText = CustomLogicModel.unescape(st.nextToken());
        }
Ejemplo n.º 6
0
        public static CustomLogicModel getModelWithName(string name)
        {
            if (modelMap == null)
            {
                modelMap = new Dictionary <string, CustomLogicModel>();
            }
            if (modelMap.ContainsKey(name))
            {
                return(modelMap[name]);
            }
            var lm = new CustomLogicModel();

            lm.name     = name;
            lm.infoText = (name == "default") ? "custom logic" : name;
            modelMap.Add(name, lm);
            return(lm);
        }
Ejemplo n.º 7
0
        public static CustomLogicModel getModelWithNameOrCopy(string name, CustomLogicModel oldmodel)
        {
            if (modelMap == null)
            {
                modelMap = new Dictionary <string, CustomLogicModel>();
            }
            if (modelMap.ContainsKey(name))
            {
                return(modelMap[name]);
            }
            if (null == oldmodel)
            {
                return(getModelWithName(name));
            }
            var lm = new CustomLogicModel(oldmodel);

            lm.name     = name;
            lm.infoText = name;
            modelMap.Add(name, lm);
            return(lm);
        }
Ejemplo n.º 8
0
        public string Dump()
        {
            var vPlot = mPlots[0];

            var elm = vPlot.Elm;

            if (elm == null)
            {
                return(null);
            }
            var flags = mFlags;
            var eno   = CirSim.Sim.LocateElm(elm);

            if (eno < 0)
            {
                return(null);
            }
            string x = "o " + eno
                       + " " + vPlot.Speed
                       + " " + vPlot.Value
                       + " " + flags
                       + " " + mScale
                       + " "
                       + " " + Position
                       + " " + mPlots.Count;

            for (int i = 0; i < mPlots.Count; i++)
            {
                var p = mPlots[i];
                x += " " + CirSim.Sim.LocateElm(p.Elm) + " " + p.Value;
            }
            if (Text != null)
            {
                x += " " + CustomLogicModel.escape(Text);
            }
            return(x);
        }
Ejemplo n.º 9
0
        public void Undump(StringTokenizer st)
        {
            _initialize();

            int e = st.nextTokenInt();

            if (e == -1)
            {
                return;
            }

            var ce = CirSim.Sim.getElm(e);

            SetElm(ce);
            Speed = st.nextTokenInt();
            var value = st.nextTokenEnum <VAL>();

            var flags = st.nextTokenInt();

            mScale = st.nextTokenDouble();
            st.nextTokenDouble();

            if (mScale == 0)
            {
                mScale = 0.5;
            }
            Text = null;
            if ((flags & FLAG_PLOTS) != 0)
            {
                try {
                    Position = st.nextTokenInt();
                    int sz = st.nextTokenInt();

                    _setValue(value);
                    /* setValue(0) creates an extra plot for current, so remove that */
                    while (1 < mPlots.Count)
                    {
                        mPlots.RemoveAt(1);
                    }

                    for (int i = 0; i != sz; i++)
                    {
                        var eleNum = st.nextTokenInt();
                        var val    = st.nextTokenEnum <VAL>();
                        var elm    = CirSim.Sim.getElm(eleNum);
                        mPlots.Add(new ScopePlot(elm, val));
                    }
                    while (st.hasMoreTokens())
                    {
                        if (Text == null)
                        {
                            Text = st.nextToken();
                        }
                        else
                        {
                            Text += " " + st.nextToken();
                        }
                    }
                } catch (Exception ex) {
                    throw ex;
                }
            }
            if (Text != null)
            {
                Text = CustomLogicModel.unescape(Text);
            }
            mFlags = flags;
        }