/// <summary> /// Send Crew Onsite message /// </summary> /// <param name="ca"></param> public void SendCrewOnsiteMessage(CrewUpdateWfmV1 ca) { CrewStatusWfmV1 msg = new CrewStatusWfmV1() { CrewId = ca.CrewId, Status = (int)eWfmCrewStatus.OnSite, Sequence = _sequence++, Guid = Guid.NewGuid().ToString() }; crewConnector.SendMessageToIdms(msg); }
/// <summary> /// Send vehicle location message /// </summary> /// <param name="ca"></param> public void SendVehicleLocationMessage(CrewUpdateWfmV1 ca) { VehicleLocationWfmV1 locations = new VehicleLocationWfmV1(); IncidentUpdateWfmV1 incidentMsg = incidentMsgList[ca.IncidentId]; if (incidentMsg != null) { locations.AddCrewLocation(ca.CrewId, incidentMsg.LatLong.X + 80, incidentMsg.LatLong.Y + 20); // position the vehicle right beside the incident locations.Sequence = _sequence++; locations.Guid = Guid.NewGuid().ToString(); crewConnector.SendMessageToIdms(locations); } }
/// <summary> /// Send Ack Message for CrewUpdateWfmV1 /// </summary> /// <param name="ca"></param> public void SendAckMessage(CrewUpdateWfmV1 ca) { AckNackV1 ack = new AckNackV1(); ack.IsAck = true; ack.ErrNo = 0; //no error ack.Id = ca.IncidentId; ack.MessageSequence = ca.Sequence; ack.Sequence = _sequence++; //optional ack.Name = ca.IncidentId; ack.AdditionalErrorInformation = ca.ToString(); crewConnector.SendMessageToIdms(ack); }
/// <summary> /// This gets called when a message is received from the Crew Server /// Based on the type of message, it can be just simply logged, or handled specifically based on the application needs. /// </summary> /// <param name="msg"></param> public void OnMessageFromIdms(NetMessageBase idmsMsg) { Console.Out.WriteLine("Received message " + idmsMsg.GetType()); if (idmsMsg.GetType() == typeof(AckNackV1)) { AckNackV1 ack = (AckNackV1)idmsMsg; if (ack.IsAck) { Console.Out.WriteLine("Ack for message " + ack.MessageSequence); // log the Ack message } else { Console.Out.WriteLine("NoAck for message " + ack.MessageSequence); } } else if (idmsMsg.GetType() == typeof(IncidentUpdateWfmV1)) { IncidentUpdateWfmV1 iu = (IncidentUpdateWfmV1)idmsMsg; Console.Out.WriteLine("Incident Id=" + iu.IncidentId + ", update type = " + ((eUpdateType)iu.UpdateType).ToString()); // save the incident details for later reference if (!incidentMsgList.ContainsKey(iu.IncidentId)) { incidentMsgList.Add(iu.IncidentId, iu); } else { incidentMsgList[iu.IncidentId] = iu; } SendAckMessage(iu); // Send Ack message SendIncidentStatusMessage(iu); // Send incident status message } else if (idmsMsg.GetType() == typeof(CrewUpdateWfmV1)) { CrewUpdateWfmV1 ca = (CrewUpdateWfmV1)idmsMsg; Console.Out.WriteLine("Incident Id=" + ca.IncidentId + ", crew Id = " + ca.CrewId + ", update type = " + ((eUpdateType)ca.UpdateType).ToString()); SendAckMessage(ca); // Send Ack message SendCrewEnrouteMessage(ca); // Send Crew Enrount status message SendCrewOnsiteMessage(ca); // Send Crew Onsite status message SendVehicleLocationMessage(ca); // send Vehicle location update message } }