Stamps, Rules as Edicts

Hello!

I’m sorry for another newbie question, but this has taken too much time to solve without success.
I’m struggling with this and I think there might be an easier way:
I made a structure just like a calendar, that populates (through rules and edicts) every day of the month with some pre-defined rules (one person for the day, another for the afternoon and another for the night and other values like Price, Day of the month etc). However I think this is pushing too much power from the processors, since it is really common to crash the program. Is there any way I could change the rules and edicts to stamps? My first problem would be to change the values of the grandchildren notes. How could that be done?

Another question:

I have 5 agents inside each month that sums the month value of every doctor. Is there an easier “generic” way to point them to the grandchildren notes of the parent’s note of the agent (so the agent’s alias aren’t summed too?)
Thanks,

Rafael.

Hi. Well it doesn’t sound like something that regularly causes crashes so likely there some unintended syntax edge case that maybe confusing Tinderbox. Meanwhile, it does sound like you have a lot of code & agents for the task at hand.

If I understand correctly you are scheduling staff (doctors?) whose (details, time cost, availability) varies. The question is how discrete are the factors. Cleary, doctor A has a different name/email/etc. than doctor B, but are rates set per person and by time of day. Depending on how complex and context specific your attributes (time slot, cost, etc.) are will affect the ways this can be done.

This is a case where a simple example where seeing your present model could help. I appreciate there may be some personal data. By all means use fictitious but realising names (e.g. is you have family names with accents, apostrophes and such do put the in the specimen data. By all means rename the attributes. As long as the attribute representing cost, for example is a Number, a fake name it find. Don’t leave in more specimen data (i.e. discrete doctors, prices, then you need as then we can gauge the size of the problem.

Knowing how person/price/time relate and the number of discrete variations should help us tune your solution.

In your scenario, rules may be overkill: edicts and on-add actions may make more sense. Edict run occasionally but can still be run on demand if needed, e.g. to make sure a change has been picked up. As agent run as aggressively as rules, you could either dial down how often they run (i.e. agent priority) or move the work into edict, stamps, etc.

Anyway, you’ve done nothing wrong. Rules and agents are an easy way to get started. Less aggressively running-options then exist (e.g. rule → edict) to ‘tune’ things once the action logic is clear.

I hope that helps.

I think it would be very helpful to take a step back and look at the problem we’re trying to solve.

We can probably get where you want to go, but it would be better to approach the problem than just fiddle with syntax :slight_smile:

Also: might you be able to put together a shareable sketch of your current work? Some of the actual data may be confidential, but the framework should be easy to extract, and you could invent a couple of imaginary staff members for test purposes.

Tks for the reply! I tried to remove the sensitive information anda made a simple file.

I’m trying to make like a dashboard with various informations of this group that I am a manager…
First with the shifts of the month and then calculate incoming and outcoming, balance, send invoice to all of them with the shifts and values of each…
I know this is complex to the newbie (like me), but I think that with a little help I can get there!

The first problem I want to address is in “/BalancoMensal/2020/Novembro”
I created a composite (CompMes)with actions and rules that auto-populate the doctors based on the day of the week and period (morning, night etc), but this task really heats up my computer! Could I make a stamp with all that information instead?
An agent for each Doctor so it sums the value of his shifts on that month. Sometimes this messes with the html export of the months’ shifts, creating doubled entries.

I think we could start here!
Tks for your patience!

I there a link to the example so we can look at the CompMes composite? If it is a TBX, you can upload it to the forum - drag/drop the TBX into the box where you write your post.

Dashboard - cópia.tbx (900.0 KB)
Sorry. I thought I had sent it.

Tks,

Rafael.

1 Like

Thanks! OK, it’s is very complex. the first thing I would do is go through and review all your action code to use correct syntax. So:

if($StartDate.format(w)=Fri & $Turno=Noite){$Plantonista=Jose};

_May work, but this is he correct version:

if($StartDate.format("w")=="Fri" & $Turno=="Noite"){$Plantonista="Jose"};

Note that literal strings, including date format strings, are put in quotes: "Noite", .format("w"), etc. Also dates are not:

$EndDate=$StartDate + 12 hours;

but

$EndDate=$StartDate + "12 hours";

In queries, e.g. in if(), do not use ‘=’. So not X=Y but X==Y.

For this code (where I have broken the code onto multiple lines just for clarity, but you don’t need this for actual use):

if($DueDate.format(d/m/y)!=$Tags){
  $Color="Red"
} else {
  $Color=
};

In the else branch to set $Color to the default/inherited values use =; not =. Thus:

if($DueDate.format("d/m/y")!=$Tags){
  $Color="Red"
} else {
  $Color=;
};

$Tags is a Set, i.e. multi-value attribute. So, by using != you are testing a string representation of all the set’s values.

For your agent queries, again, quote strings. So:

$Plantonista==Jose & descendedFrom(/2020/Outubro)

Becomes:

$Plantonista=="Jose" & descendedFrom(/2020/Outubro)

In the case of descendedFrom(), you are correct as the convention is to use either an unquotes $Path (as here) or a quoted $Name.

As well as cleaning up the code, so you don’t have accidental side effect, I would delete all the false starts in the document. When testing at this stage, use the smallest possible amount of notes/data/values so you can see what’s going on.

As it is there are too many abandoned tests to fully understand your TBX, although I understand the general concept.

So I suggest:

  1. Delete anything notes that are not part of the logic we are testing
  2. For the remaining notes/agents, fix all the queries/rules/edicts etc so they use correct actions code

…and then re-upload. If you get stuck with correcting the code, just ask. however, I hope the examples above give you enough examples.

1 Like