public InstanceIdSerializeable() { /* m_instanceId = -1; * m_instanceIdStr = ""; */ Safir.Dob.Typesystem.InstanceId instanceId = new Safir.Dob.Typesystem.InstanceId(); m_instanceId = instanceId.RawValue; m_instanceIdStr = instanceId.RawString; }
// // The following methods are derived from Safir.Dob.EntityHandlerInjection. // public void OnCreateRequest( Safir.Dob.EntityRequestProxy entityRequestProxy, Safir.Dob.ResponseSender responseSender) { bool bOk = false; Safir.Dob.Typesystem.InstanceId instanceId; Safir.Dob.Typesystem.EntityId entityId = new Safir.Dob.Typesystem.EntityId(); // Cast to known type, the vehicle entity. Capabilities.Vehicles.Vehicle vehicle = (Capabilities.Vehicles.Vehicle)entityRequestProxy.Request; // Identification is a mandatory member. if (!vehicle.Identification.IsNull()) { // Generate instance number from unique value. instanceId = new Safir.Dob.Typesystem.InstanceId(vehicle.Identification.Val); // Check if entity with given value already exist. entityId.TypeId = Capabilities.Vehicles.Vehicle.ClassTypeId; entityId.InstanceId = instanceId; if (!m_connection.IsCreated(entityId)) { // Store object in the Dob. m_connection.SetAll( vehicle, instanceId, new Safir.Dob.Typesystem.HandlerId()); bOk = true; m_iNumberOfCreatedVehicles++; } } if (bOk) { // Inform requestor about the instance. Safir.Dob.EntityIdResponse entIdResponse = new Safir.Dob.EntityIdResponse(); entIdResponse.Assigned.Val = entityId; responseSender.Send(entIdResponse); // Send notification message when the number of created vehicles // has reached the limit. if (m_iNumberOfCreatedVehicles == Capabilities.Vehicles.VehicleParameters.VehicleLimit) { MessageSender.Instance.SendMaxNofVehicleMsg(); } } else { Safir.Dob.ErrorResponse errorResponse = new Safir.Dob.ErrorResponse(); errorResponse.Code.Val = Safir.Dob.ResponseGeneralErrorCodes.SafirReqErr; responseSender.Send(errorResponse); } }
void HandleSequencerState(DoseTest.Sequencer sequencerState) { bool activate = sequencerState != null && sequencerState.Partners[m_instance].Val.Equals(m_identifier); //bool activate = true; if (activate == m_isActive) { //already active or not active return; } if (activate) { m_defaultContext = sequencerState.Context.Val; System.Console.WriteLine("Activating (default context is " + m_defaultContext + ")"); m_controlConnection.RegisterEntityHandler(m_partnerEntityId.TypeId, new Safir.Dob.Typesystem.HandlerId(m_instance), Safir.Dob.InstanceIdPolicy.Enumeration.HandlerDecidesInstanceId, this); m_controlConnection.RegisterServiceHandler(DoseTest.Dump.ClassTypeId, new Safir.Dob.Typesystem.HandlerId(m_instance), this); m_actionReceiver.Open(); DoseTest.Partner partner = new DoseTest.Partner(); partner.Identifier.Val = m_identifier; partner.Port.Val = m_actionReceiver.getPort(); try { Safir.Dob.Typesystem.InstanceId instance = new Safir.Dob.Typesystem.InstanceId(Safir.Dob.ThisNodeParameters.NodeNumber); Safir.Dob.Typesystem.EntityId eid = new Safir.Dob.Typesystem.EntityId(Safir.Dob.NodeInfo.ClassTypeId, instance); using (Safir.Dob.EntityProxy ep = m_controlConnection.Read(eid)) { partner.Address.Val = ((Safir.Dob.NodeInfo)ep.Entity).IpAddress.Val; } } catch (Safir.Dob.NotFoundException e) { System.Console.WriteLine("Not found exception: " + e); } m_controlConnection.SetAll(partner, m_partnerEntityId.InstanceId, new Safir.Dob.Typesystem.HandlerId(m_instance)); m_isActive = true; } else { System.Console.WriteLine("Deactivating"); m_actionReceiver.Close(); m_testConnection.Close(); m_controlConnection.Delete(m_partnerEntityId, new Safir.Dob.Typesystem.HandlerId(m_instance)); m_controlConnection.UnregisterHandler(m_partnerEntityId.TypeId, new Safir.Dob.Typesystem.HandlerId(m_instance)); m_controlConnection.UnregisterHandler(DoseTest.Dump.ClassTypeId, new Safir.Dob.Typesystem.HandlerId(m_instance)); m_isActive = false; } }
public InstanceIdSerializeable(Safir.Dob.Typesystem.InstanceId instanceId) { m_instanceId = instanceId.RawValue; m_instanceIdStr = instanceId.RawString; }
public void setInstanceId(Safir.Dob.Typesystem.InstanceId instanceId) { instanceIdSer = new InstanceIdSerializeable(instanceId); }