Store pedestrian agents position in a txt - anylogic

I'm new on AnyLogic, I'm a universitary student, I'm working in my title project and I still can't get to save the coordinates of my agents in time. I've been working with this tool for near 3 months and just started to seek for help.
I tried with traceln(getX and getY), propperly written, but it only shows me the entrance position, how could I create a function to store this information onto a txt file? Or how could I create a new agent type to apply the steps above described
Please your help

Here is a simple example to show you how to do this.
I have a custom pedestrian agent that gets created in the ped source block and a population, which starts of empty where all the pedestrians that gets created get added to.
This is just so that I can have the event to record the location inside the agent and the file object to write to is on main. So we need to access main from inside the agent.
In the file object, I just set it to write and selected a blank .txt file that I created.
You can read more about using the text file from the help - https://anylogic.help/anylogic/connectivity/text-file.html
Inside the pedestrian agent, I have an event that simply saves the location to the file in a new line.
I make use of the "\t" so that the txt file is tab-separated. You can use whatever separator you prefer.
You must remember to call the close command on the text file when you have finished writing to it. I simply called it on the destroy code of main. So it only "writes" the data to the text file when you close the model.
Here is the output from this very simple example

Calling getX() and getY() on agents does definitely give their current coordinates (assuming they are in a continuous space and not GIS/discrete space) so it's likely you're calling this on the wrong agents (e.g., calling it for your instance of Main instead of for some agents living in a population inside it).
Or you're not actually calling it at different simulation times (via, say, a cyclic event), so you're only getting the initial values.

Related

Update parameters promoted to a mask inSimulink

So I am working on constructing a mask for a CAN unpack system. It's a basic mask with 2 promoted parameters and a browse button. The promoted parameters are the "CANdb" file field and the drop down menu, "MsgList", that follows it.
The basic mask it self works. I'm able to browse for a CAN ".dbc" file and its path is available in the promoted field, and even the drop down menu works where I'm able to select a message from those available in the ".dbc" file. But this is about all the functionality I'm getting.
My observation was that this problem is in 2 different parts. I'll try to explain them individually.
The first is with the "CANdb" promoted parameter. While on the outside it appears as though the parameter is changing (it changes in the mask), internally nothing changes: when i peak under the mask, there is no change on the values of the CANUnpack Block that i am using. Then CANUnpack block itself does update when I double click to open it. The new DBC and message list shows up but only on the block.
The second issue was with The list of messages, that is also promoted to the mask is also not updating. The list from the previous DBC file remains there, and does not change even if i run the simulation, update the model or refresh the block. When i close and reopen the model, it updates then.
These observations lead me to believe that i need to add some kind of code to update the mask, but i don not know what this code will be. I though that the issue may have to do with the fact that the value needs to propagate from the mask to the block and then updated all the parameters so maybe that prevents or hinders an update.
For this i then removed the promoted parameter for the DCB file and linked the browse button directly to the block parameter. The only difference this made is that the name of the new DBC file shows up on the CAN unpack block. Nothing else changes. Not even the messages of the "MsgList" till I double click to open the block. And as usual, the message list on the mask remains unchanged.
I am adding some images and the code for my browse button below to aid with trouble shooting. Thanks in advance.
pp = Simulink.Mask.get('NXP_CAN_Unpack/Subsystem/CANUnpack2');
p = pp.getParameter("CANdbFile");
[fName,pName] = uigetfile("*.dbc");
p.Value = [pName,fName] ;
Mask for system
Inside Mask
Block Parameters for CANUNpack

Export specific agent trajectory in Anylogic?

I'm new to AnyLogic. I'm trying to export the pedestrian trajectory from my model. I used an event updated every simulation time unit with code: traceln("When time is "+ (int) time()+ " ," + getId()+"is at ("+getX()+","+getY()+")"), and get several agents' id and location information with specific time.
Anylogic console image
But when I use textFile.println() with same command to export them, the information I get in outside text file is only one agent.
text file image
Is there anyway I can export all of them?
Simply call the code from within the pedestrian agent (if you defined a custom agent) or use the ped keyword within pedestrian-library blocks code sections (ped.getX()/Y).

