why DolphinDB reports error message when subscribing to stream tables - stream

I subscribed to stream tables in DolphinDB, but the error reports ‘exception=Only a table can append to another table’. Is there anything wrong with my code?
I also used a user-defined function as the handler. Still, the error message ‘exception=FROM clause must return a table’ shows up.

When subscribing to the stream table, you need to specify the parameter ‘msgAsTable=true’.
subscribeTable(tableName="trades1", actionName="tradesStats22", offset=0, handler=func, msgAsTable=true)
Its default value is false, meaning the subscribed data is ingested into handler as a tuple of columns. That's the cause for the two errors.

Related

synchronize between publisher and subscriber

I am working on test program which subscribes to one topic published by main program. There is only single message on this topic published by main program. Now it might happen that my subscriber is not alive when publisher is publishing a message and it will get lost. One way to avoid it is put while inside main program till numsubcribers are not zero. but I cannot put while inside my main program. How do i achieve it?
So since you say that there is only a single message send by the main program, this is probably a job for the latch argument when you allocate the publisher:
latch [optional]
Enables "latching" on a connection. When a connection is latched, the last message published is saved and automatically sent to any future subscribers that connect. This is useful for slow-changing to static data like a map. Note that if there are multiple publishers on the same topic, instantiated in the same node, then only the last published message from that node will be sent, as opposed to the last published message from each publisher on that single topic.
Just give your publisher the argument as described here, and ROS handles the message passing to your subscriber when it comes up:
...
bool latch = true;
ros::Publisher advertise(topic, latch)
...

How to find the distinct error messages of model state validation failure in asp.net mvc

I want to filter the Error Messages that gets populated as part of data annotation modelstate validation failure. As in if an array of objects comes as a part of class, and the validation fails for more than one object, I do not want the same message to be added again and again. Instead, I want to find the distinct error messages
string ValidationFailure= string.Join(";", actionContext.ModelState.Values.Distinct().Select(x.ErrorMessage));
But not able to get the required output.
It looks like your attempt is close, but you’re using Distinct on something that’s already unique (Values). Instead, try the following variation:
string ValidationFailure = string.Join(";", actionContext.ModelState.Values.Select(x => x.ErrorMessage).Distinct());
This ensures that you get a distinct list of ErrorMessages.

Sending message with CAPL and dbc signal values

I am using CAPL to simulate a test envirmonet for some small tests and i am having problems sending messages or more specific setting up the values.
I am able to read Signal Values with $SignalName, also i am able to set signal values like that.
If i am using this code to send a message the message data is always 0:
on key 't'
{
message MessageName msg;
setSignal(SignalName,i);
write("Value: %d",i);
outport(msg);
}
Witch makes kinda sence becouse i think the message objects are intended to be used to send bytes witch you can access through msg.byte()
I know that i can set signals in messages by msg.SignalName, but again this seems not the right way. I think there should be a way to send a message and all the signals contained in the message are set to the values set by SetSignal() function. Otherwise the SetSignal Funktion is a bit useless
Maybe somebody has an idea.
Thank you
I am using CANalyzer version 8.2 and I do not have the option to use SetSignal(signal, value) function. Setting the signal values by accessing the message selectors seems to be a reasonable approach. However you used the function outport! You need to use the output function to transmit messages.
on key 't' {
message MessageName msg;
msg.signal1 = value1;
output(msg);
}
For this method the database has to be configured so that the message msg contains all the necessary signals (signal1).
If you want to set all signal values to the start values configured in the database use the function:
setSignalStartValues(message msg);
You can set up an interaction layer that will handle the messages as defined in the CAN database (DBC file) assigned to the node. The interaction layer will need some attributes in the database to define how the messages have to be sent. If not already present you may have to add these attributes. If the Tx messages are not sent as expected, check the attributes.
Function output() is useful if you want to implement (and fully control) the sending of the message yourself.
Instead of using SetSignal() it is also possible to write the signal using $SignalName = value;
See this support note:
https://kb.vector.com/upload_551/file/SN-IND-1-011_InteractionLayer(1).pdf
You may have to guess and experiment a bit. In the DBC files provided by a customer I found attribute values that are not mentioned in this document.

How do I filter Purchase Order query in QBXML to only return records that are not fully received?

When doing a PurchaseOrderQuery in QBXML I am trying to get Quickbooks to only return purchase orders that are not yet processed (i.e. "IsFullyReceived" == false). The response object contains the IsFullyReceived flag, but the query object doesn't seem to have a filter for it??
This means I have to get every single Purchase Order whether or not it's received, then do the filtering logic in my application - which slows down Web Connector transactions.
Any ideas?
Thanks!
You can't.
The response object contains the IsFullyReceived flag, but the query object doesn't seem to have a filter for it??
Correct, there is no filter for it.
You can see this in the docs:
https://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html
This means I have to get every single Purchase Order whether or not it's received, then do the filtering logic in my application - which slows down Web Connector transactions.
Yep, probably.
Any ideas?
Try querying for only Purchase Orders changed or modified (ModifiedDateRangeFilter) since the last time you synced.
Or, instead of pulling every single PO, keep track of a list of POs that you think may not have been received yet, and then only query for those specific POs based on RefNumber.
Or, watch the ItemReceipt and BillPayment objects, and use that to implement logic about which POs may have been recently filled, since BillPayment andItemReceipt` objects should get created as the PO is fulfilled/received.

How to get the kbmMW client query statement on server-side?

I found the "OnQueryStatement" method :
procedure TkbmMWQueryService2.kbmMWQueryServiceQueryStatement(Sender: TObject;
Place: TkbmMWQueryOperationType; var NamedQueryName, Statement: string);
begin
Form1.Memo1.Lines.Add(Statement);//show the query statement
end;
this method can get the client-side query statement,but all the client-side query trigger this event twince!(like the screenshot)!Why? How can i get the client-siade query statement correctly?
thanks in advance! :)
Its called twice on the server (in fact can be called 3 times for the same query on the server in the most far out situation).
Check the Place argument for the situation that its called in.
It can be
mwqotDefinition,mwqotQuery,mwqotExecute,mwqotResolve,mwqotMoreData,mwqotMetaData
The reason its being called multiple times when opening the query, is that the dataset first likes to get the definition (which fields and parameters will this query result in), and then the data itself.
Both the server and the client default operates like that. Hence opening a query on the client result the client in asking the server about definitions, then the client asks for the data, and that on the server may result in the server itself asking for definitions and then the data. Remember the server is stateless and default doesnt know anything about previous calls to it.
There are many ways to optimize this:
Enable caching for metadata (definitions). That will result in the cache results being used instead of the server asking the database for the definitions, and enabling the cache on the client too, results in the client not having to ask the server for definitions except first time.
Setup the AutoFieldDefs property on the query to mwafoWithData. Then the data will actually be returned at the same time as the definitions, and the 2.nd data fetch call will be skipped.

Resources