Abstract-Two Major challenges in securing reliable Optimal Power Flow (OPF) operations are: (i) fluctuations induced due to renewable generators and energy demand, and (ii) interaction and interoperability among the different entities. Addressing these issues requires handling both physical (e.g., power flows) and cyber aspects (computing and communication) of the energy grids, i.e, a cyber-physical systems (CPS) approach is necessitated. First, this investigation proposes a receding horizon control (RHC) based approach for solving OPF to deal with the uncertainties. It uses forecasts on renewable generation and demand and an optimization model solving a predictive control problem to secure energy balance while meeting the network constraints. Second, to handle the interoperability issues, a middleware using common information model (CIM) for exchanging information among applications and the associated profiles are presented. CIM profiles modelling various components and aspects of the RHC based OPF is proposed. In addition, a middleware architecture and services to collect information is discussed. The proposed CPS approach is illustrated in a distribution grid in Steinkjer, Norway having 85 nodes, 700 customers, 3 hydrogenerators, and various industrial loads. Our results demonstrate the benefits of CPS approach to implement OPF addressing also the interoperability issues.