17 #include <pia/common/common_PacketDefine.h> 18 #include <pia/common/common_OffsetTreeMap.h> 19 #include <pia/common/common_OffsetList.h> 20 #include <pia/transport/transport_Protocol.h> 21 #include <pia/clone/clone_definitions.h> 22 #include <pia/clone/clone_SendClone.h> 23 #include <pia/clone/clone_ReceiveClone.h> 24 #include <pia/clone/clone_AtomicSharingClone.h> 25 #include <pia/clone/clone_SequentialSharingClone.h> 37 class CompressDataUnpacker;
54 PIA_PROTOCOL_TYPE_INFO(nn::pia::transport::PROTOCOL_TYPE_CLONE);
241 return m_ElementSizeMax;
256 return RegisterClone(SendClone::ToKey(cloneId), pClone);
272 return UnregisterClone(pClone);
288 return UnregisterClone(SendClone::ToKey(cloneId));
299 return static_cast<SendClone*
>(m_CloneCollection.Find(SendClone::ToKey(cloneId)));
310 return static_cast<const SendClone*
>(m_CloneCollection.Find(SendClone::ToKey(cloneId)));
340 return UnregisterClone(pClone);
389 return RegisterClone(AtomicSharingClone::ToKey(cloneId), pClone);
406 return UnregisterClone(pClone);
423 return UnregisterClone(AtomicSharingClone::ToKey(cloneId));
434 return static_cast<AtomicSharingClone*
>(m_CloneCollection.Find(AtomicSharingClone::ToKey(cloneId)));
445 return static_cast<const AtomicSharingClone*
>(m_CloneCollection.Find(AtomicSharingClone::ToKey(cloneId)));
460 return RegisterClone(SequentialSharingClone::ToKey(cloneId), pClone);
476 return UnregisterClone(pClone);
492 return UnregisterClone(SequentialSharingClone::ToKey(cloneId));
503 return static_cast<SequentialSharingClone*
>(m_CloneCollection.Find(SequentialSharingClone::ToKey(cloneId)));
514 return static_cast<const SequentialSharingClone*
>(m_CloneCollection.Find(SequentialSharingClone::ToKey(cloneId)));
530 virtual nn::Result Startup(
StationIndex localStationIndex);
538 virtual void Cleanup();
548 virtual nn::Result Dispatch();
563 virtual nn::Result UpdateProtocolEvent(
const transport::ProtocolEvent& event);
585 return static_cast<State>(m_InnerState & cStateMask);
718 return m_MaxSendDelay;
762 return m_pSendProfiler;
773 return m_pReceiveProfiler;
871 virtual void Trace(u64 flag)
const;
879 SystemTime GetResendSpan()
const 889 SystemTime GetResendSpanForUnicast(
StationIndex stationIndex)
const 891 return m_ResendSpanForUnicast[stationIndex];
895 u32 GetStationNum()
const 909 return m_LocalStationIndex;
911 u32 GetParticipantBitmap()
const 913 return m_ParticipantBitmap;
915 SystemTime GetSystemTime()
const 919 u32 GetDispatchCount()
const 921 return m_DispatchCount;
924 void ErrorDropEvent()
930 u32 GetValidStationBitmap()
const 932 return m_ValidStationBitmap;
935 u32 GetNoticeParticipationBitmap()
const 937 return m_NoticeParticipationBitmap;
943 return (m_StationNum > 0);
945 bool IsInCommunication()
const 959 InnerState GetInnerState()
const 964 void UpdateCloneState();
966 void UpdateResendSpan();
968 void ReceiveMessages();
969 void ReceiveMessage(
StationIndex src,
const void* cpMessage,
size_t size);
970 bool UpdateReceivedMessageSequentialId(
StationIndex src,
const void* cpMessage);
972 bool SendUnicastMessage(
StationIndex dest,
void* pMessage,
size_t messageSize);
973 bool SendMulticastMessage(u32 destBitmap,
void* pMessage,
size_t messageSize);
974 void SetSequentialIdToMessage(
void* pMessage);
981 void UpdateSystemTime();
983 void SendClockRequest();
984 void ReceiveClockRequest(
StationIndex src,
const void* cpMessage,
size_t size);
985 void ReceiveClockReplyMessage(
StationIndex src,
const void* cpMessage,
size_t size);
987 void NoticeParticipation();
988 void ReceiveEnterMessage(
StationIndex src,
const void* cpMessage,
size_t size);
989 void ReceiveExitMessage(
StationIndex src,
const void* cpMessage,
size_t size);
990 void ReceiveEnterAckMessage(
StationIndex src,
const void* cpMessage,
size_t size);
991 void ReceiveExitAckMessage(
StationIndex src,
const void* cpMessage,
size_t size);
993 struct DispatchCountData
998 m_MyCount = cInvalidDispatchCount;
1002 u16 m_ReceivedCount;
1006 size_t m_ElementSizeMax;
1010 u32 m_ValidStationBitmap;
1011 u32 m_ParticipantBitmap;
1012 InnerState m_InnerState;
1016 SystemTime m_SystemTime;
1017 SystemTime m_ResendSpan;
1019 f32 m_ResendSpanRatio;
1020 SystemTime m_LastUpdateResendSpanTime;
1021 SystemTime m_LastParticipationCommandTime;
1022 SystemTime m_LastClockCommandTime;
1024 SystemTime m_MaxSendDelay;
1026 static const SystemTime cDefaultResendSpan = 500;
1028 u32 m_DispatchCount;
1029 DispatchCountData* m_paReceivedDispatchCount;
1030 static const u32 cCheckDispatchCount = 0x00003fff;
1033 static const u32 cInvalidDispatchCount = 0xffffffff;
1041 u32 m_NoticeParticipationBitmap;
1044 nn::Result RegisterClone(CloneBase::Key key,
CloneBase* pClone);
1045 nn::Result UnregisterClone(CloneBase::Key key);
1046 nn::Result UnregisterClone(
CloneBase* pClone);
1048 typedef common::OffsetTreeMap<CloneBase::Key, CloneBase> CloneCollection;
1049 CloneCollection m_CloneCollection;
1053 void AddSendCommand(CloneBase::CommandToken* pToken);
1054 void CancelSendCommand(CloneBase::CommandToken* pToken);
1058 u32 SendCommandCore(CloneBase::CommandToken* pToken,
bool isUnicast, u32 destBitmap,
void* pMessage,
size_t messageSize);
1060 typedef common::OffsetList<CloneBase::CommandToken> CommandTokenList;
1061 CommandTokenList m_SendCommandTokenList;
1062 CommandTokenList m_ResendCommandTokenList;
1065 void AddSendData(CloneBase::DataToken* pToken);
1066 void CancelSendData(CloneBase::DataToken* pToken);
1070 bool SendCloneData(CloneBase::DataToken* pToken);
1073 typedef common::OffsetList<CloneBase::DataToken> DataTokenList;
1074 DataTokenList m_DataTokenList;
1076 struct DataMessageBuffer
1088 u8 m_Message[common::PROTOCOL_MESSGAE_PAYLOAD_SIZE_MAX];
1091 DataMessageBuffer m_DataMessageBuffer;
1092 IDataPacker* m_pDataPacker;
1093 IDataUnpacker* m_pDataUnpacker;
1094 CompressDataUnpacker* m_pCompressedDataUnpacker;
1099 return m_ClockPriorityJudgeFunction;
1114 u32 m_SendMessageSequentialId;
1116 #if NN_PIA_ENABLE_TRACE 1118 struct MessageHeaderForDebug
1122 u16 m_DispatchCount;
1124 MessageHeaderForDebug m_ReceivedMessageHeaderForDebug[
MAX_STATION_NUM];
1130 class ElementDefinition
1133 ElementDefinition();
1134 void Register(u16 type, ReceiveElementFunction receiveFunction,
size_t dataChunkHeaderSize);
1135 ReceiveElementFunction GetReceiveFunction(u16 type)
const;
1136 size_t GetDataChunkHeaderSizeMax()
const 1138 return m_DataChunkHeaderSizeMax;
1140 static const u32 cTypeNum = 16;
1143 ReceiveElementFunction m_aReceiveFunction[cTypeNum];
1144 size_t m_DataChunkHeaderSizeMax;
1147 static ElementDefinition* GetElementDefinition();
1151 virtual Clock* CreateRtcClock(f32
clockPerSec, f32 regulationRate);
1152 virtual size_t TransportGetMaxStationNum();
1153 virtual size_t PayloadSizeManagerGetMtuSize();
1154 virtual size_t SignatureManagerGetSignatureSizeMax();
1155 virtual const common::Time& TransportGetDispatchedTime();
1157 virtual s32 StationGetRttPulseInterval();
1158 virtual size_t PacketHandlerGetPayloadSizeLimit();
1159 virtual bool PacketHandlerSendMessageById(
StationIndex dest,
const void* cpData,
size_t size);
1160 virtual bool PacketHandlerSendMessageByBitmap(u32 destBitmap,
const void* cpData,
size_t size);
1161 virtual void PacketHandlerReadIterationBegin(
void** ppIterator);
1162 virtual bool PacketHandlerReadIterationIsEnd(
const void* cpIterator);
1163 virtual void PacketHandlerReadIterationNext(
void* pIterator);
1164 virtual void PacketHandlerReadIteratorGet(
StationIndex* pSrc,
const void** cppPayloadPtr,
size_t* pPayloadSize,
const void* cpIterator);
1167 template <
int TEST_ID,
typename Arg>
1168 static void Test(
const CloneProtocol& obj, Arg* pArg = NULL);
1176 f32 m_CompRateTotal;
1179 u32 m_SendDataTotal;
nn::Result Initialize(const Setting &setting)
Initialization. Make this call between the BeginSetup and EndSetup functions.
const SendClone * SearchSendClone(CloneBase::Id cloneId) const
Searches for and gets the SendClone object with the specified ID.
Definition: clone_CloneProtocol.h:308
static const u32 COMPRESSION_LEVEL_HIGH
Specifies the compression level (compression rate emphasized) for the data to send specified in Setti...
Definition: clone_CloneProtocol.h:95
This is the base class for managing data that is sent and received. .
Definition: clone_CloneElementBase.h:40
Specifies stopping.
Definition: clone_CloneProtocol.h:575
u32 GetProfiledTotalSendSize(StationIndex stationIndex) const
Gets the amount of data, in bytes, sent since ResetProfiler was called.
f32 clockPerSec
Specifies the value to advance the clock per second.
Definition: clone_CloneProtocol.h:152
Specifies active.
Definition: clone_CloneProtocol.h:574
u32 ClockValue
Defines a type that holds a clock value.
Definition: clone_definitions.h:44
u32 GetProfiledLatestReceiveCount(StationIndex stationIndex) const
Gets the receive count for the last CloneProfiler::LATEST_BUFFER_SIZE times common::Scheduler::Dispat...
nn::Result UnregisterSendClone(CloneBase::Id cloneId)
Unregisters a SendClone.
Definition: clone_CloneProtocol.h:286
Class that represents time.
Definition: common_Time.h:39
StationIndex
Enumerates StationIndex values.
Definition: platformCtr.h:44
Definition of the StationId identifying the station within the session.
Definition: types.h:33
ErrorType GetError() const
Gets the error state.
Definition: clone_CloneProtocol.h:691
bool IsRegulatingClock() const
Gets whether the clock is being regulated.
Specifies that the station with a smaller station ID value was first.
Definition: clone_CloneProtocol.h:177
size_t GetElementSizeMax() const
Gets the maximum value that can be retrieved from the SerializePolicy::GetSize function of the clone ...
Definition: clone_CloneProtocol.h:239
SequentialSharingClone * SearchSequentialSharingClone(CloneBase::Id cloneId)
Searches for and gets the SequentialSharingClone object with the specified ID.
Definition: clone_CloneProtocol.h:501
nn::Result RegisterSendClone(SendClone *pClone, CloneBase::Id cloneId)
Registers a SendClone to the specified ID.
Definition: clone_CloneProtocol.h:254
ID indicating a station that is not present in the session.
Definition: platformCtr.h:59
This class is a derivative of CloneBase and provides functionality for managing unidirectional sendin...
Definition: clone_SendClone.h:33
nn::Result RegisterReceiveClone(ReceiveClone *pClone, StationIndex sendStationIndex, CloneBase::Id cloneId)
Registers a ReceiveClone to the specified ID.
const CloneProfilerBase * GetSendProfiler() const
Gets the object configured to manage send profiling.
Definition: clone_CloneProtocol.h:760
Specifies starting up.
Definition: clone_CloneProtocol.h:573
f32 clockRegulationRate
Specifies the rate at which to speed up or slow down the clock when re-regulating the clock...
Definition: clone_CloneProtocol.h:169
ErrorType
Enumerates the error state.
Definition: clone_CloneProtocol.h:674
u32 clockPerFrame
Specifies the value to advance the clock per frame.
Definition: clone_CloneProtocol.h:160
Specifies that the clock advances based on the number of times CloneProtocol::UpdateClock is called...
Definition: clone_CloneProtocol.h:126
static const u32 COMPRESSION_LEVEL_LOW
Specifies the compression level (speed emphasized) for the data to send specified in Setting::dataCom...
Definition: clone_CloneProtocol.h:93
Specifies inactive.
Definition: clone_CloneProtocol.h:572
nn::Result UnregisterSequentialSharingClone(CloneBase::Id cloneId)
Unregisters a SequentialSharingClone.
Definition: clone_CloneProtocol.h:490
int(* ClockPriorityJudgeFunction)(ClockValue clock, StationIndex stationA, StationIndex stationB)
Compares the order.
Definition: clone_CloneProtocol.h:89
virtual void Trace(u64 flag) const
Prints information that is useful for debugging.
Represents a protocol for sharing values between stations.
Definition: clone_CloneProtocol.h:51
State
Enumerates the operational states of CloneProtocol.
Definition: clone_CloneProtocol.h:570
bool IsInitialized(void)
Gets whether the clone module is initialized.
This base class manages PiaClone profiling.
Definition: clone_CloneProfilerBase.h:33
This is the base class for managing sending and receiving. .
Definition: clone_CloneBase.h:38
nn::Result RegisterSequentialSharingClone(SequentialSharingClone *pClone, CloneBase::Id cloneId)
Registers a SequentialSharingClone to the specified ID.
Definition: clone_CloneProtocol.h:458
void ResetProfiler()
Resets the results of send/receive profiling.
const size_t MAX_STATION_NUM
The maximum value for the number of stations that can participate in a Pia session.
Definition: platformCtr.h:64
ClockPriorityJudgeFunction clockPriorityJudgeFunction
Specifies the function for determining which station was first when an event occurs at the time clock...
Definition: clone_CloneProtocol.h:196
This class is a derivative of CloneBase and provides functionality for managing unidirectional receiv...
Definition: clone_ReceiveClone.h:34
Specifies no error.
Definition: clone_CloneProtocol.h:676
nn::Result UnregisterReceiveClone(ReceiveClone *pClone)
Unregisters a ReceiveClone.
Definition: clone_CloneProtocol.h:338
Specifies the clock value overflowed. Widespread inconsistencies may be occurring.
Definition: clone_CloneProtocol.h:679
ReceiveClone * SearchReceiveClone(StationIndex sendStationIndex, CloneBase::Id cloneId)
Searches for and gets the ReceiveClone object with the specified ID.
u16 GetMaxSendDelay() const
Gets the maximum time to defer the sending of data.
Definition: clone_CloneProtocol.h:716
Specifies an inconsistency in event management.
Definition: clone_CloneProtocol.h:677
u32 dataCompressionLevel
Specifies the compression level for data to send.
Definition: clone_CloneProtocol.h:208
SendClone * SearchSendClone(CloneBase::Id cloneId)
Searches for and gets the SendClone object with the specified ID.
Definition: clone_CloneProtocol.h:297
AtomicSharingClone * SearchAtomicSharingClone(CloneBase::Id cloneId)
Searches for and gets the AtomicSharingClone object with the specified ID.
Definition: clone_CloneProtocol.h:432
Stores settings specified during initialization.
Definition: clone_CloneProtocol.h:101
u32 GetProfiledTotalSendCount(StationIndex stationIndex) const
Gets the number of times sent since ResetProfiler was called.
void Finalize()
Finalizes the class instance.
nn::Result UnregisterSequentialSharingClone(SequentialSharingClone *pClone)
Unregisters a SequentialSharingClone.
Definition: clone_CloneProtocol.h:474
u32 GetProfiledLatestReceiveSize(StationIndex stationIndex) const
Gets the total amount of data, in bytes, received during the last CloneProfiler::LATEST_BUFFER_SIZE t...
nn::Result UnregisterAtomicSharingClone(CloneBase::Id cloneId)
Unregisters a AtomicSharingClone.
Definition: clone_CloneProtocol.h:421
Protocol base class.
Definition: transport_Protocol.h:44
State GetState() const
Gets the current operational state.
Definition: clone_CloneProtocol.h:583
Specifies that the application defines the method to use.
Definition: clone_CloneProtocol.h:179
nn::Result RegulateClock()
Starts re-regulating the clock.
nn::Result Stop()
Stops operation of CloneProtocol.
ClockPriorityJudgeMethod clockPriorityJudgeMethod
Specifies the method for determining which station was first when an event occurs at the time clock v...
Definition: clone_CloneProtocol.h:188
Specifies that the clock advances based on RTC.
Definition: clone_CloneProtocol.h:125
nn::Result SetProfiler(CloneProfilerBase *pSendProfiler, CloneProfilerBase *pReceiveProfiler)
Sets an object to manage send/receive profiling.
u32 GetProfiledTotalReceiveCount(StationIndex stationIndex) const
Gets the number of times received since ResetProfiler was called.
nn::Result SetMaxSendDelay(u16 maxSendDelay)
Sets the maximum time to defer the sending of data.
Setting()
Instantiates the object with default parameters (default constructor).
Definition: clone_CloneProtocol.h:108
const SequentialSharingClone * SearchSequentialSharingClone(CloneBase::Id cloneId) const
Searches for and gets the SequentialSharingClone object with the specified ID.
Definition: clone_CloneProtocol.h:512
nn::Result RegisterAtomicSharingClone(AtomicSharingClone *pClone, CloneBase::Id cloneId)
Registers a AtomicSharingClone to the specified ID.
Definition: clone_CloneProtocol.h:387
static const u32 COMPRESSION_LEVEL_MIDDLE
Specifies the compression level for the data to send specified in Setting::dataCompressionLevel.
Definition: clone_CloneProtocol.h:94
This class is a derivative of CloneBase and provides functionality for bidirectional sending and rece...
Definition: clone_SequentialSharingClone.h:35
u32 GetProfiledLatestSendCount(StationIndex stationIndex) const
Gets the send count for the last CloneProfiler::LATEST_BUFFER_SIZE times common::Scheduler::Dispatch ...
u32 Id
Specifies the type of the ID for identifying clones.
Definition: clone_CloneBase.h:68
nn::Result UnregisterSendClone(SendClone *pClone)
Unregisters a SendClone.
Definition: clone_CloneProtocol.h:270
This class is a derivative of CloneBase and provides functionality for exclusively controlling the lo...
Definition: clone_AtomicSharingClone.h:33
Specifies that the priority is changed based on the clock value so that no single station has an adva...
Definition: clone_CloneProtocol.h:178
nn::Result UnregisterAtomicSharingClone(AtomicSharingClone *pClone)
Unregisters a AtomicSharingClone.
Definition: clone_CloneProtocol.h:404
void UpdateClock()
Advances the clock by one frame.
static const u32 COMPRESSION_LEVEL_NONE
Specifies the compression level (no compression) for the data to send specified in Setting::dataCompr...
Definition: clone_CloneProtocol.h:92
ClockValue GetClock() const
Gets the current clock.
const CloneProfilerBase * GetReceiveProfiler() const
Gets the object configured to manage receive profiling.
Definition: clone_CloneProtocol.h:771
u32 GetProfiledLatestSendSize(StationIndex stationIndex) const
Gets the total amount of data, in bytes, sent during the last CloneProfiler::LATEST_BUFFER_SIZE times...
ClockType clockType
Specifies the standard to use for advancing the clock.
Definition: clone_CloneProtocol.h:144
ClockPriorityJudgeMethod
Enumerates the method for determining which station was first when an event occurs at the time clock ...
Definition: clone_CloneProtocol.h:175
const AtomicSharingClone * SearchAtomicSharingClone(CloneBase::Id cloneId) const
Searches for and gets the AtomicSharingClone object with the specified ID.
Definition: clone_CloneProtocol.h:443
u16 Id
Specifies the type of the ID for identifying clone elements.
Definition: clone_CloneElementBase.h:59
bool IsActiveStation(StationId stationId) const
Determines whether the CloneProtocol of the specified station is active.
nn::Result Start()
Starts operation of CloneProtocol.
nn::Result SetClockOverFlowSpanForDebug(u32 span)
(For debugging.) Sets the time until the clock value overflows.
nn::Result SetResendSpanRatio(f32 ratio)
Specifies the ratio of the resend interval for the base RTT obtained from profiling.
u32 GetProfiledTotalReceiveSize(StationIndex stationIndex) const
Gets the amount of data, in bytes, received since ResetProfiler was called.
ClockType
Enumerates the standard used for advancing the clock.
Definition: clone_CloneProtocol.h:123