Ejemplo n.º 1
0
    ///////////////////////////////////////////////////////////////
    private void SetInput(string str, bool bInt, byte[] buf)
    {
        ushort IOID = IOChannelMgr.inst().GetIOChannel(str);

        if (IOID > 0)
        {
            int    length = (m_Inputs != null) ? m_Inputs.Length : 0;
            byte[] bytes  = new byte[length + buf.Length + 2];
            if (length > 0)
            {
                m_Inputs.CopyTo(bytes, 0);
            }

            if (buf.Length == 8)
            {
                IOID = (ushort)(IOID | (1 << (int)IOFlags.LENGTH8));
            }
            if (bInt)
            {
                IOID = (ushort)(IOID | (1 << (int)IOFlags.INTEGER));
            }

            BitConverter.GetBytes(IOID).CopyTo(bytes, length);
            buf.CopyTo(bytes, length + 2);
            m_Inputs = bytes;
        }
    }
Ejemplo n.º 2
0
    //////////////////////////////////////////////////////////////////////////
    public bool GetInput(string str, out decimal fValue)
    {
        if (str == "SPEED")
        {
            fValue = m_Speed;
            return(true);
        }

        if (str == "DIRECTION")
        {
            fValue = m_Direction;
            return(true);
        }

        if (str == "ALT")
        {
            fValue = m_Alt;
            return(true);
        }

        if (m_Inputs != null)
        {
            int IOID = IOChannelMgr.inst().GetIOChannel(str);
            int i    = 0;
            while (i < m_Inputs.Length)
            {
                int  id     = (int)BitConverter.ToUInt16(m_Inputs, i);
                bool b64bit = (id & (1 << (int)IOFlags.LENGTH8)) != 0;
                if ((id & 0xFFF) == IOID)
                {
                    if ((id & (1 << (int)IOFlags.INTEGER)) != 0)
                    {
                        if (b64bit)
                        {
                            fValue = BitConverter.ToUInt64(m_Inputs, i + 2);
                        }
                        else
                        {
                            fValue = BitConverter.ToInt32(m_Inputs, i + 2);
                        }
                    }
                    else
                    {
                        fValue = (decimal)(b64bit ? BitConverter.ToDouble(m_Inputs, i + 2) : BitConverter.ToSingle(m_Inputs, i + 2));
                    }
                    return(true);
                }
                i += 2 + (b64bit ? 8 : 4);
            }
        }
        fValue = 0;
        return(false);
    }
Ejemplo n.º 3
0
    string GetPacket(TrackerPacket point)
    {
        decimal key = 0;

        point.GetInput("EKEY", out key);

        DateTime dt  = CTime.GetTime(point.m_Time);
        string   str = dt.ToString("ddMMyy") + ";" +
                       dt.ToString("HHmmss") + ";" +
                       GetCoord(Math.Abs(point.m_fLat), true) + ";" +
                       ((point.m_fLat > 0) ? "N" : "S") + ";" +
                       GetCoord(Math.Abs(point.m_fLng), false) + ";" +
                       ((point.m_fLng > 0) ? "E" : "W") + ";" +
                       point.m_Speed + ";" +
                       point.m_Direction + ";" +
                       point.m_Alt + ";" +
                       point.m_SatteliteCount + ";" +
                       "0" + ";" +
                       ";" +
                       ";" +
                       ";" +
                       ((key > 0) ? ((long)key).ToString("X12") : "NA") + ";";

        byte[] inputs = point.GetIOBuffer();
        if (inputs != null)
        {
            int i = 0;
            while (i < inputs.Length)
            {
                ushort id     = BitConverter.ToUInt16(inputs, i);
                bool   b64bit = (id & (1 << (int)TrackerPacket.IOFlags.LENGTH8)) != 0;
                i += 2 + (b64bit ? 8 : 4);

                decimal fValue = 0;
                string  name   = IOChannelMgr.inst().GetIOChannel((ushort)(id & 0xFFF));
                if (name != null && point.GetInput(name, out fValue))
                {
                    if ((id & (1 << (int)TrackerPacket.IOFlags.INTEGER)) != 0)
                    {
                        str += name + ":1:" + fValue + ",";
                    }
                    else
                    {
                        str += name + ":2:" + CObject.Float2XML(fValue) + ",";
                    }
                }
            }
        }
        return(str.Trim(','));
    }
