Dear guys,
I am currently working on a GPS tracking software. It should implement a function to trigger GPS data logging if GPS enter in a specific area and stop logging after going out of boundary.
Anyway, My problem is if I select GPS as a observable object and make a GPSMonitor class to monitor its status. I registered two events based on my gpsmonitor, I found that if GPS enter in the bounding area, the logging function works, but the other event never been triggered. I think there are some problems for my programming skills.
I registered my GPS monitor like this way:
GPSMonitor gpsmonitor = new GPSmonitor (_tempX, _tempY, corners, _Time, sct, polygonGeofence);
and I then attached two events to it, one happened when gps enter a specific area, while the other one happened if gps go out of geofence.
gpsmonitor.GeofencePositioned += new GPSMonitor.PositionInGeofenceEventHandler(RaiseInEvent);
gpsmonitor.GeofenceOutPositioned += new GPSMonitor.PositionInGeofenceEventHandler(RaiseOutEvent);
and gpsmonitor start by
gpsmonitor.GeofenceSDetermination();
The methods happened by two events are the following two sections.
this following part works well when GPS enter in the area:
private void RaiseAlarmEvent(object sender, PositionInGeofenceEventArgs e)
{
DemoServer.SendText("1", DemoServer.IndexOf(Socket));
BtnRecordData.BeginInvoke(new System.EventHandler(BtnRecordData_Click));
}
but second event below part doesn't work. it should trigger the Stop Button stopping, but it nothing happened.
private void RaiseAlarmEvent(object sender, PositionInGeofenceEventArgs e)
{
gpsmonitor.GeofenceOutPositioned -= new GPSMonitor.PositionInGeofenceEventHandler(RaiseInEvent)
DemoServer.SendText("2", DemoServer.IndexOf(Socket));
BtnRecordData.BeginInvoke(new System.EventHandler(BtnRecordStop_Click));
}
I think there is less possible problems on my condition to determine the entry or out of GPS because I have tested it. I donnot know if there is problems on event registration.
Many thanks if any of you could give me suggestions and guidance.