For a complex electromechanical product that is a cyber–physical system (CPS), its dynamic behaviors are embodied in the closed-loop control between the logic process in its cyber component and actual actuators/sensors in its physical component, and thus, a well-defined model of the control is important to create a digital twin that acts as much like the real machine as possible. This article proposes a Petri nets (PNs)-based modeling solution that employs hybrid PNs (HPNs) for physics and system of sequential systems with shared resources (S4R) nets for logic in building a hierarchical control model. We also present PNs technologies for implementing a smooth transition and bidirectional mapping from the virtual prototype to the real machine. These technologies involve a PNs integration of a reinforcement learning (RL) method for generating a workflow scheduling agent in design, an extension of PNs definitions that is compatible with the microcontroller for easy deployment in manufacturing, and an architecture of PNs execution recording for data-driven monitoring in service. A software kit is provided for the solution that includes an integrated development environment of PNs, tools for quickly building a virtual prototype, and a monitor server for remote data-driven monitoring. This solution is successfully applied in the development of a typical cyber–physical product case, namely, the chemiluminescence immunoassay (CLIA) analyzer.