Automatically download emails from Outlook with SAS or Outlook rule

I am trying to create a program to automatically download the attached files that are sent to us from a certain email and then transform the delimiter with SAS, of those csv that are attached to us and pass those csv through a flow that I have already created.
I have managed to create a program that treats the csv as I want and the delimiter that I want, the problem is that when it comes to automating the download of files from Outlook it does not work.
What I have done is create a rule with the following VB code that I found on the internet:
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "C:\Users\ES010246\Desktop"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub
I have changed the path to my personal path where i want the files are downloaded.
website: https://es.extendoffice.com/documents/outlook/3747-outlook
The problem is that this code does not work for me, it does absolutely nothing for me and no matter how much I search the internet, only this code appears.
Is there any other way to do with SAS what I want? What is it to automatically download 8 csv files sent to me by Outlook, or has someone experienced the same thing as me with VBA?
I have followed all the steps about 7 times so I think the error is not in copying the code or selecting certain options wrong, in fact I had copied and pasted the code and later I modified the path where I wanted those to be saved. files but it doesn't work, does anyone know why?
I will be tremendously grateful, thank you very much for everything!
First of all, you need to make sure the file name and path doesn't include forbidden symbols.
The VBA macro used for a rule in Outlook is absolutely valid except that a mail item may contain the attached files with the same name, so a file saved to the disk may be overwritten (saved with the same name). That's why I'd suggest generating a file name with your own unique IDs making sure that DisplayName property is not empty and has a valid name what can be used for file names (exclude forbidden symbols).
Also you may consider handling the NewMailEx event of the Application class which is fired when a new message arrives in the Inbox and before client rule processing occurs. Use the Entry ID returned in the EntryIDCollection string to call the NameSpace.GetItemFromID method and process the item. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem.
The Items.ItemAdd event can be helpful when items are moved to a folder (from Inbox). This event does not run when a large number of items are added to the folder at once.

minifilter driver | tracking changes in files

What I'm trying to achieve is to intercept every write to a file and track the changes within the file. I want to track how much different the file content before and after the write.
So far in my minifilter driver I registered to IRP_MJ_WRITE callbacks and can now intercept writes to file. However I'm still not sure how can I obtain the content of the file before [preoperation] and the content after [postoperation].
The parameters that I have within the callback functions are:
PCFLT_RELATED_OBJECTS, PFLT_CALLBACK_DATA and I could not find anything related to the content of the file itself within these.
These are the operations that could change data in a file:
Modifying the file: IRP_MJ_WRITE, IRP_MJ_SET_INFORMATION ( specifically the FileEndOfFileInformation and FileValidDataLengthInformation information classes), IRP_MJ_FILE_SYSTEM_CONTROL ( specifically FSCTL_OFFLOAD_WRITE, FSCTL_WRITE_RAW_ENCRYPTED and FSCTL_SET_ZERO_DATA fsctl codes).
As for the content of the file itself that you just need to read it yourself.
If you mean the buffers as they are being written for example, check this out to find out more about the parameters of IRP_MJ_WRITE in the callback data. Esentially the buffer is at Data->Iopb->Parameters.Write.WriteBuffer/MdlAddress
Make sure you handle that memory correctly otherwise it will result a BSODs.
Good luck.

Jenkins How can i upload a text file and use it as a parameter

I have a txt file that is holding a string inside, I want to be able to use this string in one of my scripts, so I'm wondering if there is a way to set the content of the file as one of the build properties or parameters which I'll be able to use in my scripts it should be the same as using one of the build environment properties.
For example : ${JOB_NAME} which is holding the the job name, so in the same way I want to access the content of the file which is holding some value inside.
Is it possible?
You can upload a file from your computer to the workspace through the File parameter of the job.
You can use Extended Choice plugin parameter, to read value(s) from a file and display them in a dropdown/radio-button/checkbox for the user to select, dynamically, every time the build is triggered.
You can use EnvInject plugin to read value(s) from a file and inject them into the build as environment variables, so that they can be used by the rest of the build steps/scripts.
Your question is very unclear on what your are trying to do. Pick one of the 3 methods above based on what you need, or clarify your question.