示例#1
0
        private void opdaterStatusToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string addr = getSelectedAddr();

            if (addr != "")
            {
                Slave s = Program.GetSlaveByAddr(getSelectedAddr());
                Program.WriteLog("Status cmd called on slave: " + s.Address + ".");
                s.SendMessage(CMD.Status);
                _lastSlave = s;
            }
        }
示例#2
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);
            }
        }
示例#3
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)
            {
            }
        }
示例#4
0
        private void slaveStatusTimer_Tick(object sender, EventArgs e)
        {
            if (Program.mode != 7)
            {
                return;
            }

            //if (!Program.masterReady)
            //    return;

            Slave s = Program.GetSlaves().First();

            if (s.ReadyNextMsg())
            {
                s.SendMessage(CMD.Status);
                _lastSlave = s;
            }
        }
示例#5
0
        private void slaveStatusTimer_Tick(object sender, EventArgs e)
        {
            if (Program.mode != 7)
                return;

            //if (!Program.masterReady)
            //    return;

            Slave s = Program.GetSlaves().First();
            if (s.ReadyNextMsg())
            {
                s.SendMessage(CMD.Status);
                _lastSlave = s;
            }
        }
示例#6
0
 private void opdaterStatusToolStripMenuItem_Click(object sender, EventArgs e)
 {
     string addr = getSelectedAddr();
     if (addr != "")
     {
         Slave s = Program.GetSlaveByAddr(getSelectedAddr());
         Program.WriteLog("Status cmd called on slave: " + s.Address + ".");
         s.SendMessage(CMD.Status);
         _lastSlave = s;
     }
 }