Be + to-infinitive is used to express:
- Official arrangements or plans:
We are to meet at his office at six.
The Prime Minister is to visit Poland next week.
- Orders and obligations:
At the end of the course, all students are to take a written exam.
You are to do your homework before you go to the cinema.
- Things that should be done:
What am I to do?
You are to stay here until I send for you.
- A possible aim when saying what should be done to reach it:
If you are to work here for more than three months, you must have a
residence permit.
- What is fated to happen:
I met a girl who was to become a queen.
- Pre-conditions:
If we are to get there on time we had better hurry.
- Prohibition (in the negative):
You are not to do that again.
In your examples # 1 is a prohibition, # 2 is an order, # 3 is what should be done, # 4 is a fulfilled plan (otherwise it were to be "to have spoken"), # 5 is an order, and # 6 is asking about whether something should be or is obligatory to be done.
Regarding obligations, the use of "must" expresses the strong ones and usually means that some personal circumstance makes the obligation necessary, and for this reason the speaker almost certainly agrees with the obligation, whereas to be + to-infinitive shows that the obligation is/has to be just put up with no matter what the speaker thinks about it.
You are to return to the regiment by 10 p.m. (a comander's order)
I was to execute the deserter and I did it.( I was ordered to, and
orders are peromptory)
He is your brother. You must help him. (it's your moral obligation).
I must stop him before it's too late. (I feel it must be done. Why not
by me?)
The source: Michael Swan, Practical English Usage, Third Edition, Oxford University Press, ISBN-13: 9780194420969, p.80, para 91