/// <summary> /// Send Incident Status message /// </summary> /// <param name="iu"></param> public void SendIncidentStatusMessage(IncidentUpdateWfmV1 iu) { IncidentStatusWfmV1 msg = new IncidentStatusWfmV1() { Cause = 5, // WfmEtr = DateTime.Now.AddMinutes(30).ToUniversalTime(), IncidentId = iu.IncidentId, 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 IncidentUpdateWfmV1 /// </summary> /// <param name="incUpdate"></param> public void SendAckMessage(IncidentUpdateWfmV1 incUpdate) { AckNackV1 ack = new AckNackV1(); //required ack.IsAck = true; ack.ErrNo = 0; //no error ack.Id = incUpdate.IncidentId; ack.MessageSequence = incUpdate.Sequence; ack.Sequence = _sequence++; //optional ack.Name = incUpdate.IncidentName; ack.AdditionalErrorInformation = incUpdate.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 } }