Ejemplo n.º 4
0
    ///////////////////////////////////////////////////////////////
    public string ToXML()
    {
        string result = "<point " +
                        "IMEI=\"" + m_ID + "\" " +
                        "Time=\"" + m_Time + "000\" " +
                        "Lat=\"" + Float2XML(m_fLat) + "\" " +
                        "Lng=\"" + Float2XML(m_fLng) + "\" " +
                        "Alt=\"" + m_Alt + "\" " +
                        "Speed=\"" + m_Speed + "\" " +
                        "Status=\"" + m_Status + "\" " +
                        "Sat=\"" + m_SatteliteCount + "\" " +
                        "GSM=\"" + m_ulMNID + "\" " +
                        "IO=\"";

        if (m_Inputs != null)
        {
            int i = 0;
            while (i < m_Inputs.Length)
            {
                int  id     = (int)BitConverter.ToUInt16(m_Inputs, i);
                bool b64bit = (id & (1 << (int)IOFlags.LENGTH8)) != 0;

                string strValue = "";
                if ((id & (1 << (int)IOFlags.INTEGER)) != 0)
                {
                    if (b64bit)
                    {
                        strValue = string.Format("{0:X2} ", BitConverter.ToUInt64(m_Inputs, i + 2));
                    }
                    else
                    {
                        strValue = BitConverter.ToInt32(m_Inputs, i + 2).ToString();
                    }
                }
                else
                {
                    strValue = Float2XML((decimal)(b64bit ? BitConverter.ToDouble(m_Inputs, i + 2) : BitConverter.ToSingle(m_Inputs, i + 2)));
                }
                result += IOChannelMgr.inst().GetIOChannel((ushort)(id & 0xFFF)) + "=" + strValue + " ";
                i      += 2 + (b64bit ? 8 : 4);
            }
        }
        return(result + "\" />");
    }
Ejemplo n.º 5
0
    ///////////////////////////////////////////////////////////////
    public override string ToString()
    {
        DateTime dt     = CTime.GetTime(m_Time).ToLocalTime();
        string   result = "IMEI=" + m_ID +
                          " Time=" + dt.ToString("dd.MM.yyyy-HH:mm:ss") +
                          " Lat=" + Float2XML(m_fLat) +
                          " Lng=" + Float2XML(m_fLng) +
                          " Alt=" + m_Alt +
                          " Dir=" + m_Direction +
                          " Speed=" + m_Speed +
                          " GSM=" + m_ulMNID +
                          " Sat=" + m_SatteliteCount;

        if (m_Inputs != null)
        {
            int i = 0;
            while (i < m_Inputs.Length)
            {
                int  id     = (int)BitConverter.ToUInt16(m_Inputs, i);
                bool b64bit = (id & (1 << (int)IOFlags.LENGTH8)) != 0;

                decimal fValue;
                if ((id & (1 << (int)IOFlags.INTEGER)) != 0)
                {
                    if (b64bit)
                    {
                        fValue = BitConverter.ToUInt64(m_Inputs, i + 2);
                    }
                    else
                    {
                        fValue = BitConverter.ToInt32(m_Inputs, i + 2);
                    }
                }
                else
                {
                    fValue = (decimal)(b64bit ? BitConverter.ToDouble(m_Inputs, i + 2) : BitConverter.ToSingle(m_Inputs, i + 2));
                }
                result += " " + IOChannelMgr.inst().GetIOChannel((ushort)(id & 0xFFF)) + "=" + Float2XML(fValue);

                i += 2 + (b64bit ? 8 : 4);
            }
        }
        return(result);
    }