Ejemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="cmdName"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public static byte[] CreateCmd(string cmdName, DeviceInfo info)
 {
     System.Diagnostics.Debug.Assert(info != null);
     if (cmdName == READ_DTU_SETTINGS)
     {
         return CreateReadDtuDscSettingCmd(info.Sim);
     }
     return null;
 }
Ejemplo n.º 2
0
        public frmCsinfo( DeviceInfo info )
        {
            //
            // Windows ���������֧���������
            //
            InitializeComponent();

            //
            // TODO: �� InitializeComponent ���ú�����κι��캯������
            //
            Debug.Assert( info != null );
            _info = info;
        }
Ejemplo n.º 3
0
        public frmCmdSelect( DeviceInfo info )
        {
            //
            // Windows ���������֧���������
            //
            InitializeComponent();

            //
            // TODO: �� InitializeComponent ���ú�����κι��캯������
            //
            FormAdjuster.SetOptionTypeForm( this );
            System.Diagnostics.Debug.Assert( info != null );

            _csinfo = info;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private string[] GetCsinfoRange(DeviceInfo info)
        {
            string[] r = new string[9];
            int i = 0;
            r[i++] = info.Address;
            r[i++] = info.DeviceAddress.ToString();
            r[i++] = GetDeviceKindAndDevice(info);
            r[i++] = info.Sim;
            r[i++] = GetSocketString(info.Socket);
            r[i++] = info.ConnectDateTime.ToString();
            r[i++] = info.LastCollDateTime.ToString();
            r[i++] = info.IsUse.ToString();
            r[i++] = GetIPString(info.IP);

            return r;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="text"></param>
 /// <returns></returns>
 private ListViewItem CreateListViewItem(DeviceInfo info)
 {
     string text = info.Address;
     ListViewItem item = new ListViewItem(text);
     for (int i = 0; i < 9; i++)
     {
         item.SubItems.Add("-");
     }
     item.Tag = info;
     return item;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// �����û�����
        /// </summary>
        /// <param name="by"> DTU ���� </param>
        /// <param name="bufLen"></param>
        /// <param name="skt"></param>
        internal void ProcessUserData(DeviceInfo deviceInfo, byte[] by, int bufLen, Socket skt, LogItem li)
        {
            #region ͨѶЭ��
            // ----------------------------------------------------------------
            // 3.5.1 DTU ���͸�DSC �����ݰ�DTU->DSC
            //
            // ��ʼ��־     ������  ������  DTU���ʶ����   ������־    �û�����
            // 1byte        1byte   2bytes  11bytes         1byte       <=1024bytes
            // 0x7B         0x09    0x10    ...             0x7B        ...
            // ----------------------------------------------------------------
            #endregion //ͨѶЭ��

            bool picked = false;
            // ��ȡ�û�����
            //
            byte[] inbyte = SGDtu.GetUserData(by);
            bufLen = inbyte.Length;

            byte[][] gateCds = GateController.Pick(inbyte);
            if (gateCds != null)
            {
                picked = true;
                foreach (byte[] bs in gateCds)
                {
                    Gate_Read(bs, /*bs.Length,*/ li);
                }
            }

            byte[][] pumpCds = PumpController.Pick(inbyte);
            if (pumpCds != null)
            {
                picked = true;
                foreach (byte[] bs in pumpCds)
                {
                    ProcessPumpData(bs, bs.Length, li);
                }
            }

            //byte[][] pumpCds705 = PumpController705.Pick( inbyte );
            //if ( pumpCds705 != null )
            //{
            //    picked = true;
            //    foreach( byte[] bs in pumpCds705 )
            //    {
            //        Pump_Read( bs, bs.Length, li );
            //    }
            //}

            // for device xd202
            //
            if (StringHelper.Equal(deviceInfo.DeviceKind, "Gate")
                &&
                StringHelper.Equal(deviceInfo.DeviceType, XD202.DeviceType)
                )
            {
                Gate_His gateHistroyData;

                picked = XD202.Process(deviceInfo, inbyte, li, out gateHistroyData);
                if (picked)
                {
                    Gate_View_His(gateHistroyData, this.listView_Gate);
                }
            }

            if (!picked)
            {
                li.Add("pick ctrl data", false);
                li.ShouldLog = true;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sck"></param>
        private void ProcessDisconnective(Socket sck, DeviceInfo sender)
        {
            //TODO: process disconnective socket
            //
            LogItem li = new LogItem("Socket disconnect", sender.IP != null ? sender.IP.ToString() : "<null>");
            _log.AddCommon(li);

            Socket temp = sck;

            foreach (object obj in InfoList_All)
            {
                DeviceInfo info = (DeviceInfo)obj;
                if (info.Socket == temp)
                {
                    if (_socketEvent != null)
                    {
                        _socketEvent(this, new SocketEventArgs(info, false));
                    }
                    info.Socket = null;
                }
            }
            try
            {
                temp.Shutdown(SocketShutdown.Both);
            }
            catch (ObjectDisposedException)
            {
            }
            temp.Close();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private string GetDeviceInfoString(DeviceInfo info)
        {
            Debug.Assert(info != null);
            string s = string.Format("StationName: {0}\r\nCommAddr: {1}\r\nSign: {2}\r\nSim: {3}\r\nSocket: {4}\r\n",
                info.Address,
                info.DeviceAddress,
                info.DeviceKind,
                info.Sim,
                GetSocketString(info.Socket)
                );

            if (info.DeviceType.Length > 0)
            {
                s += string.Format(
                    "Type: {0}\r\n",
                    info.DeviceType
                    );
            }

            return s;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private string GetDeviceKindAndDevice(DeviceInfo info)
 {
     if (info.DeviceType.Length > 0)
     {
         return string.Format("{0}({1})", info.DeviceKind, info.DeviceType);
     }
     else
     {
         return info.DeviceKind;
     }
 }
Ejemplo n.º 10
0
Archivo: Events.cs Proyecto: hkiaipc/lx
 /// <summary>
 /// 
 /// </summary>
 /// <param name="info"></param>
 public TimeOutEventArgs( DeviceInfo info )
 {
     _info = info;
 }
Ejemplo n.º 11
0
Archivo: Events.cs Proyecto: hkiaipc/lx
        private bool _isConnectedEvent; // connect event or disconnect event

        #endregion Fields

        #region Constructors

        public SocketEventArgs( DeviceInfo info , bool connected )
        {
            if ( info == null )
                throw new ArgumentNullException( "info" );

            _info = info;
            _isConnectedEvent = connected;
        }
Ejemplo n.º 12
0
Archivo: Group.cs Proyecto: hkiaipc/lx
        /// <summary>
        /// 
        /// </summary>
        /// <param name="di"></param>
        public void MarkLastDeviceInfo(DeviceInfo di)
        {
            Debug.Assert(di.IP.Equals(this.IP), "mark deviceInfo.ip != group.ip");

            _lastDeviceInfo = di;
            _lastDateTime = DateTime.Now;
        }
Ejemplo n.º 13
0
Archivo: XD202.cs Proyecto: hkiaipc/lx
        /// <summary>
        /// 
        /// </summary>
        /// <param name="deviceInfo"></param>
        /// <param name="inbyte"></param>
        /// <param name="li"></param>
        /// <returns></returns>
        public static bool Process(DeviceInfo deviceInfo, byte[] inbyte, LogItem li, out GateDriver.Gate_His gateHisortyData)
        {
            gateHisortyData = null;

            // parse xd202 data
            //
            string errormsg;
            object gateHis = Parse(inbyte,out errormsg);

            // save to db
            //
            if (gateHis != null)
            {
                DbClass db = new DbClass();
                db.Gate_His_Save(ref gateHis);

                gateHisortyData = (GateDriver.Gate_His)gateHis;
                return true;
            }
            else
            {
                li.Add("Error", errormsg);
                return false;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// create deviceInfo class from db, and save to Global.CSinfoList
        /// </summary>
        public void GetInfoAll()
        {
            this.DataBaseConnect();
            SqlConnection conn = myConnection;
            conn.Open();

            string serverIP = Config.Default.ServerIP;

            string sql = MakeGateSql(serverIP);

            SqlCommand cmd = new SqlCommand(sql, conn);
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                DeviceInfo info = new DeviceInfo(
                    dr["Address"].ToString().Trim(),
                    int.Parse(dr["ComAdr"].ToString()),
                    dr["Sim"].ToString().Trim(),
                    DeviceInfoManager.TEXT_GATE,
                    1,
                    dr["GateIP"].ToString().Trim()
                    );

                info.DeviceType = GetDeviceType(dr);
                info.ID = int.Parse(dr["Id"].ToString());

                DeviceInfoManager.DeviceInfoList.Add(info);
            }
            dr.Close();

            sql = MakePumpSql(serverIP);
            cmd = new SqlCommand(sql, conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                DeviceInfo info = new DeviceInfo(
                    dr["Address"].ToString().Trim(),
                    int.Parse(dr["ComAdr"].ToString()),
                    dr["Sim"].ToString().Trim(),
                    DeviceInfoManager.TEXT_PUMP,
                    1,
                    dr["PumpIP"].ToString().Trim()
                    );

                info.DeviceType = GetDeviceType(dr);
                info.ID = int.Parse(dr["Id"].ToString());
                DeviceInfoManager.DeviceInfoList.Add(info);
            }
            dr.Close();
            cmd.Dispose();
            conn.Close();
        }
Ejemplo n.º 15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="info"></param>
 public TimeOutEventArgs(DeviceInfo info)
 {
     _info = info;
 }