sending and recieving two double with a message in Anylogic - message

I want to send the message in an Anylogic model from each agent to others which the message has two parameters. when another agent received the message in the "communication", check the first parameter. if it passes a condition, we use a second parameter in a way and if not, we use it in another way.
for example:
X, Y, and Z are the parameters of the agents.
I send a message in a transition.
and received it in "connection-link to agent"
I want to have this condition:
if sender.X > receiver.X
receiver.Z=receiver.Z + sender.Y;
if sender.X < receiver.X
receiver.Z=receiver.Z - sender.Y;
so I should send X and Y Simultaneously from an agent to another.
but I can not send a message in a transition as:
sendToAllConnected(X,Y);
could you help me?
I use this code ( "op" is a agent parameter):
if(msg.op<this.op)
this.op=this.op+msg;
if (msg.op<this.op)
this.op=this.op-msg;
and this code:
if (sender.op<this.op)
this.op=this.op+msg;
if (sender.op<this.op)
this.op=this.op-msg;
but I have an error that op cannot be resolved or is not a field.

Send a reference to the sender object. Don't try to send the X and Y values. Once you send the sender object, then the receiving object can reason with that message object (a reference to the sender) and get the applicable values of x and y.

Related

Discordia bot DM sending breaks my script

I am trying to make a bot for my server on discord using Discordia, but when I try to use member:send(str), all I get is Uncaught Error: C:/luvit/deps/coro-channel.lua:62: C:/luvit/deps/discordia/libs/containers/User.lua:91: attempt to call method 'getPrivateChannel' (a nil value)
it does send the dm, but then the code breaks and the bot doesn't run anymore, how can I fix this?
member is a variable that gets the member from message
local member = message.member
I am able to recreate the issue, albeit with a different error that I suspect is due to me not having all your code to debug with.
The bot will send the DM and post a message, then crash due to error.
You have this code:
if message.content:lower() == prefix..'createdm' then
message.channel:send("<#!"..memberid.."> ".. "Sent!")
message.member:send("test") --message.member is able to inherit the send method from message.author
end
I don't know how you find memberid, so I defined it like this:
memberid = message.member:__hash()
It is called every time a message is sent, and it sends a message. This means the bot is going to call this and read its own messages. While the bot will not continue into the if statement because its message is not <prefix>createdm, it will still try to get memberid and evaluate the if statement. I do not know how bot users differ from human users in their account metadata, but I strongly suspect there is some difference and this is your issue.
I believe adding this to your code, at the beginning of your message callback (before your do anything else to evaluate a message) will fix your problem.
if message.author == client.user then
return
end
client here is whatever you assigned discordia.Client() to.
if message.content:lower() == prefix..'createdm' then
message.channel:send("<#!"..memberid.."> ".. "Sent!") -- member.id !!!
message.member:send("test") --message.member is able to inherit the send method from message.author
end

Is there a way to get the last chat massage in shout or say?

