Schneider Electric has agreed to buy PTC in an all-cash deal valuing the US software company's equity at around $22.6 billion (€20.1 billion).