In this work, a freeway traffic control scheme is proposed to regulate traffic in freeway networks via multi-class ramp metering. Specifically, each controlled on-ramp of the system adopts a feedback regulator of proportional-integral type and is able to compute the traffic flows entering the freeway mainstream, differentiated for each class of vehicles, e.g., cars and trucks. Since a crucial aspect of proportional-integral controllers is the tuning of parameters, in this work an optimization-based procedure is devised to determine the controller parameters to be used in the different on-ramps of the network, according to the detected traffic conditions. To this end, a set of representative traffic scenarios is defined and, for each scenario, an offline optimization procedure is applied to determine the optimal parameters. Then, in real time, a controller parameter selector identifies the scenario associated with the current system conditions and communicates to the local controllers the optimal parameters to be applied. The effectiveness of the proposed control scheme is tested in a simulative example and the main results are discussed in the paper.