Пример #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");
        }
Пример #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);
        }
Пример #3
0
 /// \brief Constructor
 public analog_input_t(core_device_t dev,    ///< owning device
                       string aname,         ///< name of terminal
                       nldelegate delegate_) ///< delegate
     : base(dev, aname, state_e.STATE_INP_ACTIVE, delegate_)
 {
     state().setup().register_term(this);
 }
Пример #4
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);
        }
Пример #5
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>();
            }
        }
Пример #6
0
        Pointer <nl_fptype> m_gt;  //nl_fptype *m_gt;  ///< conductance for total conductance


        /// \brief constructor
        ///
        /// @param dev core_devict_t object owning the terminal
        /// @param aname name of this terminal
        /// @param otherterm pointer to the sibling terminal
        public terminal_t(core_device_t dev, string aname, nldelegate delegate_)  //terminal_t(core_device_t &dev, const pstring &aname, terminal_t *otherterm, const std::array<terminal_t *, 2> &splitterterms, nldelegate delegate)
            : base(dev, aname, state_e.STATE_BIDIR, delegate_)
        {
            // NOTE - make sure to call terminal_t_after_ctor()

            m_Idr = null;
            m_go  = null;
            m_gt  = null;


            // this is handled below so that recursive links can be handled properly.  see nld_twoterm()
            //state().setup().register_term(*this, otherterm, splitterterms);
        }
Пример #7
0
        }                                                                      //void register_net(device_arena::owned_ptr<T> &&net) { m_nets.push_back(std::move(net)); }

        /// \brief Get device pointer by name
        ///
        ///
        /// \param name Name of the device
        ///
        /// \return core_device_t pointer if device exists, else nullptr

        //core_device_t *find_device(const pstring &name) const
        //{
        //    for (const auto & d : m_devices)
        //        if (d.first == name)
        //            return d.second.get();
        //    return nullptr;
        //}

        /// \brief Register device using owned_ptr
        ///
        /// Used to register owned devices. These are devices declared as objects
        /// in another devices.
        ///
        /// \param name Name of the device
        /// \param dev Device to be registered
        //template <typename T>
        public void register_device(string name, core_device_t dev)  //void register_device(const pstring &name, device_arena::owned_ptr<T> &&dev) noexcept(false)
        {
            foreach (var d in m_devices)
            {
                if (d.first == name)
                {
                    //dev.release();
                    log().fatal.op(MF_DUPLICATE_NAME_DEVICE_LIST(name));
                    throw new nl_exception(MF_DUPLICATE_NAME_DEVICE_LIST(name));
                }
            }

            //m_devices.push_back(dev);
            m_devices.Add(new std.pair <string, core_device_t>(name, dev));  //m_devices.insert(m_devices.end(), { name, std::move(dev) });
        }
Пример #8
0
        core_device_t get_single_device(string classname, get_single_device_func cc)  //core_device_t *get_single_device(const pstring &classname, bool (*cc)(core_device_t *)) const;
        {
            core_device_t ret = null;

            foreach (var d in m_devices)
            {
                if (cc(d.second))
                {
                    if (ret != null)
                    {
                        m_log.fatal.op(MF_MORE_THAN_ONE_1_DEVICE_FOUND(classname));
                        throw new nl_exception(MF_MORE_THAN_ONE_1_DEVICE_FOUND(classname));
                    }

                    ret = d.second;
                }
            }

            return(ret);
        }
Пример #9
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");
        }
Пример #10
0
        //PCOPYASSIGNMOVE(netlist_state_t, delete)

        /// \brief Destructor
        ///
        /// The destructor is virtual to allow implementation specific devices
        /// to connect to the outside world. For examples see MAME netlist.cpp.
        ///
        //virtual ~netlist_state_t() noexcept = default;


        //template<class C>
        static bool check_class <C>(core_device_t p) where C : core_device_t
        {
            return(p is C);  //return dynamic_cast<C *>(p) != nullptr;
        }
Пример #11
0
        //using value_t = value_base_t<nl_fptype>;
        //using value_str_t = value_base_t<pstring>;


        public param_model_t(core_device_t device, string name, string val)
            : base(device, name, val)
        {
        }
Пример #12
0
 protected param_t(core_device_t device, string name)
     : base(device, device.name() + "." + name)
 {
     device.state().setup().register_param_t(this);
 }
Пример #13
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);
        }
Пример #14
0
 protected analog_t(core_device_t dev, string aname, state_e state, nldelegate delegate_)
     : base(dev, aname, state, delegate_)
 {
 }