How can I define that teacher can have max 3 consecutive periods(but he can have 2 doubles)
First you would need to define that each teacher can have max 4 consecutive lessons:
Our teachers cannot teach more than 6 lessons consecutively
Then you need to say that each teacher can have max 3 consecutive single lessons:
Then you need to specify that teacher can have max 3 consecutive lessons where there are both single and doubles mixed:
in both cardrelationships you might want to select relevant subjects, so that for example teachers preparation time and lunch are not counted into the consecutive periods count.