|
Hi Richard
Yes this is what I am using, but the event is never triggered. Serial port exists.
thanks again
regards John
|
|
|
|
|
|
Hi Richard
great, yes this is how I use it, only I would like to use DataReceiveEvent. I will try to do it using the loop, may be this is the solution.
Thanks you very much
Regards John
|
|
|
|
|
I have used OData in my asp.net core project. I have problem with nullable foreign keys. When I want to use expand in url query, there is an exception that says:
System.InvalidOperationException: Nullable object must have a value.
I have provided a simple reproducible project in GitHub GitHub - codeblock88/temp: This repository is used for debugging.[^]repository.
Please help me to solve this problem.
|
|
|
|
|
If a key is nullable then how can it be used to maintain referential integrity?
|
|
|
|
|
I want to expand it for records are not null.
|
|
|
|
|
It's not "records" that can be null, but individual fields in the record.
You're not making much sense, so you're going to have to do a much better job of explaining what you're trying to do.
As for the error you're getting, show the code that's throwing it.
|
|
|
|
|
I have no idea what you mean by that, or what it has to do with your original question.
|
|
|
|
|
There's nothing in that project that would actually call your API and produce that error. Where's the actual reproduction of the error?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
"Nullable foreign keys". Sounds like the definition of an orphan.
(You need a "null' parent in those cases; if you want to stay sane)
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Replace the null with a zero and filter them out in your query.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Hi Guys,
I am not expert and will be glad to get some help. I wrote software, where I am using Barcode reader, com port, in number of Windows forms. I am switching receive data on Form Activation and disabling it on Form deactivated. it has worked well for number of months, but now I am occasionally get error, Com port is not accessible. Received I use Invoke.
<pre> private void CheckForUsbDevice()
{
string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)
{
if ((port == "COM3") || (port == "COM4"))
{
if (AcdStart.mySerialPort == null)
{
AcdStart.mySerialPort = new SerialPort(port)
{
BaudRate = 9600,
Parity = Parity.None,
StopBits = StopBits.One,
DataBits = 8,
Handshake = Handshake.None,
RtsEnable = true
};
}
AcdStart.mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
if (!AcdStart.mySerialPort.IsOpen)
{
AcdStart.mySerialPort.Close();
AcdStart.mySerialPort.Open();
}
PortTextBox.Text = (string.Format("Port {0}", port));
break;
}
}
}
private void RxPurchaseOrder_Deactivate(object sender, System.EventArgs e)
{
if ((AcdStart.mySerialPort != null) && (AcdStart.mySerialPort.IsOpen))
AcdStart.mySerialPort.DiscardInBuffer();
if (AcdStart.mySerialPort != null)
{
AcdStart.mySerialPort.DataReceived -= new SerialDataReceivedEventHandler(DataReceivedHandler);
AcdStart.mySerialPort.Close();
}
AcdStart.mySerialPort = null;
PauseNow = true;
this.BackColor = Color.LightSalmon;
}
private void RxPurchaseOrder_Activated(object sender, EventArgs e)
{
if ((AcdStart.mySerialPort != null) && (AcdStart.mySerialPort.IsOpen))
{
AcdStart.mySerialPort.DiscardInBuffer();
if (AcdStart.mySerialPort.IsOpen)
AcdStart.mySerialPort.Close();
AcdStart.mySerialPort = null;
}
PortTextBox.Text = "";
CheckForUsbDevice();
PauseNow = false;
this.BackColor = Color.LightSteelBlue;
}
I hope I have indicated flow of the basics. I am self learning pensioner ... apologize in advance and thanks for any help and suggestions.
regards John
|
|
|
|
|
What is the exact error message, and where is it generated?
|
|
|
|
|
Hi Richard
The error is, "Access to com port denied". as it is very hard to debug it but it happens on Open port call. I have done some changes, leave com port assigned and only remove or add SerialDataRceivedEventHandler. I feel it is still not the good way, but is working.
regards John
|
|
|
|
|
You have a "number of forms", and imply that each form is opening and closing the port on activation / deactivation. I maintain the serial port should not be dependent on "forms"; and should be part of the app's start and stop process (and "interval" / wait processing).
The port should be "wrapped" in such a way that it can be shared by the various forms / processes.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Hi Garry
thanks for your reply. As I was unable to find some example, this is how I have created. I feel it is not good way, as I done it, as there is a lot of areas which is unpredictable. I will try to see. what I can do. If you have some link to give me some link to example, will be very much appreciated. I fully agree with Napoleon and like the internet and Code Project, to learn.
thanks for great help.
Regards John
|
|
|
|
|
|
thank you Gerry
regards John
|
|
|
|
|
assume you have a simple working social network (I wrote one as an experiment):
nodes are class Person ... identity properties
edges are class Edge ... FromNode, ToNode, Intensity (nullable double): they are one way following standard graph conventions.
both and Node have CRUD methods in place ... working.
if Intensity value is null: it means FromNode to ToNode has no connection
when Intensity's value changes: it raises a PropertyChanging ... the change can be canceled Iimplemented, working)
problem scenario:
an Edge Joe has a ToNode Mary and Intensity 50.
an Edge Mary has a ToNode Joe and Intensity 50
Joe's Node changes Intensity to 100 and raises PropertyChanging which Joe subscribes Mary to.
You see the possibility of runaway recursion if both Edges subscribe PropertyChanging to each other.
how to limit recursion ?
how to limit recursion when an Edge Intensity wants to raise raises PropertyChanging when a certain magnitude of change occurs ?
keep a count ? enforce a limit ?
appreciate your thoughts !
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
BillWoodruff wrote: You see the possibility of runaway recursion if both Edges subscribe PropertyChanging to each other. If they also change their Intensity in response to that event, sure. (if something else then I don't know what you mean)
BillWoodruff wrote: keep a count ? enforce a limit ? Sure, I guess? But where do you keep that count and whose responsibility is this etc, idk ultimately it seems like a bit of hack.
Reading between the lines, here's what I think is going on:
- You have some sparse matrix.
- You updated one entry in it.
- You need to run some algorithm to restore some property.
So here's my proposal: run that algorithm on the matrix. That doesn't sound it means anything, but it does. It means, forget imbuing the individual edges with agency (at least in this context). It's the matrix as a whole that has a property that you want to restore, and the algorithm works on the matrix as a whole (hopefully not every entry needs to be changed). There's no difficulty now in running a limited number of iterations of an incremental algorithm or anything of that nature. You can just do that, explicitly, in one place.
Such a zoomed-out view may also help when implementing other matrix-based graph algorithms such as eigenvector centrality or whatever (do social networks use that? I don't know what social networks actually do to be honest).
But I don't really know what you're doing, maybe none of this applies to your situation.
|
|
|
|
|
Thanks, Harold !
I did not explain adequately.
Joe and Mary's Edges are reciprocal.
Joe changes the intensity value for Mary ... raises OnPropertyChanging.
Mary subscribes to Joe's OnPropertyChanging.
Joe's change calls Mary's OnPropertyChanging handler.
Based on Mary's intensity value and Joe's new value ... Mary changes her value and raises her OnPropertyChanging event that Joe subscribes to.
Then, you get runaway recursion, and stack overflow.
Right now, i am thinking of writing a ChangeManager class outside Edge.
cheers, bill
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
This sounds exactly like a good case for making the matrix responsible for the reciprocity invariant.
|
|
|
|
|
Or just call "OnPropertyChanged", without a name, once, at the end of the "update" cycle. The binding engine then simply refreshes all bound properties. The issue is that most don't benchmark "PropertyChanged" and "optimize" it when it makes no difference (due to a given scenario's low "frame rate"). Users do not perceive "lag" below 100ms.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
note: i am using OnPropertyChanging here.
Gerry Schmitz wrote: The binding engine then simply refreshes all bound properties. Source of this ?
Speed is the issue here: preventing runaway recursion is.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
Thanks, Harold,
What does "matrix" mean here ? How can you have "reciprocity" and "invariant."
i'm dense, and, light-headed, these daze
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|