Alaska Software Inc. - Microsoft 'Sensor and location platform'
Alaska Software Inc. - Microsoft 'Sensor and location platform'
Username: Password:
AuthorTopic: Microsoft 'Sensor and location platform'
Jan Groenestein Microsoft 'Sensor and location platform'
on Tue, 09 Aug 2016 09:46:27 +0200
Gentlemen,

Our clients often use GPS to find their location in our geographical 
system. However, many tablet computers now have an internal GPS system, 
which does not communicate via the good old COM port anymore. Instead, 
Microsoft has a 'Sensor and location platform' and they also offer 
examples for accessing this platform :

http://msdn.microsoft.com/en-us/library/windows/hardware/dn614612(v=vs.85).aspx
The sensor and location platform however uses namespaces
http://msdn.microsoft.com/library/windows/apps/BR225603
and we can't do anything with that, the alaska activex-class
refuses to interface with it.

The only data that we need from it is the longitude and the latitude, 
examples of how to access that are in :
http://msdn.microsoft.com/en-US/library/windows/apps/windows.devices.geolocation.geocoordinate

Is there anyone who has an idea on how to solve this problem ?

Kind regards,
Jan Groenestein
Thomas BraunRe: Microsoft 'Sensor and location platform'
on Tue, 09 Aug 2016 15:05:22 +0200
Jan Groenestein wrote:

> The only data that we need from it is the longitude and the latitude, 
> examples of how to access that are in :
> http://msdn.microsoft.com/en-US/library/windows/apps/windows.devices.geolocation.geocoordinate
> 
> Is there anyone who has an idea on how to solve this problem ?

Create a small, windowless c# console app that gets the coordinates and
passes it back to your application... I wished there was Xbase# 

Thomas
Pascal BoivinRe: Microsoft 'Sensor and location platform'
on Tue, 09 Aug 2016 16:00:21 +0200
Hi

Like Thomas said, use C# and copy/paste sample at
https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinate.latitude(v=vs.110).aspx

Uncomment the line "watcher.stop" so the application will quit when the
first position is received. Then change

Console.WriteLine("Lat: {0}, Long: {1}", coordinate.Latitude,
                    coordinate.Longitude);
to 
System.IO.File.WriteAllText(String.Format("Lat: {0}, Long: {1}",
coordinate.Latitude,
                    coordinate.Longitude), "Output.txt")

Make this an executable, call it from xbase then read Output.txt.
Thomas BraunRe: Microsoft 'Sensor and location platform'
on Tue, 09 Aug 2016 16:42:25 +0200
Pascal Boivin wrote:

> System.IO.File.WriteAllText(String.Format("Lat: {0}, Long: {1}",
> coordinate.Latitude,
>                     coordinate.Longitude), "Output.txt")
> 
> Make this an executable, call it from xbase then read Output.txt.

Wouldn't it be possible to just write to stdout and capture this from the
runshell-call from Xbase++?

Thomas
Pascal BoivinRe: Microsoft 'Sensor and location platform'
on Tue, 09 Aug 2016 16:58:49 +0200
> Wouldn't it be possible to just write to stdout and capture this from
> the runshell-call from Xbase++?

That's what the sample from MS do! Just uncomment the specified line
and here you go.
Thomas BraunRe: Microsoft 'Sensor and location platform'
on Tue, 09 Aug 2016 16:50:45 +0200
Just found this one which could probably be used to catch the stdout return
of a c# program:

http://www.idep.nl/xbase/datpage/shell2buffer.html

HTH
Thomas
Jim LeeRe: Microsoft 'Sensor and location platform'
on Tue, 09 Aug 2016 17:30:44 +0200
hi,

> Make this an executable, call it from xbase then read Output.txt.

why not make a activeX COM DLL using using System.Runtime.InteropServices
coordinate.Latitude and coordinate.Longitude can be assign to a PUBLIC var 
so you can get Property from Xbase++

! Note : you need "register" DotNet COM DLL with 
c:\Windows\Microsoft.NET\Framework\*VERSION*\RegAsm.exe
Jan Groenestein Re: Microsoft 'Sensor and location platform'
on Wed, 10 Aug 2016 10:31:41 +0200
Gentlemen,

Thanks for the suggestions. This is, basically, what we do now. However, 
we would like to access the 'Sensor and location platform' using 
Xbase++, because the route that we now follow makes installation more 
complicated. This is a problem when our software (a client in a SAAS 
system) may be installed on machines without our knowledge.

We want to be able to use the Xbase++ Activex class for this in order to 
keep installation simple, but for some reason alaska activex-class 
refuses to interface with it.

Kind regards,
Jan Groenestein

