Exemple #1
0
 /// <summary>
 /// if a client is offline, then show the warning in GUI
 /// </summary>
 /// <param name="sender"></param>
 public static void ShowClientOffLine(string sender)
 {
     for (int id = 1; id <= 6; id++)
     {
         if (Server.stationList[id - 1].ahaddress == sender)
         {
             Server.gufList[id - 1].InitGUF(-1, id, 2);      // when client offline, reset the guflist
             Server.stationList[id - 1].InitStationList(id); // when client offline, reset the station list
             Server.stationList[id - 1].aTimer.Stop();
             string msgTemp = string.Format("station: {0} is offline", id);
             Server.stationList[id - 1].errorInfo = msgTemp;
             ClientGUFStatus.UpdateStationsData(id, 1, ClientStatusType.Unknown);
             ClientGUFStatus.UpdateStationsData(id, 2, ClientStatusType.Unknown);
             ClientGUFStatus.UpdateStationsData(id, 3, ClientStatusType.Unknown);
             ClientGUFStatus.UpdateStationsData(id, 4, ClientStatusType.Unknown);
             LogerHelper2.ToAutoTestLogFile(DateTime.Now.ToString() + ": station " + id + " is offline");
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// server send message to station clinet
        /// </summary>
        /// <param name="msg">message information which need to send</param>
        /// <param name="ip">client ip and port</param>
        /// <returns></returns>
        public bool SendMsg(Message msg, string ip)
        {
            string s        = null;
            int    clientId = 99;
            bool   b        = true;

            for (int i = 0; i < lstClient.Count; i++)
            {
                s = lstClient[i].Name;
                if (string.Compare(ip, s) == 0)
                {
                    clientId = i;
                }
            }
            if (clientId == 99)
            {
                LogerHelper2.ToLog("station:" + msg.stationId + " is offline, can't control or send commond to this station", 3);
                return(false);
            }
            string msgTemp = string.Format("to: {4}  StationID: {0}\tMessageID: {1}\tType: {2}\t Info:{3}", msg.stationId, msg.MsgId, msg.MsgType.ToString(), msg.Info, lstClient[clientId].Name);

            //if (msg.MsgType != MsgType.Ack)
            //{
            //    LogerHelper2.ToLog(msgTemp, 1);
            //}
            for (int i = 0; i < 3; i++)  // if first time is send fail, then send again
            {
                b = Send(Message.ConvertMsgToByte(msg), lstClient[clientId]);
                if (b == false)
                {
                    LogerHelper2.ToLog("commond send fail", 3);
                    Server.stationList[int.Parse(msg.stationId) - 1].errorInfo = msg.Info + "commond send fail";
                    ClientGUFStatus.UpdateStationsData(int.Parse(msg.stationId), 4, ClientStatusType.Unknown);
                    continue;
                }
                else
                {
                    break;
                }
            }
            return(b);
        }