Beispiel #1
0
        private void lukDørToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string addr = getSelectedAddr();

            if (addr != "")
            {
                Slave s = Program.GetSlaveByAddr(getSelectedAddr());
                s.RequestedNewState = true;
                s.SetState("Lukker");
                Program.updateSlaves = true;
                Program.WriteLog("Close cmd called on slave: " + s.Address + ".");
                s.SendMessage(CMD.Close);
            }
        }
Beispiel #2
0
        void Form1_DataReceived(object source, string data)
        {
            try
            {
                string   header = data.Substring(0, 1);
                string[] args   = data.Split(':');
                switch (header)
                {
                case "O":
                    Program.mode = 1;
                    Program.WriteLog("Got online status from STK500.");
                    break;

                case "S":
                    Program.WriteLog("Got status: " + args[1]);
                    int   pos = Array.IndexOf(Program._commands, args[1]);
                    Slave s   = Program.GetSlaveByAddr(_lastSlave.Address);
                    s.SetState(Program._humancmds[pos]);
                    s.RequestedNewState  = false;
                    Program.updateSlaves = true;
                    break;

                case "K":
                    Program.mode = 5;
                    break;

                case "L":
                    if (Program.mode == 5)
                    {
                        Program.mode = 7;
                    }
                    break;

                case "R":     // Master is ready again.
                    Program.WriteLog("Master is ready again.");
                    Program.masterReady = true;
                    break;

                default:
                    Program.WriteLog("Didnt recognize data: " + data);
                    break;
                }
            }
            catch (Exception e)
            {
            }
        }