Previously, the authors have proposed the concept of piston trajectory-based combustion control enabled by a free piston engine (FPE) and shown its advantages on both thermal efficiency and emissions performance. The main idea of this control method is to design and implement an optimal piston trajectory into FPE and optimizes the combustion performance accordingly. To realize the combustion control in practice, it is obvious that the design of the optimal trajectory should consider the dynamic behaviors of the FPE's actuation systems as well as variable load dynamics and fuels' chemical kinetics. In this paper, a comprehensive model describing the operation of a hydraulic FPE fueled by diesel under HCCI combustion mode is developed. Such a high fidelity model includes four parts, i.e. the piston dynamics, the hydraulic dynamics, the thermodynamics and the fuel's chemical kinetics. Extensive simulation results are produced, showing that by varying the switching strategy of a fast-response digital valve, the hydraulic FPE can operate at different working loads in a stable manner. Additionally, analysis has been conducted to quantify the thermal efficiency as well as the frictional loss and throttling loss of the FPE. At last, a feedback control is developed to generate optimal switching strategies for the digital valve aimed to achieve the HCCI combustion phasing control. The resulted switching strategy of the digital valve not only increases the thermal efficiency by 0.76%, but also reduces frictional loss by 9.8%, throttling loss by 6.5% as well as NOx emission by 85.6%, which clearly demonstrates the effectiveness of the trajectory-based combustion control.