Op 9-8-2016 om 16:00 schreef Pascal Boivin:
> Hi
>
> Like Thomas said, use C# and copy/paste sample at
> https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinate.latitude(v=vs.110).aspx
>
> Uncomment the line "watcher.stop" so the application will quit when the
> first position is received. Then change
>
> Console.WriteLine("Lat: {0}, Long: {1}", coordinate.Latitude,
>                     coordinate.Longitude);
> to
> System.IO.File.WriteAllText(String.Format("Lat: {0}, Long: {1}",
> coordinate.Latitude,
>                     coordinate.Longitude), "Output.txt")
>
> Make this an executable, call it from xbase then read Output.txt.
>
Pascal BoivinRe: Microsoft 'Sensor and location platform'
on Wed, 10 Aug 2016 15:00:33 +0200
> Thanks for the suggestions. This is, basically, what we do now.
> However, we would like to access the 'Sensor and location platform'
> using Xbase++, because the route that we now follow makes
> installation more complicated. This is a problem when our software (a
> client in a SAAS system) may be installed on machines without our
> knowledge.
> 
> We want to be able to use the Xbase++ Activex class for this in order
> to keep installation simple, but for some reason alaska activex-class
> refuses to interface with it.

ActiveX and .Net use complety different way to expose properties and
methods.  They can not be interchange. I have not read anything about
.Net from Alaska Software in a near future, but I may just have miss it
as I'm not up to date with 2.0.
Jim LeeRe: Microsoft 'Sensor and location platform'
on Wed, 10 Aug 2016 19:00:53 +0200
> ActiveX and .Net use complety different way to expose properties and
> methods.  They can not be interchange. I have not read anything about
> .Net from Alaska Software in a near future, but I may just have miss it
> as I'm not up to date with 2.0.

as i say you can make a DotNet COM DLL using with Xbasse++ v1.9x
-------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
namespace InteropExamples
{
    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [ProgId("InteropExamples.Examples")]
    public class Examples
    {
        public string HelloWorld(string name)
        {
            return "hello World, " + name;
        }
        public decimal Add(decimal number1, decimal number2)
        {
            return number1 + number2;
        }
    }
}
-------------------------------------------------------------------------

you also can get Events from DotNet this Way

-------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;

