open-dis / open-dis-cpp

C++ implementation of the IEEE-1278.1 Distributed Interactive Simulation (DIS) application protocol v6 and v7
BSD 2-Clause "Simplified" License
90 stars 65 forks source link

setTimestamp on EntityStatePdu #94

Open AJPerriello opened 6 months ago

AJPerriello commented 6 months ago

I've done reading and haven't found a good code example. But from what I read in the standard is that DIS servers may reject EntityStatePdu is the timestamp is not 0 (relative) or valid. So using this open-dis library I'm not sure how this would work properly. I've seen other dis implementations that manage more code and logic to handle timestamps and updating them for persistent entities. In other words, if timestamps are not relevant or too latent then it could be perceived that the entity is no longer existing. Unix time in milliseconds since epoch fits in 64 bit long, but not 32 bit int, furthermore, it seems timestamps need to be DIS compliant by setting the least significant bit too 0 or 1. (relative or absolute) and then the next 31 bits could hold at most (2^31) - 1 values. This will not work for epoch time without significant loss, so I think it means that time values are how many ticks since the top of the hour. I can't see how this would be used with the current library APIs on Pdu::setTimestamp(). An example would help. But I can't find one. For now, I'll just keep trying different techniques to see what works. If you have more info or a good example in C++ thank you.

leif81 commented 2 months ago

@AJPerriello there's a class in the Java library named disTime that may help answer your questions

https://github.com/open-dis/open-dis-java/blob/master/src%2Fmain%2Fjava%2Fedu%2Fnps%2Fmoves%2Fdisutil%2FDisTime.java

leif81 commented 2 months ago

@AJPerriello 's a class in the Java library named disTime may help answer your questions

https://github.com/open-dis/open-dis-java/blob/master/src%2Fmain%2Fjava%2Fedu%2Fnps%2Fmoves%2Fdisutil%2FDisTime.java

Many simulations, especially the in-house kind, ignore timestamp and handle packets the order they are received.