Calculus of variations approach for state and parameter estimation in switched 1D hyperbolic PDEs