Пример #1
0
        public override bool Send(PDU pdu)
        {
            var d = Devices.I().FindById(pdu.IdDispositivo);

            if (d != null && d.State == DeviceTypes.States.ONLINE)
            {
                d.Touch(pdu.Destino);
            }
            if (d != null && d.SupportsChecksum)
            {
                pdu.Options = 0x80;
            }
            var size            = 0;
            var instance_buffer = new byte[8192];

            CODEC.Encode(ref instance_buffer, ref size, pdu);
            return(sendTo(instance_buffer, size, pdu.Destino.UDP));
        }
Пример #2
0
        public override bool Send(PDU pdu)
        {
            var d = Devices.I().FindById(pdu.IdDispositivo);

            STrace.Debug(GetType().FullName, String.Format("XBEE/SEND: d={0}", (d == null ? "(nil)" : d.LogId)));
            if (d != null && d.State == DeviceTypes.States.ONLINE)
            {
                d.Touch(pdu.Destino);
            }
            var size            = 0;
            var instance_buffer = new byte[8192];
            var bytes           = CODEC.Encode(ref instance_buffer, ref size, pdu);

            STrace.Debug(GetType().FullName, String.Format("---XBEE SENDING {0}/{1} bytes TO {2}----------\n{3}", bytes, size, pdu.Destino.XBee, pdu.Trace("")));

            /*if (pdu.SourcePdu != null && pdu.SourcePdu.CH == (byte)Codes.HighCommand.MsgPosicion)
             * {
             *  STrace.Trace(GetType().FullName,0, "--- PAUSA XBEE DE POSICION ---");
             *  Thread.Sleep(1000);
             * }*/
            return(links[0].Send(instance_buffer, size, pdu.Destino.XBee));
        }
Пример #3
0
        public override bool Send(PDU pdu)
        {
            var size = 0;
            // to do: que el buffer se maneje automaticamente.
            var d = Devices.I().FindById(pdu.IdDispositivo);

            if (d != null)
            {
                d.Touch(pdu.Destino);
            }
            var instance_buffer = new byte[1024];

            //Marshall.Debug("---TCP SENDING-------------------------------------------------------------");
            //Marshall.Debug(pdu.Trace(""));
            //Marshall.Debug("---------------------------------------------------------------------------");
            CODEC.Encode(ref instance_buffer, ref size, pdu);
            if (!conexiones.ContainsKey(pdu.Destino.TCP))
            {
                STrace.Debug(GetType().FullName, "No existe la conexion TCP especificada.");
                return(false);
            }
            conexiones[pdu.Destino.TCP].send(instance_buffer, size);
            return(true);
        }