Ejemplo n.º 1
0
        //template <typename T>
        public param_num_t(core_device_t device, string name, T val)
            : base(device, name)
        {
            m_param = val;


            bool   found = false;
            string p     = this.get_initial(device, out found);

            if (found)
            {
                plib.pfunction <nl_fptype, nl_fptype_ops> func = new plib.pfunction <nl_fptype, nl_fptype_ops>();
                func.compile_infix(p, new std.vector <string>());
                var valx = func.evaluate();
                if (ops.is_integral())  //if (plib::is_integral<T>::value)
                {
                    if (plib.pg.abs(valx - plib.pg.trunc(valx)) > nlconst.magic(1e-6))
                    {
                        throw new nl_exception(MF_INVALID_NUMBER_CONVERSION_1_2(device.name() + "." + name, p));
                    }
                }
                m_param = ops.cast(valx);  //m_param = plib::narrow_cast<T>(valx);
            }

            device.state().save(this, m_param, this.name(), "m_param");
        }
Ejemplo n.º 2
0
        protected string get_initial(core_device_t dev, out bool found)
        {
            string res = dev.state().setup().get_initial_param_val(this.name(), "");

            found = !res.empty();
            return(res);
        }
Ejemplo n.º 3
0
        public analog_output_t(core_device_t dev, string aname)
            : base(dev, aname, state_e.STATE_OUT, null)  //: analog_t(dev, aname, STATE_OUT, nldelegate())
        {
            m_my_net = new analog_net_t(dev.state(), name() + ".net", this);


            state().register_net(m_my_net);  //state().register_net(device_arena::owned_ptr<analog_net_t>(&m_my_net, false));
            this.set_net(m_my_net);

            //net().m_cur_Analog = NL_FCONST(0.0);
            state().setup().register_term(this);
        }
Ejemplo n.º 4
0
        void core_device_t_after_ctor(core_device_t owner, string name)
        {
            m_hint_deactivate = false;
            m_active_outputs  = new state_var_s32(this, "m_active_outputs", 1);


            //printf("owned device: %s\n", this->name().c_str());
            owner.state().register_device(this.name(), this);  //owner.state().register_device(this->name(), device_arena::owned_ptr<core_device_t>(this, false));
            if (exec().stats_enabled())
            {
                m_stats = new stats_t();  //m_stats = owner.state().make_pool_object<stats_t>();
            }
        }
Ejemplo n.º 5
0
        public param_enum_t(core_device_t device, string name, T val)
            : base(device, name)
        {
            m_param = val;


            bool   found = false;
            string p     = this.get_initial(device, out found);

            if (found)
            {
                T    temp = val;
                bool ok   = ops.set_from_string(p, out temp); //bool ok = temp.set_from_string(p);
                if (!ok)
                {
                    device.state().log().fatal.op(MF_INVALID_ENUM_CONVERSION_1_2(name, p));
                    throw new nl_exception(MF_INVALID_ENUM_CONVERSION_1_2(name, p));
                }

                m_param = temp;
            }

            device.state().save(this, m_param, this.name(), "m_param");
        }
Ejemplo n.º 6
0
 protected param_t(core_device_t device, string name)
     : base(device, device.name() + "." + name)
 {
     device.state().setup().register_param_t(this);
 }
Ejemplo n.º 7
0
        string m_param;  //host_arena::unique_ptr<pstring> m_param;


        public param_str_t(core_device_t device, string name, string val)
            : base(device, name)
        {
            m_param = val;                                                            //m_param = plib::make_unique<pstring, host_arena>(val);
            m_param = device.state().setup().get_initial_param_val(this.name(), val); //*m_param = device.state().setup().get_initial_param_val(this->name(),val);
        }