- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I've successfully created a simple component. What I what to do is PREVENT instancing on this component.
I've imported the cy_boot_xx component which disallows instancing. I reviewed the source code available, the properties and the Symbol parameters.
The only thing I noticed is the cy_boot_xx property "Doc.DefaultInstanceName" is 'blank'.
When I try to set my component's property "Doc.DefaultInstanceName" to 'blank'. The error message comes up "Property value is not valid" => "Illegal character".
What do I need to do to prevent instancing? I just want to drop only one of these components on the schematic. Only one is necessary.
Len.
"Engineering is an Art. The Art of Compromise."
Solved! Go to Solution.
- Labels:
-
PSoC Creator Software
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Again, I'm going to say this is not recommend and very strange to do. But you can create an error when two instances are put down if you do something like this in a header file (assuming your component name was CP1):
#if !defined(CP1_`$INSTANCE_NAME`_H)
#define CP1_`$INSTANCE_NAME`_H
#if !defined(CP1_ONLY_ONE)
#define CP1_ONLY_ONE
#else
#error
There can only be one instance of CP1
#endif
#endif
Users of course can import you component and change this behavior or simply disable code generation and edit to their hearts content.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
CyBoot is special as you never actually see it on the schematic. For any component you can drag and drop, there isn't a great way to prevent dropping multiple copies. In general the fitter will give an error on overuse of resources.
I believe you can play some games with the c code that will give an error on compilation (just leave a nice comment as to why the user's getting an error) or there may be a way to create a DRC error on generating source if you see two copies.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Scott,
Thanks again for your assistance.
Since my original post here, I have been able to prevent incrementing instancing. However, the component object still uses the instance (_1) when it creates the .h file. I'd like to fix that too.
I'll look into the DRC checking.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Len,
I wonder how you were able to block incrementing instances? Can you share an example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
If you want to prevent instancing of the UDB Component you created then go to the .cysym page of the component created. Double click (select) the instance name on the component. delete the name and save. Now when you use the component in the schematic it will not have any instance name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ekta,
Thanks for the suggestion. It didn't work. I still had instancing occurring.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
EktaN,
I dropped two components on schematic and it compiles just fine. By "no instancing" I assume that only a single component can exist in schematic.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Again, I'm going to say this is not recommend and very strange to do. But you can create an error when two instances are put down if you do something like this in a header file (assuming your component name was CP1):
#if !defined(CP1_`$INSTANCE_NAME`_H)
#define CP1_`$INSTANCE_NAME`_H
#if !defined(CP1_ONLY_ONE)
#define CP1_ONLY_ONE
#else
#error
There can only be one instance of CP1
#endif
#endif
Users of course can import you component and change this behavior or simply disable code generation and edit to their hearts content.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ScottA,
Thank you for the hint. Do you think it is possible to add something similar to the customizer file so that it will throw Error if another instance is found?
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Possible? Sure, most things are possible given enough time and effort. I suppose you could create a shape customizer and a semaphore for counting, and then use the count in the UI customizer. That said I really don't recommend doing that.
The C code is far simpler and has a lot less gotchas to deal with. For example, if you use the semaphore, you need to make sure it takes into account multiple projects, multiple schematic pages that could be enable/disabled, and multiple instances of Creator running.