How to define a primitive device in Proteus? - primitive

I'm trying to make my own full adder and some other devices as a sub-circuit in "Proteus" and use them several times in a bigger circuit.
The problem is when you copy a sub-circuit you need to rename all of its inner parts, otherwise, the parts with a same name in two sub-circuits would be considered as one, therefore you'd get some errors.
So I'd like to know if there is a way to define a full adder of my own and use it like "74LS183" which is a primitive device, and by primitive I mean it has been defined in the library.

From answer posted here
It's in the Proteus Help file:
SCHEMATIC CAPTURE HELP (F1) -> MULTI-SHEET DESIGNS -> Hierarchical Designs
See the section "Module Components":
Any ordinary component can be made into a module by setting the Attach Hierarchy Module checkbox on the Edit Component dialogue form.
The component's value is taken to be the name for the associated circuit,
and the component's reference serves as the instance name.
after this you can use your new implementation of that component with your new name. for making it available at library see "External Modules" section of proteus help.

The problem with copying is solved in "Proteus 8".not completely but sort of.
I mean you can copy a subcircuit without a need to change it's inner parts, but you must change the subcircuit name and I mean the bigger name above the subcircuit not the little one below it.
so there is no need to define a primitive.

Related

typo3: extension template namespace

In the root template page.10 is already taken. If I put page.10 into my extension template, I override it. How can I make sure (just putting a large number is not "making sure") that I don't override anything? The root template is very complicated and includes many other templates, so I cannot really tell which numbers are already taken. I just want to use the extension template to append some content.
The safest solution would be not adding anything automatically. Instead you could provide your rendering instruction via lib.* or tt_content.list.* in case it is a registered plugin:
lib.yourContent = USER_INT
lib.yourContent { ... }
Then you only need to document how to add something to the page output, e.g.:
page.11 < lib.yourContent
I know it has been a while since you've asked this question.
You're saying "just putting a large number is not making sure" because you have no idea what content is using which number on the page object.
If you want to be 99,9% sure that a number has not been used, why don't you use the current timestamp as a number on this cObject? That's how the TYPO3 Errorhandler also refers to pages, using the timestamp they wrote it.
The simpliest answer if you can make sure which Page object index is already used for something is you cannot.
It might be set somewhere deeper in extensions, in any condition that meets any expression is defined there.
None of standard built in tools in TYPO3 can predict that and check all combinations of conditions to tell you if such number is set somewhere in some case.
But.
If you are an admin of that page, then the best approach is just to know your template.
Analyse the typoscript and know what numbers in Page object are used for something. Make a tidy consistent template, clean it up, check using Template tools -> Typoscript object browser. You have to know what's going on on your site, the elements in indexes of main Page object are the main and basis things which are shown public.
(Or just guess any random big number and try to search it in whole typoscript using Template tools -> Template Analyzer -> View complete TS listing. Let's be honest, probability that you shoot a big number which is already used is rather low)

In Component, what's the best pattern for creating configuration at system-start?

There's a pattern I haven't figured out for Component yet:
I have some "live" configuration that requires disk IO (a component) on system-start, and has a dependency on a map of static config (.edn), and after this "live" configuration is instantiated, it won't change or side-effect anything anymore.
For ex: I need to set this up once, and it depends on static config:
(buddy.core.backends/jws
{:secret (buddy.core.keys/public-key
path-to-public-key-from-static-config)})
I would then reuse that backend ad-infinitum, (ex: in buddy.auth.middleware/wrap-authentication), and it doesn't change, nor side-effect.
Possible Solutions
I could make a component that stores this backend at system-start. But this gives up generality, because when I want to add similar "live config", it would have to be explicitly written into the component, and that gives up the spirit of generality that I think Component champions (eg Duct says components define side-effects, and create boundaries to access them)
I could pass a generic component a map of keys - [fn & args] and the fn+args get evaluated and stored in the component. But this feels like it offloads computation to my configuration .edn, and is an anti-pattern. For example:
(private-key priv-path-from-static
(slurp :password-path-from-static))
Should I encode the notion of slurping in my .edn config? I don't want to offload computation to a config file...
The backend and keys can be instantiated on a per-need basis within each component that requires them. IMO, that's too much of computing the exact same thing, when I'd rather it be stored in memory once.
I could have an atom component that holds a map of these "live" config objects, but then they get destructively added in, and my code has lost it's declarative nature.
TL;DR
What's the best way to create configuration at system-start, possibly needing dependencies, and then becoming available to other components as a component, while not giving up the generality which components should have?
In an ideal world, I think the component itself should describe what type of configuration data it needs. (This could be done with a protocol extending the component in question.). When the config component is started, it should look at all other components, get the list of config requirements and resolve it somehow (from a file, a database, etc.).
I've not seen such a library, but Aviso's config library comes close, maybe you can adapt it to your needs.

How to get the full name of a Sitecore DMS rule?

I'm using Sitecore. I want to get the full name/description of a DMS rule in programcode by Sitecore ID, for example: "Where the DayOfWeek has a value that is equal to Tuesday".
Who knows how to do this?
Thanks a lot.
Jordy
I don't know of a simple way, but the class responsible for rendering the rule text is Sitecore.Shell.Applications.Rules.RulesRenderer in Sitecore.Client.dll.
Its constructor accepts the XML from a rules field and you call the Render method, passing in a prepared HtmlTexteWriter. It also has a bunch of fairly self-explanatory private methods like RenderRule, RenderCondition etc.
I'm sure if you decompile that class you can pick out the bits you need.

Twig/Symfony2: Search multiple template directories?

What I want to do is quite easy, but I did not found the solution, yet. In my application I want to organize all templates by theme, language and scope. For that it is neccessary to build and search multiple paths for the right template.
For example the Acme:Default:editAction is requested and the Acme:Default:edit.html.twig template should be loaded by default.
APP_PATH/src/Acme/DefaultBundle/Resources/views/Default/edit.html.twig
Now I want to change this behaviour and search in multiple paths for that template in the given order.
1. VIEWS_PATH/%theme%/%lang%/%scope%/Default/edit.html.twig
2. VIEWS_PATH/%theme%/%lang%/Default/edit.html.twig
3. VIEWS_PATH/%theme%/Default/edit.html.twig
4. VIEWS_PATH/Default/edit.html.twig
What is the easiest way to do that? Add the Paths at some point in config or in an event listener or override the TemplateLoaderClass?
Please no recommendations to any Bundles. I just want to understand how Symfony(2.1)/Twig works at that point.
Bind an event listener that takes the Templating service as an argument and modify the template name on the kernel.view event.
See https://stackoverflow.com/a/12403233/1649758 for a code sample of this.

Searching on 3-level structure (in both directions)

[Note] I try to edit your question. Please accept if this is correct. The original question is very ambigous.
I have some task to do. User can input the name of a function and optionally the name of the class and the file. I have to perform some checks on this function name depending upon a check-list. However, the problem is that the checks in the check-list are described for the files, not the functions. i.e, It describes the checks for all the classes and functions appearing in each file. So, when the user enters the function name, I need to map that to the right file and find out the right checks.
Could you please suggest some efficient ways to do this?
EDIT: (as simple as I can, sorry my English isn't the best ;))
Let's say we have a application (script?) which one we want to profile (yes! we are creating something like profiler! :D) but we don't want to check everything, just few functions. But there is problem. User of our profiler wants to give list of functions to profile in a little bit strange way.
So, he can give us:
- a name of function - we need to profile every function (or method) which has that name no matter where it is (can be in every file or every class or something like standard library (in this case we don't have file name)).
- a name of class - we need to profile every function/method in this class but class itself can be anywhere in few files (we can have different classes with the same name)
- a name of file - we need to profile everything in this file, but there can be few files with the same name (so in every of them we need to profile every function/method).
And all mix of above, so if we have class (let's call it "Bar") and function ("foo") we need to profile this function "foo" in the class "Bar", but still class can be in any file (there can be few "Bar" classes in few files. If we have file name and function name we need to profile every function which has that name (no matter if it is inside or outside any class) in the file (but still there can be few files with the same name).
Few files or few classes isn't really a problem, because I have already replace execution function in profiler (yes, profiler itself is working) but problem is how to storage names of functions (and classes and files) so it could be as fast as possible (memory doesn't really matter if it fast) to search the function should be profile (in short: execution function ask as about it should profile this function or no and we need to give answer, in execute function we have function name (for sure), class name (if function is method from class) and file name (if function isn't from standard library).
You can generate a xml file to store your check list info. as :
<file name="file1"...>
<class name="class1" ...>
<func name=" func1" ... />
</class>
</file>
When you run your program, read the xml into memory, each hierarchy build a object and the high hierarchy object include the lower object.
And build three map lists, which the first 'string' is the name of file or class or func, and the second 'object*' is the point to the object built by xml.
When you get an information, you can just use map::find to search it. If you find the 'object1', you can do the method, defined in 'object1' and its including objects.
You can once go through all your files->classes->functions and create a map (a hash-map) with function name as the key and class and file info as the value.
User enters function name -> you instantly get file/class name by searching your map -> you seek your rules list for the file name and apply the rules.