section_path: Science and technology/Engineering
section_name: Engineering
paragraph_text: Engineering
  
  Technology during the Tang period was built also upon the precedents of the past. Previous advancements in clockworks and timekeeping included the mechanical gear systems of Zhang Heng (78–139) and Ma Jun (fl. 3rd century), which gave the Tang mathematician, mechanical engineer, astronomer, and monk Yi Xing (683–727) inspiration when he invented the world's first clockwork escapement mechanism in 725. This was used alongside a clepsydra clock and waterwheel to power a rotating armillary sphere in representation of astronomical observation. Yi Xing's device also had a mechanically timed bell that was struck automatically every hour, and a drum that was struck automatically every quarter-hour; essentially, a striking clock. Yi Xing's astronomical clock and water-powered armillary sphere became well known throughout the country, since students attempting to pass the imperial examinations by 730 had to write an essay on the device as an exam requirement. However, the most common type of public and palace timekeeping device was the inflow clepsydra. Its design was improved c. 610 by the Sui-dynasty engineers Geng Xun and Yuwen Kai. They provided a steelyard balance that allowed seasonal adjustment in the pressure head of the compensating tank and could then control the rate of flow for different lengths of day and night.
  
  There were many other mechanical inventions during the Tang era. These included a 3 ft (0.91 m) tall mechanical wine server of the early 8th century that was in the shape of an artificial mountain, carved out of iron and rested on a lacquered -wooden tortoise frame. This intricate device used a hydraulic pump that siphoned wine out of metal dragon -headed faucets, as well as tilting bowls that were timed to dip wine down, by force of gravity when filled, into an artificial lake that had intricate iron leaves popping up as trays for placing party treats. Furthermore, as the historian Charles Benn describes it:
  
  Midway up the southern side of the mountain was a dragon... the beast opened its mouth and spit brew into a goblet seated on a large lotus leaf beneath. When the cup was 80% full, the dragon ceased spewing ale, and a guest immediately seized the goblet. If he was slow in draining the cup and returning it to the leaf, the door of a pavilion at the top of the mountain opened and a mechanical wine server, dressed in a cap and gown, emerged with a wooden bat in his hand. As soon as the guest returned the goblet, the dragon refilled it, the wine server withdrew, and the doors of the pavilion closed... A pump siphoned the ale that flowed into the ale pool through a hidden hole and returned the brew to the reservoir inside the mountain.
  
  Yet the use of a teasing mechanical puppet in this wine-serving device wasn't exactly a novel invention of the Tang, since the use of mechanical puppets in China date back to the Qin dynasty (221–207 BC). In the 3rd century Ma Jun had an entire mechanical puppet theater operated by the rotation of a waterwheel. There was also an automatic wine-server known in the ancient Greco-Roman world, a design of the Greek inventor Heron of Alexandria that employed an urn with an inner valve and a lever device similar to the one described above. There are many stories of automatons used in the Tang, including general Yang Wulian's wooden statue of a monk who stretched his hands out to collect contributions; when the number of coins reached a certain weight, the mechanical figure moved his arms to deposit them in a satchel. This weight-and-lever mechanism was exactly like Heron's penny slot machine. Other devices included one by Wang Ju, whose "wooden otter" could allegedly catch fish; Needham suspects a spring trap of some kind was employed here.
  
  In the realm of structural engineering and technical Chinese architecture, there were also government standard building codes, outlined in the early Tang book of the Yingshan Ling (National Building Law). Fragments of this book have survived in the Tang Lü (The Tang Code), while the Song dynasty architectural manual of the Yingzao Fashi (State Building Standards) by Li Jie (1065–1101) in 1103 is the oldest existing technical treatise on Chinese architecture that has survived in full. During the reign of Emperor Xuanzong of Tang (712–756) there were 34,850 registered craftsmen serving the state, managed by the Agency of Palace Buildings (Jingzuo Jian).