How to update database and let delay block reference delay duration to updated value? - anylogic

I have created a UI page for user to input the delay duration in edit boxes for certain activities at the simulation screen. The input values should update the database value and amend the delay duration. However, while the database does get updated, the delay block in the main screen keeps capturing the non-updated database value (eg. initial database value is 100, then a user inputs 200. The database value updates to 200, however, my delay block still captures 100.) Is this an issue with AnyLogic database or am I using it wrongly?

You need to specify in the unique result formula that you do not want to make use of the cached result.
(This image is from the local AnyLogic help, you can search for "uniqueResult". I could not find it on the new online help.
The default value is to use true, i.e. use the previous value that was retrieved from the DB for the same query
Simply add false as the first argument in your uniqueResult() code.

Related

Count the duration of a variable in a state (true/false)

I am trying to count the duration of a variable in a specific state (true or false) in seconds then store it in a mongo database, but I can't figure out how to proceed.
Example : if "my_var" is true for 60 seconds, then "my_var_time" = 60 on the database.
I was thinking about running a script that would check "my_var" value each second, but that would not be reliable. It can't work if the program doesn't end in less than one second, which is likely if multiple objects are checked during the process.
There must be some event that causes my_var to change. So you could, after the line that causes the change, add a line that captures a timestamp. That way, you could get timestamps for the moment when it became true and for the moment when it became false, and calculate the difference between those two stamps.

Change a particular node in branch that each users have in firebase

How can I update a particular node that all users have in their own branch?
I am trying to update a users set of points back to 15 after a certain amount of days by a push of a button. I know how to update 1 users node but can't seem to figure out how to do create a function that when I push a button it resets all users that have that branch/var back to 15.
Otherwise, I would have to do it individually which is obviously not efficient.
This is my code to reset 1 of the student's node by a click of a button
Database.database().reference().root.child("students").child(userId).updateChildValues(["points": self.newPoints])
How do I write a method to reset all students who have the value "points" key by a press of a button?
Any help would be appreciated.
Thanks
You can't use wildcards to replace userId and therefore apply it to every node. You would probably need to fetch the entire students node, and update them one by one using a for loop, which would be very inefficient.
You probably want to use a different data structure in your database that would be more appropriate to your situation. Thats said, if you still want to stick with your current structure you can try having your client update a single boolean flag in your database, and then program a trigger function in node.js so that the update is handled on the server side directly. Check out : Firebase Cloud Functions

In Maximo, how do I get in between workflow process whether data in the table has been modified?

I want to show a different option to the user in workflow through input node, depending upon whether the user has modified the record or not.
Problem is if I would use a condition node with custom class to detect whether object has been modified by some person or not in between the workflow process then as soon as the person clicks on route workflow the save is automatically called and isModified() flag gets false, How do I get in condition node whether some person has modified the record or not.
I have to show different options to the user if he has modified and different option on routing workflow if he have not modified.
Sounds to me like you need to enable eAudit on the object and then to check whether eauditusername on the most recent audit record for that object bears the userid of the current user.
It's a little hokey and tempts fate, but if your condition node is early in the workflow's route when this button is pressed, you could try and check to see if the changedate on the object (assuming you are working with one of the many objects that has one) is within the last 5 seconds. There is a gap where the record could be routed twice within a few seconds, but the gap is fairly hard to hit. There is also a gap where if the system slows down at that point and takes more than 5 seconds to get to and run your condition, then it would appear to be not modified. You can play with the delay to find a sweet spot of the fewest false positives and negatives.

How to modify a record within a record type in oracle forms

I created 3 blocks in my oracle 10g form, Headers, Lines and Lines Details. I am fetching the records using cursors for all the three blocks everything is working fine. Now in Lines Details block there is a numeric field called priority. By default I am using FIFO method for priority value starting from 1 to n numbers. Now I want user to decide the priority such that any specific record can be shifted up or down to increase or decrease the priority without committing line details. Once user is satisfied with priority he will click on save to commit the changes. Please help me with this. Thanks in advance.
Locate the changed record and based on the current priority value make it current priority +/- number of times user clicked Up or Down. Declare a record type variable with exact number of columns as in your lines details data block. Copy the all records including the changed record into record type variable. Clear block with no validate and then re-populate the changed record. To shift the record as per the priority values modify your default order by clause. This will solve your problem.

Delayed Execution on Edit with Google Apps Script

I have a relatively large spreadsheet (300 rows, 30 columns) that I color based on the values in the spreadsheet. I'm doing accessing the API minimally using only two accesses:
getValues(...) to access all the values of the data range.
setBackgrounds(...) to set all the backgrounds of the data range.
This runs in about half a second or less. However, it gets in the way if I make it run on every edit using onEdit(), but I also don't want it to be updated at regular time intervals when I'm not editing it, seems like a waste. Is there a good way to make the script run in a "delayed" way, updating at regular time intervals while I'm editing?
Firstly, I would say you should look at Google Sheets' conditional formatting (Format > Conditional formatting menu item in Sheets) -- you may be able to do much of what you need without involving Apps Script at all.
Failing that, you can set up a regular time-based trigger to check for edits and change the backgrounds appropriately. You can support this trigger with a separate onEdit() trigger to record what has changed internally. The flow goes like this:
A change is made and onEdit() triggers
The onEdit() trigger only records the changed cell locations to a local variable or Cache
A time-based trigger fires every minute/hour/whenever
The time-based trigger checks the cache for edited cells, alters their backgrounds, then clears them from the cache
That said, depending on your workflow this approach may not be much better than simply using a time trigger to change the cells directly.