Observability and controllability of piecewise affine and hybrid systems