On 09/05/2014 03:48 PM, Sylvain Joyeux wrote:
Could you be more specific as to the type of property.
I have the following types, in effect four nested std::vector types

   namespace ndlcom_device_driver
   {
        struct ConfigureRegisterBit {
            std::string name;
            int bit;
            bool value;t
        };

        typedef std::vector< ConfigureRegisterBit > ConfigureRegisterBits;

        struct ConfigureRegister {
            std::string name;
            representations::RegisterId id;
            double value;
            ConfigureRegisterBits bits;
            std::string valueString;
        };

        typedef std::vector< ConfigureRegister > ConfigureRegisters;

        struct DeviceClassRegister {
            std::string deviceclass;
            ConfigureRegisters registers;
        };

        typedef std::vector< DeviceClassRegister > DeviceClassRegisters;

        struct JointConfig {
            std::string jointName;
            DeviceClassRegisters configureRegisters;
        };

        typedef std::vector< JointConfig > JointsConfig;
   }

The task property is of type JointsConfig. In the ruby script I do

        joints_config = task.joints_config.to_a
        joints_config.each do | joint_config |
           configureRegisters = joint_config.configureRegisters.to_a
           configureRegisters.push(
   Types::NdlcomDeviceDriver::DeviceClassRegister.new )
           joint_config.configureRegisters = configureRegisters
        end
        task.joints_config = joints_config  # This is where it crashes

I also tried something like.

            joints_config.each do | joint |
joint.configureRegisters.push( Types::NdlcomDeviceDriver::DeviceClassRegister.new )
                joint.configureRegisters.each do | dc |
dc.registers.push( Types::NdlcomDeviceDriver::ConfigureRegister.new )
                    dc.registers.each do | reg |
reg.bits.push( Types::NdlcomDeviceDriver::ConfigureRegisterBit.new )
                    end
                end
            end

The difference is that then the problem is changing from crash to following error message.

   install/lib/ruby/1.9.1/typelib/compound_type.rb:23:in `set':
   invalidated object for
   /ndlcom_device_driver/DeviceClassRegister.registers for
   /ndlcom_device_driver/JointConfig.configureRegisters (TypeError)

Let me know if you need more info.

Moreover, do you try to change the property while the component is running ?
No the task is not running.

Best
Ajish

Sylvain

On Thu, Sep 4, 2014 at 3:19 PM, Ajish Babu <[email protected]> wrote:
Hi all,

I have a complex property with std::vector (sub-configs) inside std:vector
(configs). I am trying to modify the property from ruby script.

Changing any already existing value works fine. But once I try to push a new
element to the sub-configs and then write it back like

             configs = task.configs.to_a

             configs.each do | config |
                 sub_configs = config.sub_configs.to_a
                 sub_configs.push( Types::SubConfig.new )
                 config.sub_configs = sub_configs
             end

             task.configs = configs

it crashes. Does anybody know how this can be achieved?

Best
Ajish




_______________________________________________
Rock-dev mailing list
[email protected]
http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev


_______________________________________________
Rock-dev mailing list
[email protected]
http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev

Reply via email to