I want to search the last message for a few strings and then echo the message back with those strings replaced with other strings.
I searched multiple documentations but didn't find a way to get the last message.
This is the first forum I ask as I already have an account so have no real starting point to give you.
Thanks in advance!
There is no way in the WoW API to get the last chat message of a specific channel. You will have to handle the CHAT_MSG_CHANNEL event (see Event Handling) to read all messages, and store the newest one. Specifically for the say or yell (shout) channels there are the CHAT_MSG_SAY and CHAT_MSG_YELL events respectively.
To do this your addon needs to own a Frame, these frames can register event handlers and you will have to store the last message you receive from that handler in a local variable in your script (let's call it last_message). Then when your other piece of code executes you can read the last_message variable:
local frame = CreateFrame("FRAME", "FooAddonFrame");
local last_message = nil;
frame:RegisterEvent("CHAT_MSG_CHANNEL");
local function eventHandler(self, event, ...)
-- Look up the arguments that are given to your specific event
-- and assign them to variables in order by retrieving them from
-- the `...` variable arguments
local msg, author, language, channel = ...
print("Hello World! Hello " .. event);
last_message = msg
end
frame:SetScript("OnEvent", eventHandler);

Specman - Monitor doesn't recognize events which it is supposed to provide

According the Universal Verification Methodology (UVM) e User Guide of Cadence:
The events recognized by the monitor depend on the actual protocol. Typically, for the basic data item the monitor
provides an item_started and an item_ended event (for example, packet_started and packet_ended). The monitor collects
the item data from the signals and creates a current_item that has the complete item data, ready to be used when the
item_ended event occurs. In addition to the raw data, the monitor should collect relevant timing information such as the
duration of the transaction.
I try to execute the following in my agent by:
connect_ports() is also {
uart_monitor.uart_frame_s_started.connect(tx_scb.uart_frame_s_add);
uart_monitor.uart_frame_s_ended.connect(tx_scb.uart_frame_s_match);
};
I get the following errors: Error: 'uart_monitor' (of 'uart_tx_monitor_u') does not have 'uart_frame_S_started'field.... Error: 'uart_monitor' (of 'uart_tx_monitor_u') does not have 'uart_frame_S_ended'field
But when I declare the events in the monitor by:
event uart_frame_s_started;
event uart_frame_s_ended;
There are no errors.
Why should I declare those events if they are supposed to be provided by the monitor?
are you using the uvm scoreboard? if so, its ports (add and match) are TLM ports. meaning - they expect to get data item written to them.
but you connect to them event ports.
there is something strange - in your code, the events names have a lower 's', but in the error - as you print it - there is capital S. is it uart_frame_s_started or uart_frame_S_started ?

STM32F4xx CAN Filter Configuration

I am writing in reference to the information in the reference manual (bxCAN).
I am trying to understand how CAN filter configuration works and need your help to check whether I understand it correctly or not.
Especially the configuration of the filter ID and the filter mask ID.
After I take a look of the stdPeriphLib and the ref. manual, I think that in understand what happens but I´m not sure.
FilterIdHigh/Low:
Is FilterIdHigh/Low the comparative value for CAN Controller after the binary AND with the FilterIdMask?
e.g:
CAN Controller receives a message --> CAN_Rx_
CAN Controller makes a binary AND with the FilterIdMask -->
CAN_Rx_ArbitrationField & FilterIdMask = Result
The CAN Controller compares the Result with the FilterId.
If there is a match CAN Controller puts the CAN_Rx_ message into the assigned FIFO otherwise it will discard the message.
Isn´t it?
Thank´s in advantage.
First received ID is ANDed with Mask to remove bits which are not required and then compared with ID. If they match, then only message is accepted.
if((CAN_RX_ID & CAN_FILTER_MASK) == (CAN_FILTER_ID & CAN_FILTER_MASK))
{
Copy Data in Buffer
}
else
{
Discard the message
}
Note that, only those bits which are set in Mask are compared.
Say, you want to accept only one frame with ID 0x18EBFAB0. In that case, you will set Filter ID as 0x18EBFAB0 and Mask as 0x1FFFFFFF.
When message with any other ID arrives, it will not satisfy required condition and it will be ignored.
If message with ID 0x18EBF9B0 is received,
(0x18EBF9B0 & 0x1FFFFFFF) != (0x18EBFAB0 & 0x1FFFFFFF)
Message will be ignored
If you want to accept any message between ID 0x120 to 0x127.
In that case, set Mask as 0x1F0 and Filter ID as 0x120. With this, Last 4 bits of the ID will be ignored as they are set to 0.
When Message with ID 0x123 is received,
(0x123 & 0x1F0) == (0x120 & 0x1F0)
Message will be accepted.

Issue with using int.parse() in Dart

I'm currently teaching myself the Dart language, and my first app doesn't seem to be working right. Here's the code that's causing trouble:
usrLoc = int.parse(query("#txtLoc").text);
When I try to run the app, it opens fine, but when I click the button that triggers this (and three other similar parses), the debugger stops and tells me "Source not found" for int._native_parse(), int._parse(), and int.parse().
Any help would be greatly appreciated.
The text property for the specified element #txtLoc returns an empty string.
The parse method requires that:
The source must be a non-empty sequence of base- radix digits, optionally prefixed with a minus or plus sign ('-' or '+').
You can specify an onError named argument in your call to parse, which takes a callback that handles the invalid input. E.g., if you want the parse call to return the value 42 for all invalid input, you can do this:
usrLoc = int.parse(query("#txtLoc").text, onError: (val) => 42);
If you really expect the element to have some text, you can store the result of query("#txtLoc").text into a separate variable and verify the value. It would also be interesting to check what the real element type is or which tag is marked with id #txtLoc.
If you want to get the content of an input element, you should use the value property instead of text:
query("#txtLoc").value

Resources