I'm trying to control a PTZ camera with the http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl file.
I can use the GotoPreset function without a problem but the ContinuousMove function throws an ProtocolException.
Page 77 of this guide shows an example of how the ConinuousMove function should be used.
Following this guide provided me with the following code:
OnvifMediaClient.Profile[] profs = this.mediaClient.GetProfiles();
OnvifMediaClient.Profile profile = mediaClient.GetProfile(profs[0].token);
OnvifPTZ.PTZConfigurationOptions options = PtzClient.GetConfigurationOptions(profile.token);
OnvifPTZ.PTZSpeed velocity = new OnvifPTZ.PTZSpeed();
velocity.PanTilt = new OnvifPTZ.Vector2D();
velocity.Zoom = new OnvifPTZ.Vector1D();
velocity.PanTilt.x = options.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Max;
velocity.PanTilt.y = options.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Max;
velocity.PanTilt.space = options.Spaces.ContinuousPanTiltVelocitySpace[0].URI;
velocity.Zoom.x = options.Spaces.ContinuousZoomVelocitySpace[0].XRange.Max;
velocity.Zoom.space = options.Spaces.ContinuousZoomVelocitySpace[0].URI;
PtzClient.ContinuousMove(profile.token, velocity, "1000");
Thread.Sleep(2000);
PtzClient.Stop(profile.token, true, true);
But there are some differences with the code in the guide, for example the actual ContinuousMove function requires 3 parameters in my code instead of 2 as in the guide. The extra parameter is a timeout so i think that won't make that much difference but maybe some other things are different that cause my code to fail.
I dit read the awnser of this question in wich the person said the PTZ camera didn't support the ver20. But when I add a service reference to the wsdl with ver20 changed to ver10 I get a message that adding the wsdl failed because it contains links that could not be resolved. Also when i paste the ver10 url (http://www.onvif.org/onvif/ver10/ptz/wsdl/ptz.wsdl) in my webbrowser it shows an xml instead of an wsdl.
How can I use the right wsdl file if i'm not using it already or what could resolve the behaviour in my current setup?
I found a solution.
It turns out I misunderstood the timeout parameter in PtzClient.ContunuousMove. In the previous wsdl version (ver10) you had to call the Stop function everytime you wanted the current PTZ action to stop. In ver20 of the wsdl the PTZ function (unless the Stop function is called) will last as long as specified in the timeout parameter. I thought it was a response timeout or something but it's not.
Calling ContinuousMove now looks like this:
PtzClient.ContinuousMove(profile.token, velocity, "PT1S");
Where the number in the string stands for the amount of seconds the PTZ action should last.
Hope it helps someone.
Related
Edit
I found out, that the requirements for showing a notification consist of setting a content-title, a context-text and a small icon. The last of which I do not do. Unfortunately, I don't know, how to provide a small icon especially in unity.
Original Question
I'm currently trying to show a notification from a unity-instance via android. I want to show the notification, when the user enters a specific gps-area. Thus, the script should run, when the app is paused. That's why I want to use the android-functionality.
With this code, I currently try to show the notification manually:
public void createNotification(){
NotificationManagerCompat nManager = NotificationManagerCompat.from(curContext);
NotificationCompat.Builder builder = new NotificationCompat.Builder(curContext, CHANNEL_ID)
.setContentTitle("Stuff")
.setContentText("MoreStuff")
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
nManager.notify(1551, builder.build());
}
The context is stored in a static variable and is set, when calling the method.
The function is called in C# with:
PluginInstance.Call("createNotification");
The PluginInstance works, the function can be called, but I get the error:
AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationManagerCompat
I found the solution for my problem: I used the Unity Android Jar-Resolver in which I provided the *Dependencies.xml (Where the * presents the Name of my project). In the *Dependenices.xml I specified: <androidPackage spec="androidx.appcompat:appcompat:1.1.0"> and run through the steps, provided in the Tutorial of the Resolver.
Afterwards, multiple dependencies appeared in my /Assets/Plugin/Android-Folder, which were successfully transferred to the app, when building it.
I am facing issue with perforce api (.net), as i am unable to pull sync logs in real time.
- What am I trying to do
I am trying to pull real time logs as Sync is triggered using the
Perforce.P4.Client.SyncFiles() command. Similar to the P4V GUI Logs, which update when we try to sync any files.
- What is happening now
As the output is generated only after the command is done execution its not something intended for.
Also tried looking into Perforce.P4.P4Server.RunCommand() which does provide detailed report but only after the execution of the command.
Looked into this
Reason is -
I am trying to add a status update to the Tool i am working on which shows which Perforce file is currently being sync'd.
Please advise. Thanks in Advance.
-Bharath
In the C++ client API (which is what P4V is built on), the client receives an OutputInfo callback (or OutputStat in tagged mode) for each file as it begins syncing.
Looking over the .NET documentation I think the equivalents are the P4CallBacks.InfoResultsDelegate and P4CallBacks.TaggedOutputDelegate which handle events like P4Server.InfoResultsReceived etc.
I ended up with the same issue, and I struggled quite a bit to get it to work, so I will share the solution I found:
First, you should use the P4Server class instead of the Perforce.P4.Connection. They are two classes doing more or less the same thing, but when I tried using the P4.Connection.TaggedOutputReceived events, I simply got nothing back. So instead I tried with the P4Server.TaggedOutputReceived, and there, finally, I got the TaggedOutput just like I wanted.
So, here is a small example:
P4Server p4Server = new P4Server(cwdPath); //In my case I use P4Config, so no need to set user or to login, but you can do all that with the p4Server here.
p4Server.TaggedOutputReceived += P4ServerTaggedOutputEvent;
p4Server.ErrorReceived += P4ServerErrorReceived;
bool syncSuccess=false;
try
{
P4Command syncCommand = new P4Command(p4Server, "sync", true, syncPath + "\\...");
P4CommandResult rslt = syncCommand.Run();
syncSuccess=true;
//Here you can read the content of the P4CommandResult
//But it will only be accessible when the command is finished.
}
catch (P4Exception ex) //Will be caught only when the command has failed
{
Console.WriteLine("P4Command failed: " + ex.Message);
}
And the method to handle the error messages or the taggedOutput:
private void P4ServerErrorReceived(uint cmdId, int severity, int errorNumber, string data)
{
Console.WriteLine("P4ServerErrorReceived:" + data);
}
private void P4ServerTaggedOutputEvent(uint cmdId, int ObjId, TaggedObject Obj)
{
Console.WriteLine("P4ServerTaggedOutputEvent:" + Obj["clientFile"]); //Write the synced file name.
//Note that I used this only for a 'Sync' command, for other commands, I guess there might not be any Obj["clientFile"], so you should check for that.
}
i want to use a WSDL-Service, but i've never done this before. I have to use a certificate, but don't know how to implement this.
I did the following steps:
Added service reference
inserted the link to the online wsdl file
he got it and i selected O.K
Now i can use the namespace "ServiceReference1" in my project
When i want to call the Login-Method, then i get a error and vs tells me, that more informations are on the "faultDetailString." but how can i get these informations?
ServiceReference1.SessionWSIClient client = new ServiceReference1.SessionWSIClient();
string result = client.Login(this.transaktionsId, this.benutzerId, this.pin);
I'm trying to add a purchase line to a purchase order in Dynamics NAV (2009 R2 Classic) using web services, but I'm running into a peculiar issue.
Creating a purchase line without defining a No works sans problem. Only when I define a No, like in the example below, I get the following exception:
You cannot enter 'Order' in Integer.
Dim purchaseLine = New PurchaseLine
purchaseLine.Document_No = myPurchaseHeader
purchaseLine.Document_Type = Document_Type.Order
purchaseLine.Document_TypeSpecified = True
purchaseLine.Line_No = 1000
purchaseLine.Line_NoSpecified = True
purchaseLine.Type = Type.Item
purchaseLine.TypeSpecified = True
purchaseLine.No = myItemNo ' Defining No seems to cause the problem.
purchaseLineService.Create(purchaseLine)
I've tried creating the purchase line first, without defining No. Which works, but updating it with No defined, results in the same.
purchaseLine.No = myItemNo
purchaseLineService.Update(purchaseLine)
It was suggested somewhere to try using 1 and "1" for Document_Type, but that didn't work either.
I've also followed the steps described here, without success.
While googling I found some forums where people had a similar problem, but they didn't get me closer to a solution.
Any idea's?
Edit:
After doing some more research and testing, I've concluded that my NAV installation is incomplete/flawed/messed up. More details here.
The problem is corrected with this change in codeunit 422, function FormatValue.
//*** BEGIN
// EVALUATE(OptionNo,FORMAT(fldRef.VALUE))
IF NOT EVALUATE(OptionNo,FORMAT(fldRef.VALUE)) THEN
EXIT(FORMAT(FldRef.VALUE));
//*** END
UPDATE2: I got it working completely now! Scroll way down to find out how...
UPDATE: I got it working! Well... partially. Scroll down for the answer...
I'm trying to get my FO file to show an external image upon transforming it to PDF (or RTF for that matter, but I'm not sure whether RTFs are even capable of displaying images (they are)) with FOP, but I can't seem to get it working. (The question asked here is different than mine.)
I am using IKVM 0.46.0.1 and have compiled a FOP 1.0 dll to put in .NET; this code worked fine when I didn't try to add images:
private void convertFoByMimetype(java.io.File fo, java.io.File outfile, string mimetype)
{
OutputStream output = null;
try
{
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired
// Setup outputput stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).
output = new FileOutputStream(outfile);
output = new BufferedOutputStream(output);
// Construct fop with desired output format
Fop fop = fopFactory.newFop(mimetype, foUserAgent, output);
// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer
// Setup input stream
Source src = new StreamSource(fo);
// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
}
catch (Exception ex)
...
}
However, when I (or rather a DocBook2FO transformation) added the following code:
<fo:external-graphic src="url(images/interface.png)" width="auto" height="auto" content-width="auto" content-height="auto" content-type="content-type:image/png"></fo:external-graphic>
into the FO file, the image did not show. I read through a bit of the FAQ on Apache's site, which says:
3.3. Why is my graphic not rendered?
Most commonly, the external file is not being found by FOP. Check the
following:
Empty or wrong baseDir setting.
Spelling errors in the file name (including using the wrong case).
...
Other options did not seem to be my case (mainly for the reason below - "The Weird Part"). I tried this:
...
try
{
fopFactory.setBaseURL(fo.getParent());
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
foUserAgent.setBaseURL(fo.getParent());
FOURIResolver fourir = fopFactory.getFOURIResolver();
foUserAgent.setURIResolver(fourir);
// configure foUserAgent as desired
...
with no avail.
The Weird Part
When I use the command-line implementation of FOP, it works fine and displays my image with no problem. (I don't want to go the run-command-line-from-program route, because I don't want to force the users to install Java AND the .NET framework when they want to use my program.)
The png file is generated from GDI+ from within my application (using Bitmap.Save). I also tried different png files, but none of them worked for me.
Is there anything I might be missing?
Thanks a bunch for getting this far
UPDATE and possible answer
So I might have figured out why it didn't work. I put some time into studying the code (before I basically just copypasted it without thinking about it much). The problem is indeed in the wrong basedir setting.
The key is in this chunk of code:
// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer
// Setup input stream
Source src = new StreamSource(fo);
// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
What happens here is an identity transformation, which routes its own result into an instance of FOP I've created before. This effectively changes the basedir of the routed FO into that of the application's executable. I have yet to figure out how to do this without a transformation and route my input directly into FOP, but for the moment I worked around this by copying my images into the executable's directory.
Which is where another problem came in. Now whenever I try to execute the code, I get an exception at the line that says transformer.transform(src, res);, which confuses the pants out of me, because it doesn't say anything. The ExceptionHelper says:
java.lang.ExceptionInInitializerError was caught
and there is no inner exception or exception message. I know this is hard to debug just from what I wrote, but I'm hoping there might be an easy fix.
Also, this e-mail seems vaguely related but there is no answer to it.
UPDATE2
Finally, after a few sleepless nights, I managed to get it working with one of the simplest ways possible.
I updated IKVM, compiled fop with the new version and replaced the IKVM references with the new dlls. The error no longer occurs and my image renders fine.
I hope this helps someone someday
I'm using very similar code, although without the FOUserAgent, Resolvers, etc. and it works perfectly.
Did you try setting the src attribute in the XSLT without the url() function?
What might help you diagnose the problem further are the following statements:
java.lang.System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog")
java.lang.System.setErr(New java.io.PrintStream(New TraceStream(TraceStream.Level.Error)))
java.lang.System.setOut(New java.io.PrintStream(New TraceStream(TraceStream.Level.Info)))
Where TraceStream is a .NET implementation of a java.io.OutputStream which writes to your favorite logger.
I posted a version for the Common.Logging package at http://pastebin.com/XH1Wg7jn.
Here's a post not to leave the question unanswered, see "Update 1" and "Update 2" in the original post for the solution.