Copy Properties to custom component?

A forum where Flowcode v6 user created components can be shared, discussed and reviewed.

Moderator: Benj

GTF
Posts: 170
Joined: Sat Dec 10, 2011 7:21 pm
Location: Canada
Has thanked: 20 times
Been thanked: 52 times
Contact:

Copy Properties to custom component?

Postby GTF » Tue Jun 14, 2016 5:36 pm

Hi,
First attempt at putting together a custom component. This one includes the cal_SPI component. I have copied the properties of the SPI component to the custom component's properties. The problem is that when the custom component is used in a project, and "Channel 1"(hardware SPI) is selected, the SPI pins do not map to the correct pins for the target device. Each pin must alwways be manually configured, no matter whether "Channel 1" or "Software" is selected.

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Copy Properties to custom component?

Postby kersing » Tue Jun 14, 2016 6:05 pm

You will need to implement an event handler for the property change event. Every time it fires you need to copy your settings to the underlying component and then read back the appropriate values for 'static' settings like hardware pins for hardware SPI. (Which means you need to decide which properties are 'static' when selecting a certain value.)

There is a feature request to allow properties to be inherited to avoid this kind of duplication.
These users thanked the author kersing for the post (total 2):
LeighM (Wed Jun 15, 2016 8:50 am) • GTF (Thu Jun 16, 2016 4:19 am)
Rating: 11.11%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 14157
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4080 times
Contact:

Re: Copy Properties to custom component?

Postby Benj » Wed Jun 15, 2016 10:50 am

Hello,

This is an example of how we do hardware component connections for SPI including hardware, software and remappable modes.

SPI_CopyProps.fcfx
(30.33 KiB) Downloaded 129 times


We wanted the property inheritance to be included in v7 but so far we have not managed to get round to it. Hopefully it is something we can do for 7.1 as it would drastically simplify things like this.
These users thanked the author Benj for the post:
GTF (Thu Jun 16, 2016 4:19 am)
Rating: 5.56%
 

GTF
Posts: 170
Joined: Sat Dec 10, 2011 7:21 pm
Location: Canada
Has thanked: 20 times
Been thanked: 52 times
Contact:

Re: Copy Properties to custom component?

Postby GTF » Wed Jun 15, 2016 5:06 pm

Thanks Benj, I'll have a look at it.

GTF
Posts: 170
Joined: Sat Dec 10, 2011 7:21 pm
Location: Canada
Has thanked: 20 times
Been thanked: 52 times
Contact:

Re: Copy Properties to custom component?

Postby GTF » Sat Jun 18, 2016 4:24 pm

Is there a list of valid events? From where is a macro such as Ev_Property called?

Seems to be something in the example that I cannot see that allows it to work while the same code ported to my component doesn't. Importing my code to the example works, but I am not allowed to view the generated code?? "You do not have a valid license to perform this action"

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Copy Properties to custom component?

Postby kersing » Sat Jun 18, 2016 7:08 pm

GTF wrote:Is there a list of valid events?


Check the documentation @ the website...

GTF wrote:From where is a macro such as Ev_Property called?


At the top of the project explorer there is an icon with "EV", once you open that list you will see the list of events. Attach the macro to a event by double clicking the event (in this case "Components"->"Property") and selecting the macro from the list at the top. If your macro is not compatible (second list) create a new macro by double clicking on the word 'Macro' and copy the contents of the existing macro to the new macro.

The on-line help pages contain more information on events with video instructions.

GTF wrote:Importing my code to the example works, but I am not allowed to view the generated code?? "You do not have a valid license to perform this action"


You can not export components with the same identifier used for genuine Matrix components. Only Matrix can export those components.
These users thanked the author kersing for the post (total 2):
GTF (Mon Jun 20, 2016 4:05 am) • Benj (Mon Jun 20, 2016 9:54 am)
Rating: 11.11%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

GTF
Posts: 170
Joined: Sat Dec 10, 2011 7:21 pm
Location: Canada
Has thanked: 20 times
Been thanked: 52 times
Contact:

Re: Copy Properties to custom component?

Postby GTF » Mon Jun 20, 2016 4:10 am

kersing wrote:At the top of the project explorer there is an icon with "EV"


Guess I couldn't see that for looking!

Got it all sorted out and working now.

Thanks kersing!

Grant
These users thanked the author GTF for the post:
Benj (Mon Jun 20, 2016 9:56 am)
Rating: 5.56%