Beispiel #1
0
 Packet CreatePacket(byte net, byte id, UInt16 oc, byte[] content)
 {
     Packet p = new Packet();
     p.TargetDeviceID = id;
     p.TargetSubnetID = net;
     p.OriginalDeviceType = 64000;
     p.OriginalDeviceID = 254;
     p.OriginalSubnetID = 254;
     p.OperationCode = oc;
     p.Content = content;
     p.FixHeader();
     p.FixLength();
     return (p);
 }
Beispiel #2
0
 private void tmrSendKey_Tick(object sender, EventArgs e)
 {
     if (WaitingForResponse)
     {
         log(LogTypes.MissKeyResponse, "@_@");
         SystemSounds.Exclamation.Play();
         faili = true;
     }
     if (chbPing.Checked)
     {
         Packet p = new Packet() { OperationCode = 0xE, OriginalDeviceID = 0xF4, OriginalSubnetID = 0xF4, TargetDeviceID = 0xFF, TargetSubnetID = 0xFF, OriginalDeviceType = 65530 };
         p.FixHeader();
         p.FixLength();
         p.FixCRC();
         comm.SendPacket(p);
     }
     else
     {
         byte channelno = (byte)rnd.Next(0, 32);
         if (channelno == 32)
             channelno = 255;
         else
             channelno = (byte)((channelno % 8) + 1);
         byte value;
         if (channelno == 255)
         {
             value = (byte)(rnd.Next(0, 2) * 100);
             if (value == 100)
                 for (int i = 0; i < 4; stat[i] = true, i++) ;
             else
                 for (int i = 0; i < 4; stat[i] = false, i++) ;
         }
         else
         {
             if (stat[channelno])
             {
                 value = 0; stat[channelno] = false;
             }
             else
             {
                 value = 100; stat[channelno] = true;
             }
         }
         byte[] cntnt = PCSingleChannelControl.GetNew(channelno, value, 0, 1);
         Packet p = new Packet();
         p.OriginalDeviceType = 0xABC0;
         p.OriginalDeviceID = 0xC0;
         p.OriginalSubnetID = 1;
         p.TargetDeviceID = 1;
         p.TargetSubnetID = 1;
         p.OperationCode = 0x31;
         p.Content = cntnt;
         p.FixLength();
         p.FixHeader();
         p.FixCRC();
         WaitingForResponse = true;
         comm.SendPacket(p);
         sw.Restart();
         SSend++; lblSSend.Text = SSend.ToString();
         log(LogTypes.SendKey, string.Format("{2} key {0} to {1}", channelno, value, SSend.ToString().PadLeft(7, '0')));
     }
 }
Beispiel #3
0
 private void btnPing_Click(object sender, EventArgs e)
 {
     Packet p = new Packet() { OperationCode = 0xE, OriginalDeviceID = 0xF4, OriginalSubnetID = 0xF4, TargetDeviceID = 0xFF, TargetSubnetID = 0xFF, OriginalDeviceType = 65530 };
     p.FixHeader();
     p.FixLength();
     p.FixCRC();
     SendPacket(p);
     //SP.Write(p.Data, 0, p.Data.Length);
 }