The Technology of Medieval China

I just spent a few weeks in Beijing as a tourist with my son. We hit a lot of temples and museums to see the classical medieval Chinese architecture and technology. I was struck by the beauty and strangeness of some medieval technology, especially astronomy and the measurement of time.
Concept of Time
Medieval Beijing tracked time for lots of reasons and they divided their night into five blocks of two hours:
First Geng Xu (dog) Shi: 19:00-21:00
Second Geng Hai (pig) shi: 21:00-23:00
Third Geng Zi (rat) shi: 23:00-1:00
Fourth Geng Chou (ox) shi: 1:00-3:00
Fifth Geng Yin (tiger) shi: 3:00-5:00
Two towers, the Drum Tower and the Bell Tower, signaled time for the city. The 1.4m in diameter drums were beaten and 7m-tall bell rung with a log as a clapper at the first and fifth gengs. The other gengs were marked by bell alone, and at the first geng, the city gates were closed and streets cleared.
But how did they know what time it was in medieval Beijing?