namespace Tester
{
 [Guid("D6F88E95-8A27-4ae6-B6DE-0542A0FC7039")]
 [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
 public interface _Numbers
 {
  [DispId(1)]
  int GetDay();

  [DispId(2)]
  int GetMonth();

  [DispId(3)]
  int GetYear();

  [DispId(4)]
  int DayOfYear();
 }

 [Guid("13FE32AD-4BF8-495f-AB4D-6C61BD463EA4")]
 [ClassInterface(ClassInterfaceType.None)]
 [ProgId("Tester.Numbers")]
 public class Numbers : _Numbers
 {
  public Numbers(){}

  public int GetDay()
  {
   return(DateTime.Today.Day);
  }

  public int GetMonth()
  {
   return(DateTime.Today.Month);
  }

  public int GetYear()
  {
   return(DateTime.Today.Year);
  }

  public int DayOfYear()
  {
   return(DateTime.Now.DayOfYear);
  }
 }
}

-------------------------------------------------------------------------
Jan Groenestein Re: Microsoft 'Sensor and location platform'
on Wed, 10 Aug 2016 21:02:41 +0200
Hi Jim,

I'm sorry that I missed your previous message, but this looks promising 
to me. Thank you, we will certainly give it a try and will report back 
to you.

Kind regards,
Jan Groenestein

Op 10-8-2016 om 19:00 schreef Jim Lee:
>> ActiveX and .Net use complety different way to expose properties and
>> methods.  They can not be interchange. I have not read anything about
>> .Net from Alaska Software in a near future, but I may just have miss it
>> as I'm not up to date with 2.0.
>
> as i say you can make a DotNet COM DLL using with Xbasse++ v1.9x
> -------------------------------------------------------------------------
> using System;
> using System.Runtime.InteropServices;
> namespace InteropExamples
> {
>     [ComVisible(true)]
>     [ClassInterface(ClassInterfaceType.AutoDual)]
>     [ProgId("InteropExamples.Examples")]
>     public class Examples
>     {
>         public string HelloWorld(string name)
>         {
>             return "hello World, " + name;
>         }
>         public decimal Add(decimal number1, decimal number2)
>         {
>             return number1 + number2;
>         }
>     }
> }
> -------------------------------------------------------------------------
>
> you also can get Events from DotNet this Way
>
> -------------------------------------------------------------------------
> using System;
> using System.Runtime.InteropServices;
>
> namespace Tester
> {
>  [Guid("D6F88E95-8A27-4ae6-B6DE-0542A0FC7039")]
>  [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
>  public interface _Numbers
>  {
>   [DispId(1)]
>   int GetDay();
>
>   [DispId(2)]
>   int GetMonth();
>
>   [DispId(3)]
>   int GetYear();
>
>   [DispId(4)]
>   int DayOfYear();
>  }
>
>  [Guid("13FE32AD-4BF8-495f-AB4D-6C61BD463EA4")]
>  [ClassInterface(ClassInterfaceType.None)]
>  [ProgId("Tester.Numbers")]
>  public class Numbers : _Numbers
>  {
>   public Numbers(){}
>
>   public int GetDay()
>   {
>    return(DateTime.Today.Day);
>   }
>
>   public int GetMonth()
>   {
>    return(DateTime.Today.Month);
>   }
>
>   public int GetYear()
>   {
>    return(DateTime.Today.Year);
>   }
>
>   public int DayOfYear()
>   {
>    return(DateTime.Now.DayOfYear);
>   }
>  }
> }
>
> -------------------------------------------------------------------------
>
>
Jim LeeRe: Microsoft 'Sensor and location platform'
on Wed, 10 Aug 2016 23:27:03 +0200
> you also can get Events from DotNet this Way
>
> -------------------------------------------------------------------------
> using System;
> using System.Runtime.InteropServices;
> namespace Tester

that Source only show how to use IDispatch Interface to access Method not 
Events.
here is a Sample from Roger how Xbase++ can use Events

/**************************************

Publishing COM Events
public.xbase++.activex
20. Januar 2008

**************************************/

Namespace DonnayTest1
{
[Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface UserControl1Events
{
[DispId(2)]
void CheckedChanged(int n, object o);
[DispId(1)]
void ButtonClick( int n, object o );
}
public delegate void ButtonClickDelegate( int n, object o );
public delegate void CheckedChangedDelegate( int n, object o );
[Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"),
ComSourceInterfaces(typeof(UserControl1Events)),
ClassInterface(ClassInterfaceType.AutoDual)]
public partial class UserControl1 : System.Windows.Forms.UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void UserControl1_Load(object sender, EventArgs e)
{
}
public event ButtonClickDelegate ButtonClick;
public event CheckedChangedDelegate CheckedChanged;

public void button1_Click(object sender, EventArgs e)
{
ButtonClick(1,this.button1);
}
public void label1_Click(object sender, EventArgs e)
{
}
public void button2_Click(object sender, EventArgs e)
{
ButtonClick(2,this.button2);
}
public void checkBox1_CheckedChanged(object sender, EventArgs e)
{
label1.Text = "Clicky";
CheckedChanged(1, this.checkBox1);
}
}
}
Jan Groenestein Re: Microsoft 'Sensor and location platform'
on Thu, 11 Aug 2016 13:05:54 +0200
Hi Jim,

Reading back your postings it looks to mee that this option is not what 
we are looking for. You propose to make an Activex COM DLL that should 
be registered first. This is what we are trying to avoid because of the 
installation troubles. Others have also done this, as using the 'Sensor 
and location platform' by non-Visual Studio developers is a widespread 
problem. The tools that we now use also have problems on some machines.
So, we are really looking for a way of directly accessing that platform 
directly form Xbase++

Any ideas, anyone ? Does it really have to go via .Net ? If so, what is 
the status of .Net support in Xbase++ ?

Kind regards,
Jan Groenestein

Op 10-8-2016 om 23:27 schreef Jim Lee:
>> you also can get Events from DotNet this Way
>>
>> -------------------------------------------------------------------------
>> using System;
>> using System.Runtime.InteropServices;
>> namespace Tester
>
> that Source only show how to use IDispatch Interface to access Method not
> Events.
> here is a Sample from Roger how Xbase++ can use Events
>
> /**************************************
>
> Publishing COM Events
> public.xbase++.activex
> 20. Januar 2008
>
> **************************************/
>
> Namespace DonnayTest1
> {
> [Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"),
> InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
> public interface UserControl1Events
> {
> [DispId(2)]
> void CheckedChanged(int n, object o);
> [DispId(1)]
> void ButtonClick( int n, object o );
> }
> public delegate void ButtonClickDelegate( int n, object o );
> public delegate void CheckedChangedDelegate( int n, object o );
> [Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"),
> ComSourceInterfaces(typeof(UserControl1Events)),
> ClassInterface(ClassInterfaceType.AutoDual)]
> public partial class UserControl1 : System.Windows.Forms.UserControl
> {
> public UserControl1()
> {
> InitializeComponent();
> }
> private void UserControl1_Load(object sender, EventArgs e)
> {
> }
> public event ButtonClickDelegate ButtonClick;
> public event CheckedChangedDelegate CheckedChanged;
>
> public void button1_Click(object sender, EventArgs e)
> {
> ButtonClick(1,this.button1);
> }
> public void label1_Click(object sender, EventArgs e)
> {
> }
> public void button2_Click(object sender, EventArgs e)
> {
> ButtonClick(2,this.button2);
> }
> public void checkBox1_CheckedChanged(object sender, EventArgs e)
> {
> label1.Text = "Clicky";
> CheckedChanged(1, this.checkBox1);
> }
> }
> }
>
>
>
Jim LeeRe: Microsoft 'Sensor and location platform'
on Sat, 13 Aug 2016 04:04:13 +0200
hi,

have you check M$ Sample if it run with your Hardware ?
my GPS Hardware still have Bluetoooth Connection so M$ Sample does not work.

>Others have also done this, as using the 'Sensor and location platform' by
>non-Visual Studio developers is a widespread problem

any Link ?
are they using Windows OS() ?

>Any ideas, anyone ?

as Pascal say you can try write "Output.txt" from VS App and read it with
Xbase++
hm ... what about WMI ?

>Does it really have to go via .Net ?

when new Hardware arrive for Windows M$ will use Dotnet to access Hardware.

>If so, what is the status of .Net support in Xbase++ ?

ask Alaska.

p.s. remember a activeX COM DLL can be used by any Language which support 
activeX