08-14-2013 06:38 AM
Hi Thierry and Zcuba,
I agree that we have to go for a structured approach. We will examin all of your suggestions. Seeing that the occurence of the problem seems random we will have to test each of the elimination questions for a long time (unless the problem occurs fast).
Some extra info:
* Our Halcon vs VBAI test was on the same computer, but not on the computer on which we run our tests. We tried taking images in both programs while streaming audio and the black stripes occurred in VBAI.
* During the 'streaming' test we ran VBAI and Halcon without interfacing.
* In the application with the black stripe-problem we use the same methods as in the API-dotnet examples.
Some extra tests we performed yesterday and today:
* We made sure the images of the 4 camera's were taken with a minimum delay of 500 milliseconds after each other. / Result: problem still occured.
* We tested with 4 VBAI-programs running without interfacing. / result: problem still occured.
Some other tests we are going to perform:
* Replace the 64-bit computer by a 32-bit computer and run with interface.
* Test with 1 cam - 1 computer without switch (and try to create noise)
* Test with 1 cam - 1 computer + switch (and try to create noise)
* Try our program without writing the images to the server. (Could this interfere?)
With kind regards,
Tom
08-14-2013 07:07 AM
Hello Tom,
It's a good approach, but I would like to make some small adaptions in your tests:
* Replace the 64-bit computer by a 32-bit computer and run with interface. (I don't think this will fix the issue, but you can try it)
* Test with 1 cam - 1 computer without switch (without extra noise)
* If problem does not show with previous test, then try it with the extra noise.
* Test with 1 cam - 1 computer + switch (without extra noise)
* If problem does not show with previous test, then try it with the extra noise.
* Try the program without writing the images to the server.
How do you connect with your server?
Is it through the same switch (and/or Ethernet Card) that you use for your camera's?
Side Questions:
Can you tell me which API .NET Example you're exactly refering to and how you have changed those examples.
I'm especially interested in seeing:
a) Which "VBAI-program" you have written?
b) How you are creating the 4 parallel feed?
Any code you can share is welcome, seeing that this might give us an idea where it's going wrong.
Important Note:
Please note that for the test mentioned above I would like you to only use 1 VBAI-programs and not 4.
This way we can see what happens without the 3 other parallel camera feeds.
08-14-2013 09:25 AM
The example we used can be found under "C:\Program Files\National Instruments\Vision Builder AI 2012\API Examples\dotNET Examples" and the library’s we use are NationalInstruments.VBAI.2008.dll and NationalInstruments.Vision.Common.dll
The basic concept what we do is we have a client and a server application. The client connects to the server and will ask to execute the test that need to be run.
For each vision builder test the client will connect to the server so we create in our case 4 different thread’s that will each handle there own test.
I didn’t post al of the code cause a lot of things are just for handeling error’s or things we need to do but that has nothing to do with the pictures or tests.
public class VisionBuilderTest
{
private VBAIEngine _engine;
public void StartEngine(int id)
{
this._engine = new VBAIEngine("Engine" + id.ToString(), string.Empty, false);
}
public void LoadProgram(string program)
{
this._engine.OpenInspection(program);
}
public void ExecuteTest()
{
this._engine.RunInspectionOnce(-1);
bool newImageAvailable, inspectionStatus;
VBAIDateTime timeStamp;
StepResult[] results = this._engine.GetInspectionResults(out timeStamp, out inspectionStatus);
VisionImage image = this._engine.GetInspectionImage(string.Empty, 1, 1, out newImageAvailable);
image.WriteJpegFile(imageFile.FullName, 100);
while (!imageFile.Exists)
{
Thread.Sleep(50);
}
if (image != null)
{
image.Dispose();
}
}
}
public class Client()
{
private Thread clientThread;
private VisionBuilderLogic _visionBuilderLogic;
private int id;
public Client(int id)
{
this.id = id;
}
public void Start()
{
this._visionBuilderLogic = new VisionBuilderLogic();
this.clientThread = new Thread(new ThreadStart(HandleClient));
this.clientThread.Start();
}
public void HandleClient()
{
try
{
this._networkStream = this._tcpClient.GetStream();
while (true)
{
ASCIIEncoding encoder = new ASCIIEncoding();
byte[] readBuffer = new byte[1024];
int bytesRead = this._networkStream.Read(readBuffer, 0, readBuffer.Length);
this._networkStream.Flush();
string command = encoder.GetString(readBuffer, 0, bytesRead);
_visionBuilderLogic.StartEngine(this.id);
_visionBuilderLogic.LoadProgram(command);
_visionBuilderLogic.ExecuteTest();
}
}
catch (Exception exc)
{
this._logger.ErrorException("Connectie met client verbroken.", exc);
}
finally
{
this._tcpClient.Close();
}
}
}
08-16-2013 03:12 AM
Hello Tom,
Thanks for the extra information!
Can you let us know when you have the results from all the tests above (with one VBAIEngine) ?
08-16-2013 04:00 AM
As I read the code, and the documentation of the example mentioned,
Each camera is handled by seperate threads, and are not locked by eachother.
Hence I have a hard time understanding how you'r application could be the cause of the problem.
The only real time consuming call you are making in this code, is the save call: image.WriteJpegFile(imageFile.FullName, 100);
If the image object was global, so that all threads used the same object, or if the write call was unblocking,
that would allowe the data to be disposed before the write operation was completed when timing was off.
However, as I remember, the WriteJpegFile is a blocking call, so that would not cause this type of problem.
Have you tried protecting the write call with semaphores, only allowing one thread at a time to write the image to disc ?
08-19-2013 01:13 AM - edited 08-19-2013 01:15 AM
Goodmorning all,
The last post (about the example code) was written by my collegue (our C# / dotnet-specialist).
Some of the little tests we started with last week:
On a different computer (32-bit system):
* We ran 4 (different) VBAI programs in wich we only took pictures (every 500ms) and wrote these to a networkdrive: black stripes.
* We ran 4 (different) VBAI programs in wich we only took pictures (every 500ms) and wrote these to a local drive: black stripes.
* We ran 4 (different) VBAI programs in wich we only took pictures (every 500ms) without writing them: black stripes.
btw: we did this by running 4 VBAI-applications seperately but simultaneously without interfacing.
So I think we can safely say that the problem is not caused by the application, nor by the use of a 64-bit system.
The problem must therefor be a network problem, a problem with the switch, a driverproblem or a distortion problem. So this week we will continue with the tests we had discussed earlier.
We'll keep you informed.
Tom
08-19-2013 04:17 AM
Hello Tom,
Thanks for the update!
I'll await the results of the beforementioned tests.
08-20-2013 12:38 AM
Tests performad yesterday:
* After receiving a tip about the NIC driver earlier we updated this driver: Problem still occured.
* We tested with 1 camera and 1 computer without switch. This by running one of our VBAI-programs without interfacing: Problem didn't occur, but we only tested this for a little more then 1 hour.
08-20-2013 01:14 AM
Interesting
I wan't to see the same simple setup with switches.
08-20-2013 03:57 AM
Hello Tom,
Like Zucba said:
1) The next test you have to do is the set-up with 1 pc and 1 camera with the switch inbetween.
Additonally I would like to add:
If this one is still succesful, then the next step would be to do the following test:
2) Set-Up with 1 pc and 2 camera's (with the switch inbetween the pc and the 2 camera's)