Beispiel #1
0
 public void OpenDoor()
 {
     openTry++;
     startX = transform.position.x;
     t      = 0.0f;
     state  = DoorsState.Opening;
 }
        public void openDoor(string loc)
        {
            CurrentState = DoorsState.Open;

            switch (loc)
            {
            case "top":
                Texture = "Dragon_Gate_top_open";
                break;

            case "bottom":
                Texture = "Dragon_Gate_bottom_open";
                break;

            case "left":
                Texture = "Dragon_Gate_left_open";
                break;

            case "right":
                Texture = "Dragon_Gate_right_open";
                break;

            default:
                Texture = "Dragon_Gate_top_open";
                break;
            }
        }
Beispiel #3
0
        public bool GetDoorState(ref DoorsState state)
        {
            bool blRet = false;

            try
            {
                int iState = 0;
                if (axCZKEM1.GetDoorState(iMachineNumber, ref iState))
                {
                    blRet = true;
                    if (iState == 0)
                    {
                        state = DoorsState.开门;
                    }
                    else if (iState == 1)
                    {
                        state = DoorsState.关门;
                    }
                }
                else
                {
                    blRet = false;
                }
            }
            catch (Exception ex)
            {
                if (frmMain.blDebug)
                {
                    MessageUtil.ShowTips(ex.Message);
                }
            }
            return(blRet);
        }
Beispiel #4
0
        /// <summary>
        /// 获取门的状态 门号
        /// </summary>
        /// <param name="doorNo"></param>
        /// <returns></returns>
        public DoorsState GetDoorState(int doorNo)
        {
            DoorsState state = DoorsState.初值;

            if (wgController == null)
            {
                wgController = new wgMjController();
                wgController.ControllerSN = (int)intSn;
                wgController.PORT         = 60000;
                wgController.IP           = strIp;
            }
            if (wgController.GetMjControllerRunInformationIP() > 0) //取控制器信息
            {
                bool bl = wgController.RunInfo.IsOpen(doorNo);
                if (bl)
                {
                    state = DoorsState.关门;
                }
                else
                {
                    state = DoorsState.开门;
                }
            }
            else
            {
                state = DoorsState.通信;
            }
            return(state);
        }
        public void closedDoor(string loc)
        {
            CurrentState = DoorsState.Closed;
            switch (loc)
            {
            case "top":
                Texture = "Dragon_Gate_top_closed";
                break;

            case "bottom":
                Texture = "Dragon_Gate_bottom_closed";
                break;

            case "left":
                Texture = "Dragon_Gate_left_closed";
                break;

            case "right":
                Texture = "Dragon_Gate_right_closed";
                break;

            default:
                Texture = "Dragon_Gate_top_closed";
                break;
            }
        }
Beispiel #6
0
        /// <summary>
        /// 开关门 信息显示 和记录
        /// </summary>
        private void OnOffDoorInfoRecord(WgDoorType doorOrBox, string strDoorName, DoorsState state, string strOpenType, string strGroup, string strUser, DateTime timeOpen, string strArea)
        {
            EventType eventType = EventType.门禁;

            if (doorOrBox == WgDoorType.门禁)
            {
                if (state == DoorsState.开门)
                {
                    commonCls.NewDoorInOut(state, strOpenType, strDoorName, strGroup, strUser, "");
                }
                else if (state == DoorsState.关门)
                {
                    TimeSpan timeSpan = DateTime.Now - timeOpen;//listWg[iIndex].listDoor[iIndexDoor].TimeOpenDoor;
                    string   strSpan  = clsCommon.CalculateTime(timeSpan);
                    commonCls.NewDoorInOut(state, "", "", "", "", strSpan);
                }
            }
            else if (doorOrBox == WgDoorType.工具柜)
            {
                eventType = EventType.工具柜;
                commonCls.BoxOnOffRecord(strArea, strDoorName, state, strOpenType, strGroup, strUser);
            }
            if (NewEventShowEvent != null)
            {
                NewEventShowEvent(new NewEventEventArgs(eventType, strDoorName, state.ToString(), strUser, strOpenType, DateTime.Now));
            }
        }
Beispiel #7
0
        /// <summary>
        /// 工具柜 开关门 时间
        /// </summary>
        public void BoxOnOffRecord(string strArea, string strName, DoorsState doorState, string strOpenType, string strGroupName, string strOpenDoorPeople)
        {
            string strTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string str     = "insert into tb_RecordBoxDoor (BoxArea,BoxName,OpenOrClose,Time,OpenType,GroupName,UserName) values ('" + strArea + "'," +
                             "'" + strName + "','" + doorState.ToString() + "','" + strTime + "','" + strOpenType + "','" + strGroupName + "','" + strOpenDoorPeople + "')";

            datalogic.SqlComNonQuery(str);
        }
        public void SixIteration_49DoorsAreOpened(int numberOfIterations, int expectedNumberOfOpenedDoors, int expectedNumberOfClosedDoors)
        {
            // arrange
            // act
            DoorsState actual = _hiker.Answer(numberOfIterations);

            // arrange
            Assert.AreEqual(expectedNumberOfOpenedDoors, actual.Opened);
            Assert.AreEqual(expectedNumberOfClosedDoors, actual.Closed);
        }
        public Doors(Vector2 origin, Vector2 c, string type)
        {
            roomMin = origin;
            roomMax = new Vector2(origin.X + 100f, (9f / 16f) * 100f + origin.Y);
            Vector2 roomCenter = (roomMax + roomMin) / 2.0f;

            switch (type)
            {
            case "top":
                // top door
                Center      = new Vector2(roomCenter.X, roomMax.Y - 5.5f);
                Width       = 7f;
                Height      = 2.5f;
                Color       = Color.Brown;
                nextRoom    = new Vector2(c.X, c.Y + 1f);
                heroNextPos = new Vector2(roomCenter.X, roomMax.Y + 6f);
                break;

            case "bottom":
                //bottom door
                Center      = new Vector2(roomCenter.X, roomMin.Y + 1.25f);
                Width       = 7f;
                Height      = 2.5f;
                Color       = Color.Brown;
                nextRoom    = new Vector2(c.X, c.Y - 1f);
                heroNextPos = new Vector2(roomCenter.X, roomMin.Y - 12f);
                break;

            case "left":
                // left door
                Center      = new Vector2(roomMin.X + 1.25f, roomCenter.Y - 2.5f);
                Width       = 2.5f;
                Height      = 7f;
                Color       = Color.Brown;
                nextRoom    = new Vector2(c.X - 1f, c.Y);
                heroNextPos = new Vector2(roomMin.X - 4.5f, Center.Y);
                break;

            case "right":
                // right door
                Center      = new Vector2(roomMax.X - 1.25f, roomCenter.Y - 2.5f);
                Width       = 2.5f;
                Height      = 7f;
                Color       = Color.Brown;
                nextRoom    = new Vector2(c.X + 1f, c.Y);
                heroNextPos = new Vector2(roomMax.X + 4.5f, Center.Y);
                break;

            default:
                break;
            }

            CurrentState = DoorsState.Closed;
        }
Beispiel #10
0
        public void CloseDoors()
        {
            if (State == DoorsState.Close)
            {
                return;
            }

            Timing.KillCoroutines(_AnimationHandle);
            State = DoorsState.InMotion;
            StateChanged?.Invoke(this, EventArgs.Empty);
            _AnimationHandle = Timing.RunCoroutine(AnimateDoors(_LeftDoorStates.x, _RightDoorStates.x, true));
        }
        public Doors(Vector2 origin, Vector2 c, string type)
        {
            roomMin = origin;
            roomMax = new Vector2(origin.X + 100f, (9f / 16f) * 100f + origin.Y);
            Vector2 roomCenter = (roomMax + roomMin) / 2.0f;

            switch (type) {
                case "top":
                    // top door
                    Center = new Vector2(roomCenter.X, roomMax.Y - 5.5f);
                    Width = 7f;
                    Height = 2.5f;

                    nextRoom = new Vector2(c.X, c.Y + 1f);
                    heroNextPos = new Vector2(roomCenter.X, roomMax.Y + 5.5f);
                    Texture = "closed";
                    break;
                case "bottom":
                    //bottom door
                    Center = new Vector2(roomCenter.X, roomMin.Y + 1.25f);
                    Width = 7f;
                    Height = 2.5f;

                    Texture = "closed";
                    nextRoom = new Vector2(c.X, c.Y - 1f);
                    heroNextPos = new Vector2(roomCenter.X, roomMin.Y - 10f);
                    break;
                case "left":
                    // left door
                    Center = new Vector2(roomMin.X +1.25f, roomCenter.Y - 2.5f);
                    Width = 2.5f;
                    Height = 7f;

                    Texture = "closed";
                    nextRoom = new Vector2(c.X - 1f, c.Y);
                    heroNextPos = new Vector2(roomMin.X - 3.75f, Center.Y);
                    break;
                case "right":
                    // right door
                    Center = new Vector2(roomMax.X - 1.25f, roomCenter.Y - 2.5f);
                    Width = 2.5f;
                    Height = 7f;

                    nextRoom = new Vector2(c.X +1f, c.Y);
                    heroNextPos = new Vector2(roomMax.X + 3.75f, Center.Y);
                    Texture = "closed";
                    break;
                default:
                    break;
            }

            CurrentState = DoorsState.Closed;
        }
Beispiel #12
0
        private IEnumerator <float> AnimateDoors(float leftZPos, float rightZPos, bool areClosing)
        {
            while (Math.Abs(_LeftDoor.localPosition.z - leftZPos) > float.Epsilon && Math.Abs(_RightDoor.localPosition.z - rightZPos) > float.Epsilon)
            {
                Vector3 position = _LeftDoor.localPosition;
                position.z = Mathf.MoveTowards(position.z, leftZPos, _AnimationSpeed * Time.deltaTime);
                _LeftDoor.localPosition = position;

                position   = _RightDoor.localPosition;
                position.z = Mathf.MoveTowards(position.z, rightZPos, _AnimationSpeed * Time.deltaTime);
                _RightDoor.localPosition = position;

                yield return(Timing.WaitForOneFrame);
            }

            State = areClosing ? DoorsState.Close : DoorsState.Open;
        }
Beispiel #13
0
        /// <summary>
        /// 门禁进出记录
        /// </summary>
        public void NewDoorInOut(DoorsState inOrOut, string strOpenType, string strPoint, string strGroupName, string strOpenDoorPeople, string strSpan)
        {
            string strSql  = "";
            string strTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            if (inOrOut == DoorsState.开门)
            {
                strSql = "insert into tb_RecordDoorInOut (OpenType,Point,GroupName,UserName,OpenTime,CloseTime,DurationTime)" +
                         "values ('" + strOpenType + "','" + strPoint + "','" + strGroupName + "','" + strOpenDoorPeople + "','" + strTime + "','','')";
            }
            else if (inOrOut == DoorsState.关门)
            {
                strSql = "update tb_RecordDoorInOut set CloseTime='" + strTime + "',DurationTime='" + strSpan + "' where " +
                         "CloseTime='' and DurationTime='' and Point='" + strPoint + "'";
                datalogic.SqlComNonQuery(strSql);
            }
            if (!string.IsNullOrEmpty(strSql))
            {
                datalogic.SqlComNonQuery(strSql);
            }
        }
Beispiel #14
0
        /// <summary>
        /// 获取门的状态 门号
        /// </summary>
        /// <param name="doorNo"></param>
        /// <returns></returns>
        public DoorsState GetDoorState(int doorNo)
        {
            DoorsState state = DoorsState.初值;

            if (wgController.GetMjControllerRunInformationIP() > 0) //取控制器信息
            {
                bool bl = wgController.RunInfo.IsOpen(doorNo);
                if (bl)
                {
                    state = DoorsState.关门;
                }
                else
                {
                    state = DoorsState.开门;
                }
            }
            else
            {
                state = DoorsState.通信;
            }
            return(state);
        }
Beispiel #15
0
 public void getDoorState()
 {
     if (wgMjController != null)
     {
         if (wgMjController.GetMjControllerRunInformationIP() > 0) //取控制器信息
         {
             bool blRet = wgMjController.RunInfo.IsOpen(1);
             if (blRet == false)
             {
                 boxDoorNow = DoorsState.开门;
             }
             else
             {
                 boxDoorNow = DoorsState.关门;
             }
         }
         else
         {
             boxDoorNow = DoorsState.通信;
         }
     }
 }
Beispiel #16
0
    void Update()
    {
        switch (state)
        {
        case DoorsState.Idle:
            break;

        case DoorsState.Opening:
            if (t < 1.0f)
            {
                Vector3 v;
                t += Time.deltaTime * speed;
                float x = Mathf.Lerp(startX, startX + maxX, t);
                if (t < 1.0f)
                {
                    v   = transform.position;
                    v.x = x;
                    transform.position = v;
                }
                else
                {
                    state = DoorsState.Idle;

                    v   = transform.position;
                    v.x = startX + maxX;
                    transform.position = v;

                    if (openTry >= openTryCount)
                    {
                        Finish();
                    }
                }
            }
            break;
        }
    }
 public void openDoor()
 {
     CurrentState = DoorsState.Open;
     Color = Color.White;
 }
Beispiel #18
0
        #pragma warning restore 0649

        #endregion Inspector Variables

        #region Unity Methods

        private void Awake()
        {
            State = DoorsState.Close;
        }
Beispiel #19
0
        private void timer_Execute()
        {
            try
            {
                for (int iIndex = 0; iIndex < listZk.Count; iIndex++)
                {
                    if (listZk[iIndex].BlConnoct == false)
                    {
                        TimeSpan span = DateTime.Now - listZk[iIndex].TimeConnectLast;
                        if (span.TotalMinutes > 2)
                        {
                            bool blRet = ConnectZk(iIndex);
                            if (blRet)
                            {
                                if (listZk[iIndex].StateOfNet != CommuniState.已连接)
                                {
                                    lock (listZk)
                                    {
                                        listZk[iIndex].StateOfNet = CommuniState.已连接;
                                    }
                                    //异常事件
                                    NetErrInfoAndRecord(iIndex, ErrorContent.通信恢复正常.ToString());
                                }
                            }
                            lock (listZk)
                            {
                                listZk[iIndex].TimeConnectLast = DateTime.Now;
                            }
                        }
                    }
                    else
                    {
                        DoorsState state = DoorsState.初值;
                        bool       blRet = listZk[iIndex].GetDoorState(ref state);
                        if (blRet)
                        {
                            if (state != listZk[iIndex].doorInfo.StateOfDoor)
                            {
                                listZk[iIndex].doorInfo.StateOfDoor = state;

                                if (state == DoorsState.关门)
                                {
                                    listZk[iIndex].doorInfo.StrOpenType = "";
                                    listZk[iIndex].doorInfo.StrGroup    = "";
                                    listZk[iIndex].doorInfo.StrUser     = "";
                                }
                                if (listZk[iIndex].doorInfo.IsOfRfid == DeviceUsing.启用)
                                {//確定是哪个门禁关联RFID
                                    if (state == DoorsState.关门)
                                    {
                                        clsRfidRead.strOpenUser = "";
                                    }
                                    else if (state == DoorsState.开门)
                                    {
                                        clsRfidRead.strOpenUser = listZk[iIndex].doorInfo.StrUser;
                                    }
                                }

                                //if (state == DoorsState.关门)
                                //{
                                //    listZk[iIndex].doorInfo.StrOpenType = "";
                                //    listZk[iIndex].doorInfo.StrGroup = "";
                                //    listZk[iIndex].doorInfo.StrUser = "";
                                //    if (listZk[iIndex].doorInfo.IsOfRfid == DeviceUsing.启用)
                                //    {
                                //        clsRfidRead.strOpenUser = "";
                                //    }
                                //}
                                //else if (state == DoorsState.开门 )
                                //{
                                //    if (listZk[iIndex].doorInfo.IsOfRfid == DeviceUsing.启用)
                                //    {
                                //        clsRfidRead.strOpenUser  = listZk[iIndex].doorInfo.StrUser;
                                //    }
                                //}
                                //开关门事件
                                if (NewEventShowEvent != null)
                                {
                                    string strPoint = listZk[iIndex].doorInfo.StrDoorName;
                                    string strType  = "非法开门";
                                    if (!String.IsNullOrEmpty(listZk[iIndex].doorInfo.StrOpenType))
                                    {
                                        strType = listZk[iIndex].doorInfo.StrOpenType;
                                    }
                                    else
                                    {
                                        strType = state.ToString();
                                    }
                                    string strUser  = listZk[iIndex].doorInfo.StrUser;
                                    string StrGroup = listZk[iIndex].doorInfo.StrGroup;
                                    NewEventShowEvent(new NewEventEventArgs(EventType.门禁, strPoint, state.ToString(), strUser, strType, DateTime.Now));
                                    commonCls.NewDoorInOut(state, strType, strPoint, StrGroup, strUser, "");
                                }
                            }
                        }
                        else
                        {
                            if (listZk[iIndex].BlConnoct)
                            {
                                DisConnectZkAndClearEvent(iIndex);
                                if (listZk[iIndex].StateOfNet != CommuniState.已断开)
                                {
                                    lock (listZk)
                                    {
                                        listZk[iIndex].StateOfNet = CommuniState.已断开;
                                    }
                                    //异常事件
                                    NetErrInfoAndRecord(iIndex, ErrorContent.通信异常.ToString());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (frmMain.blDebug)
                {
                    MessageUtil.ShowTips(ex.Message);
                }
            }
        }
Beispiel #20
0
        /// <summary>
        /// 定时读取 门禁控制器状态
        /// </summary>
        private void updateControllerStatus()
        {
            try
            {
                if (watching != null)
                {
                    int iCount = listWg.Count;
                    for (int iIndex = 0; iIndex < iCount; iIndex++)
                    {
                        if (listWg[iIndex] != null)
                        {
                            // 门的类型 大门 或 工具柜门
                            WgDoorType doorOrBox = listWg[iIndex].DoorOrBoxDoor;

                            #region  网络通信 状态 及校时

                            //网络连接错误 30S 后继续连接
                            bool blAgain = false;
                            if (listWg[iIndex].StateOfNet == CommuniState.未连接)
                            {
                                TimeSpan span = DateTime.Now - listWg[iIndex].TimeErrNet;
                                if (span.TotalSeconds > 30)
                                {
                                    blAgain = true;
                                    lock (listWg)
                                    {
                                        listWg[iIndex].TimeErrNet = DateTime.Now;
                                    }
                                }
                            }

                            if (listWg[iIndex].StateOfNet == CommuniState.已连接 || blAgain)
                            {
                                wgMjControllerRunInformation conRunInfo = null;
                                int commStatus;
                                int iSn = (int)listWg[iIndex].IntSn;
                                commStatus = watching.CheckControllerCommStatus(iSn, ref conRunInfo);

                                if (commStatus == -1)
                                {
                                    if (listWg[iIndex].StateOfNet != CommuniState.未连接)
                                    {
                                        lock (listWg)
                                        {
                                            listWg[iIndex].StateOfNet = CommuniState.未连接;
                                            listWg[iIndex].TimeErrNet = DateTime.Now;
                                        }

                                        //通信 异常信息 及记录
                                        NetErrInfoAndRecord(doorOrBox, iIndex, ErrorContent.通信异常.ToString());

                                        #region

                                        //string strErrType = DoorOrBoxDoor.ToString();
                                        //string strWgName = "";//微耕控制器名称
                                        //if (DoorOrBoxDoor == EventType.工具柜)
                                        //{
                                        //    strWgName = listWg[iIndex].StrNameOfWg;
                                        //}
                                        //string strContent = ErrorContent.通信异常.ToString();
                                        ////异常记录
                                        //commonCls.NewErrRecord(strErrType, strWgName, strContent, "");
                                        //if (NewAlarmShowEvent != null)
                                        //{
                                        //    NewAlarmShowEvent(new NewEventEventArgs(DoorOrBoxDoor, strWgName, strContent, "", "", DateTime.Now));
                                        //}

                                        #endregion
                                    }
                                }
                                else if (commStatus == 1)
                                {
                                    if (listWg[iIndex].StateOfNet != CommuniState.已连接)
                                    {
                                        lock (listWg)
                                        {
                                            listWg[iIndex].StateOfNet = CommuniState.已连接;
                                        }

                                        //通信恢复 正常 记录及主界面显示
                                        NetErrInfoAndRecord(doorOrBox, iIndex, ErrorContent.通信恢复正常.ToString());

                                        #region  通信恢复 正常 记录及主界面显示

                                        //string strErrType = DoorOrBoxDoor.ToString();
                                        //string strWgName = "";//微耕控制器名称
                                        //if (DoorOrBoxDoor == EventType.工具柜)
                                        //{
                                        //    strWgName = listWg[iIndex].StrNameOfWg;
                                        //}
                                        //string strContent = ErrorContent.通信恢复正常.ToString();
                                        //commonCls.NewErrRecord(strErrType, strWgName, strContent, "");
                                        //if (NewAlarmShowEvent != null)
                                        //{
                                        //    NewAlarmShowEvent(new NewEventEventArgs(DoorOrBoxDoor, strWgName, strContent, "", "", DateTime.Now));
                                        //}

                                        #endregion

                                        #region  校时

                                        DateTime time = conRunInfo.dtNow;
                                        TimeSpan ts   = DateTime.Now - time;//记录历史温湿度数据间隔
                                        if (ts.TotalSeconds >= 59 || ts.TotalSeconds <= -59)
                                        {
                                            wgController.AdjustTimeIP(DateTime.Now);
                                        }

                                        #endregion
                                    }
                                }
                            }

                            #endregion

                            #region  门状态

                            if (listWg[iIndex].StateOfNet == CommuniState.已连接)
                            {
                                if (listWg[iIndex].listDoor != null)
                                {
                                    string strArea    = listWg[iIndex].StrArea;
                                    int    iCountDoor = listWg[iIndex].listDoor.Count;
                                    for (int iIndexDoor = 0; iIndexDoor < iCountDoor; iIndexDoor++)
                                    {
                                        //门名称
                                        string strDoorName = "";
                                        if (listWg[iIndex].listDoor[iIndexDoor].StrDoorName != null)
                                        {
                                            strDoorName = listWg[iIndex].listDoor[iIndexDoor].StrDoorName;
                                        }

                                        int        iDoorIndex   = listWg[iIndex].listDoor[iIndexDoor].IntDoorIndex;
                                        DoorsState getDoorState = listWg[iIndex].GetDoorState(iDoorIndex);
                                        if (listWg[iIndex].listDoor[iIndexDoor].StateOfDoor != getDoorState)
                                        {
                                            lock (listWg)
                                            {
                                                listWg[iIndex].listDoor[iIndexDoor].StateOfDoor = getDoorState;
                                            }
                                            if (getDoorState == DoorsState.开门)
                                            {
                                                lock (listWg)
                                                {
                                                    listWg[iIndex].listDoor[iIndexDoor].TimeOpenDoor = DateTime.Now;
                                                }
                                                if (listWg[iIndex].listDoor[iIndexDoor].IsOfRfid == DeviceUsing.启用)
                                                {
                                                    clsRfidRead.strOpenUser = listWg[iIndex].listDoor[iIndexDoor].StrUser;
                                                }
                                                //开门
                                                string strOpenType = listWg[iIndex].listDoor[iIndexDoor].StrOpenType;
                                                string strGroup    = listWg[iIndex].listDoor[iIndexDoor].StrGroup;
                                                string strUser     = listWg[iIndex].listDoor[iIndexDoor].StrUser;
                                                OnOffDoorInfoRecord(doorOrBox, strDoorName, DoorsState.开门, strOpenType, strGroup, strUser, DateTime.Now, strArea);

                                                #region
                                                //string strOpenType = listWg[iIndex].listDoor[iIndexDoor].StrOpenType;
                                                //string strGroup = listWg[iIndex].listDoor[iIndexDoor].StrGroup;
                                                //string strUser = listWg[iIndex].listDoor[iIndexDoor].StrUser;
                                                //if (DoorOrBoxDoor == EventType.门禁)
                                                //{
                                                //    commonCls.NewDoorInOut(DoorsState.开门, strOpenType, strDoorName, strGroup, strUser, "");
                                                //}
                                                //else if (DoorOrBoxDoor == EventType.工具柜)
                                                //{

                                                //}
                                                //if (NewEventShowEvent != null)
                                                //{
                                                //    NewEventShowEvent(new NewEventEventArgs(DoorOrBoxDoor, strDoorName, DoorsState.开门.ToString(), strUser, strOpenType, DateTime.Now));
                                                //}
                                                #endregion
                                            }
                                            else if (getDoorState == DoorsState.关门)
                                            {
                                                lock (listWg)
                                                {
                                                    listWg[iIndex].listDoor[iIndexDoor].ClearOpenInfo();
                                                }
                                                if (listWg[iIndex].listDoor[iIndexDoor].IsOfRfid == DeviceUsing.启用)
                                                {
                                                    clsRfidRead.strOpenUser = "";
                                                }
                                                //关门
                                                DateTime timeOpen = listWg[iIndex].listDoor[iIndexDoor].TimeOpenDoor;
                                                OnOffDoorInfoRecord(doorOrBox, strDoorName, DoorsState.关门, "", "", "", timeOpen, strArea);

                                                #region

                                                //TimeSpan timeSpan = DateTime.Now - listWg[iIndex].listDoor[iIndexDoor].TimeOpenDoor;
                                                //string strSpan = clsCommon.CalculateTime(timeSpan);
                                                //if (DoorOrBoxDoor == EventType.门禁)
                                                //{
                                                //    commonCls.NewDoorInOut(DoorsState.关门, "", "", "", "", strSpan);
                                                //}
                                                //else if (DoorOrBoxDoor == EventType.工具柜)
                                                //{

                                                //}
                                                //if (NewEventShowEvent != null)
                                                //{
                                                //    NewEventShowEvent(new NewEventEventArgs(DoorOrBoxDoor, strDoorName, DoorsState.开门.ToString(), "", "", DateTime.Now));
                                                //}

                                                #endregion
                                            }
                                        }
                                    }
                                }
                            }

                            #endregion
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (frmMain.blDebug)
                {
                    MessageUtil.ShowTips(ex.Message);
                }
            }
        }
Beispiel #21
0
        public void openDoor(string loc)
        {
            CurrentState = DoorsState.Open;

            switch (loc)
            {
                case "top":
                    Texture = "Dragon_Gate_top_open";
                    break;
                case "bottom":
                    Texture = "Dragon_Gate_bottom_open";
                    break;
                case "left":
                    Texture = "Dragon_Gate_left_open";
                    break;
                case "right":
                    Texture = "Dragon_Gate_right_open";
                    break;
                default:
                    Texture = "Dragon_Gate_top_open";
                    break;
            }
        }
Beispiel #22
0
 public void closedDoor(string loc)
 {
     CurrentState = DoorsState.Closed;
     switch (loc)
     {
         case "top":
             Texture = "Dragon_Gate_top_closed";
             break;
         case "bottom":
             Texture = "Dragon_Gate_bottom_closed";
             break;
         case "left":
             Texture = "Dragon_Gate_left_closed";
             break;
         case "right":
             Texture = "Dragon_Gate_right_closed";
             break;
         default:
             Texture = "Dragon_Gate_top_closed";
             break;
     }
 }
Beispiel #23
0
 public void closedDoor()
 {
     CurrentState = DoorsState.Closed;
     Texture      = "closed";
 }
 public void closedDoor()
 {
     CurrentState = DoorsState.Closed;
     Texture = "closed";
 }
 public void openDoor()
 {
     CurrentState = DoorsState.Open;
     Texture = "open";
 }
Beispiel #26
0
        /// <summary>
        /// 工具柜 状态及 记录
        /// </summary>
        /// <param name="iIndex"></param>
        /// <param name="doorState"></param>
        private void DoorStateRecord(int iIndex)
        {
            DoorsState doorState = doorState = listWg[iIndex].GetDoorState(1);

            if (doorState == DoorsState.开门 || doorState == DoorsState.关门)
            {
                string   strArea           = listWg[iIndex].StrArea;
                string   strName           = listWg[iIndex].StrBoxName;
                string   strOpenType       = "";
                string   strTime           = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string   strOpenDoorPeople = "";
                string   strGroupName      = "";
                DateTime timeOpen          = DateTime.Now;

                if (listWg[iIndex].BoxDoorState != doorState)
                {
                    lock (listWg)
                    {
                        listWg[iIndex].BoxDoorState = doorState;
                    }

                    if (doorState == DoorsState.开门)
                    {
                        //开门类型
                        strOpenType = listWg[iIndex].StrOpenTypeDoor;
                        if (strOpenType == OpenDoorType.刷卡.ToString())
                        {
                            strGroupName      = listWg[iIndex].StrOpenGroup;
                            strOpenDoorPeople = listWg[iIndex].StrOpenName;
                        }

                        #region

                        //#region 关闭RFID扫描

                        //string strHasRfid = listWg[iIndex].StrHasRfid;
                        //if (strHasRfid == DeviceUsing.启用.ToString())
                        //{
                        //    string strMain = listWg[iIndex].StrRfidMain;
                        //    string StrChildId = listWg[iIndex].StrChildId;
                        //    for (int iIndexRfid = 0; iIndexRfid < MainControl.listBoxRfid.Count; iIndexRfid++)
                        //    {

                        //        if (strMain == BoxRfidMain.主机.ToString())
                        //        {
                        //            if (MainControl.listBoxRfid[iIndexRfid].StrChildIdMain == StrChildId)
                        //            {
                        //                if (MainControl.listBoxRfid[iIndexRfid].StateMainRead != BoxRfidState.不读)
                        //                {
                        //                    lock (MainControl.listBoxRfid)
                        //                    {
                        //                        MainControl.listBoxRfid[iIndexRfid].StateMainRead = BoxRfidState.不读;
                        //                    }
                        //                }
                        //                break;
                        //            }
                        //        }
                        //        else if (strMain == BoxRfidMain.从机.ToString())
                        //        {
                        //            if (MainControl.listBoxRfid[iIndexRfid].StrChildIdSlave == StrChildId)
                        //            {
                        //                if (MainControl.listBoxRfid[iIndexRfid].StateSlaveRead != BoxRfidState.不读)
                        //                {
                        //                    lock (MainControl.listBoxRfid)
                        //                    {
                        //                        MainControl.listBoxRfid[iIndexRfid].StateSlaveRead = BoxRfidState.不读;
                        //                    }
                        //                }
                        //                break;
                        //            }
                        //        }
                        //    }
                        //}

                        //#endregion

                        #endregion
                    }
                    else if (doorState == DoorsState.关门)
                    {
                        lock (listWg)
                        {
                            listWg[iIndex].StrOpenTypeDoor = "";
                            listWg[iIndex].StrOpenGroup    = "";
                            listWg[iIndex].StrOpenName     = "";
                        }

                        #region

                        #region

                        //#region RFID扫描

                        //string strHasRfid = listWg[iIndex].StrHasRfid;
                        //if (strHasRfid == DeviceUsing.启用.ToString())
                        //{
                        //    string strMain = listWg[iIndex].StrRfidMain;
                        //    string StrChildId = listWg[iIndex].StrChildId;
                        //    for (int iIndexRfid = 0; iIndexRfid < MainControl.listBoxRfid.Count; iIndexRfid++)
                        //    {
                        //        if (strMain == BoxRfidMain.主机.ToString())
                        //        {
                        //            if (MainControl.listBoxRfid[iIndexRfid].StrChildIdMain == StrChildId)
                        //            {
                        //                //从机 有没读标签
                        //                if (MainControl.listBoxRfid[iIndexRfid].StateSlaveRead == BoxRfidState.不读)
                        //                {
                        //                    lock (MainControl.listBoxRfid)
                        //                    {
                        //                        MainControl.listBoxRfid[iIndexRfid].StateMainRead = BoxRfidState.读标签;
                        //                        MainControl.listBoxRfid[iIndexRfid].TimeMainStart = DateTime.Now;
                        //                    }
                        //                }
                        //                else
                        //                {
                        //                    if (MainControl.listBoxRfid[iIndexRfid].StateMainRead != BoxRfidState.等待读)
                        //                    {
                        //                        lock (MainControl.listBoxRfid)
                        //                        {
                        //                            MainControl.listBoxRfid[iIndexRfid].StateMainRead = BoxRfidState.等待读;
                        //                        }
                        //                    }
                        //                }
                        //                if (MainControl.listBoxRfid[iIndexRfid].timerRfidFast.State != TimerState.Running)
                        //                    MainControl.listBoxRfid[iIndexRfid].StatrRead();

                        //                break;
                        //            }
                        //        }
                        //        else if (strMain == BoxRfidMain.从机.ToString())
                        //        {
                        //            if (MainControl.listBoxRfid[iIndexRfid].StrChildIdSlave == StrChildId)
                        //            {
                        //                //主机 有没读标签
                        //                if (MainControl.listBoxRfid[iIndexRfid].StateMainRead == BoxRfidState.不读)
                        //                {
                        //                    lock (MainControl.listBoxRfid)
                        //                    {
                        //                        MainControl.listBoxRfid[iIndexRfid].StateSlaveRead = BoxRfidState.读标签;
                        //                        MainControl.listBoxRfid[iIndexRfid].TimeSlaveStart = DateTime.Now;
                        //                    }
                        //                }
                        //                else
                        //                {
                        //                    if (MainControl.listBoxRfid[iIndexRfid].StateSlaveRead != BoxRfidState.等待读)
                        //                    {
                        //                        lock (MainControl.listBoxRfid)
                        //                        {
                        //                            MainControl.listBoxRfid[iIndexRfid].StateSlaveRead = BoxRfidState.等待读;
                        //                        }
                        //                    }
                        //                }
                        //                if (MainControl.listBoxRfid[iIndexRfid].timerRfidFast.State != TimerState.Running)
                        //                    MainControl.listBoxRfid[iIndexRfid].StatrRead();
                        //                break;
                        //            }
                        //        }


                        //        //if (strMain == BoxRfidMain.主机.ToString())
                        //        //{
                        //        //    if (MainControl.listBoxRfid[iIndexRfid].StrChildIdMain == StrChildId)
                        //        //    {
                        //        //        if (MainControl.listBoxRfid[iIndexRfid].BlMainRead == false)
                        //        //        {
                        //        //            lock (MainControl.listBoxRfid)
                        //        //            {
                        //        //                MainControl.listBoxRfid[iIndexRfid].BlMainRead = true;
                        //        //            }
                        //        //        }
                        //        //        if (MainControl.listBoxRfid[iIndexRfid].timerRfidFast.State != TimerState.Running)
                        //        //            MainControl.listBoxRfid[iIndexRfid].StatrRead();
                        //        //        break;
                        //        //    }
                        //        //}
                        //        //else if (strMain == BoxRfidMain.从机.ToString())
                        //        //{
                        //        //    if (MainControl.listBoxRfid[iIndexRfid].StrChildIdSlave == StrChildId)
                        //        //    {
                        //        //        if (MainControl.listBoxRfid[iIndexRfid].BlSlaveRead == false)
                        //        //        {
                        //        //            lock (MainControl.listBoxRfid)
                        //        //            {
                        //        //                MainControl.listBoxRfid[iIndexRfid].BlSlaveRead = true;
                        //        //            }
                        //        //        }
                        //        //        if (MainControl.listBoxRfid[iIndexRfid].timerRfidFast.State != TimerState.Running)
                        //        //            MainControl.listBoxRfid[iIndexRfid].StatrRead();
                        //        //        break;
                        //        //    }
                        //        //}
                        //    }
                        //}

                        //#endregion

                        #endregion

                        #endregion
                    }


                    lock (MainControl.dtNewEvent)//Type ToolID Content People Time No IsClick
                    {
                        DataRow dr = MainControl.dtNewEvent.NewRow();
                        dr["Type"]  = EventType.工具柜.ToString();
                        dr["Point"] = strName;
                        if (strOpenType == OpenDoorType.超级密码开门.ToString())
                        {
                            dr["Content"] = OpenDoorType.密码.ToString();
                            strOpenType   = OpenDoorType.密码.ToString();
                        }
                        else
                        {
                            dr["Content"] = doorState.ToString();
                        }
                        dr["People"] = strOpenDoorPeople;
                        dr["Time"]   = strTime;
                        MainControl.dtNewEvent.Rows.Add(dr);
                    }
                    string str = "insert into tb_RecordBoxDoor (BoxArea,BoxName,OpenOrClose,Time,OpenType,GroupName,UserName) values ('" + strArea + "'," +
                                 "'" + strName + "','" + doorState.ToString() + "','" + strTime + "','" + strOpenType + "','" + strGroupName + "','" + strOpenDoorPeople + "')";
                    datalogic.SqlComNonQuery(str);
                }
            }
        }
 public void openDoor()
 {
     CurrentState = DoorsState.Open;
     Color        = Color.White;
 }
Beispiel #28
0
        public void ReadRunState(ref int iCardIndex, ref int iCardCountLast, ref string sCardNo, ref DoorsState doorState, bool blAdd)
        {
            bSendDoor[1] = MainControl.bDoorAddrL;
            bSendDoor[2] = MainControl.bDoorAddrH;
            bSendDoor[3] = 0x81;
            bSendDoor[4] = 0x10;
            bSendDoor[5] = (byte)(iCardIndex & 0xff);
            bSendDoor[6] = (byte)((iCardIndex >> 8) & 0xff);
            bSendDoor[7] = (byte)((iCardIndex >> 16) & 0xff);
            bSendDoor[8] = (byte)((iCardIndex >> 24) & 0xff);
            for (int i = 9; i < 31; i++)
            {
                bSendDoor[i] = 0;
            }
            int iCheckSun = 0;

            for (int i = 1; i < 31; i++)
            {
                iCheckSun += bSendDoor[i];
            }
            bSendDoor[31] = (byte)(iCheckSun & 0x00ff);
            bSendDoor[32] = (byte)(iCheckSun >> 8);

            //txt 发送
            string strContent = SerialPortUtil.ByteToHex(bSendDoor);

            txtLog.WriteTxt("Door.txt", "State Send", strContent, false);

            byte[] bRece   = new byte[34];
            int    iLength = doorSerial.SendReceByte(bSendDoor, ref bRece, 500);

            //txt 接受
            if (iLength > 0)
            {
                strContent = SerialPortUtil.ByteToHex(bRece);
                txtLog.WriteTxt("Door.txt", "State Rece", strContent, true);//01 01 01 0F 11 8C
            }

            #region  接受 读运行状态

            if (iLength == 34)
            {
                iCheckSun = 0;
                for (int i = 1; i < 31; i++)
                {
                    iCheckSun += bRece[i];
                }
                byte bL = (byte)(iCheckSun & 0x00ff);
                byte bH = (byte)(iCheckSun >> 8);
                if (bRece[0] == 0x7E && bRece[1] == MainControl.bDoorAddrL && bRece[2] == MainControl.bDoorAddrH && bRece[3] == 0x81 && bRece[4] == 0x10 &&
                    bRece[31] == bL && bRece[32] == bH && bRece[33] == 0x0D)
                {
                    JudgeDatetime(bRece);
                    // 刷卡数
                    int iCardCount = bRece[12];
                    int i          = bRece[13];
                    i          *= 256;
                    iCardCount += i;
                    i           = bRece[14];
                    i          *= 65536;
                    iCardCount += i;
                    if (iCardIndex == 0 && iCardCountLast == 0)
                    {
                        //第一次运行
                        iCardCountLast = iCardCount;
                        iCardIndex     = iCardCount;
                        iCardIndex++;
                    }
                    else
                    {
                        if (iCardCount > iCardCountLast)
                        {
                            //卡号
                            iCardCountLast = iCardCount;
                            iCardIndex     = iCardCount;
                            iCardIndex++;
                            string str       = bRece[19].ToString();
                            string strCardNo = IcCardFormat(3, str);
                            i          = bRece[18];
                            i         *= 256;
                            i         += bRece[17];
                            str        = i.ToString();
                            str        = IcCardFormat(5, str);
                            strCardNo += str;
                            //记录状态
                            byte bRecordState = bRece[20];
                            if (blAdd)// blAdd  为添加用户时
                            {
                                sCardNo = strCardNo;
                            }
                            else
                            {
                                if (bRecordState == 0x00 || bRecordState == 0x01)//有效IC卡
                                {
                                    sCardNo = strCardNo;
                                }
                            }
                        }
                    }

                    //        //门磁状态
                    byte bMc = bRece[26];
                    if ((bMc & 0x10) == 0x00)
                    {
                        doorState = DoorsState.开门;
                    }
                    else
                    {
                        doorState = DoorsState.关门;
                    }
                }
            }

            #endregion
        }
		public void openDoor() {
			CurrentState = DoorsState.Open;
            Texture = "open";
		}
Beispiel #30
0
        /// <summary>
        /// 大门 状态及 记录
        /// </summary>
        /// <param name="iIndex"></param>
        /// <param name="doorState"></param>
        private void BigDoorStateRecord(int iIndex, DoorNo doorNo)
        {
            DoorsState doorState = DoorsState.初值;

            if (doorNo == DoorNo.门1)
            {
                doorState = listWg[iIndex].GetDoorState(1);
            }
            else if (doorNo == DoorNo.门2)
            {
                doorState = listWg[iIndex].GetDoorState(2);
            }
            if (doorState == DoorsState.开门 || doorState == DoorsState.关门)
            {
                bool     blRecord          = false;
                string   strPoint          = "";
                string   strOpenType       = "";
                string   strTime           = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string   strOpenDoorPeople = "";
                string   strGroupName      = "";
                DateTime timeOpen          = DateTime.Now;

                #region 门 状态

                if (doorNo == DoorNo.门1)
                {
                    if (listWg[iIndex].DoorState1 != doorState)
                    {
                        blRecord = true;
                    }
                    if (blRecord)
                    {
                        lock (listWg)
                        {
                            listWg[iIndex].DoorState1 = doorState;
                        }

                        if (doorState == DoorsState.开门)
                        {
                            //开门类型
                            strOpenType = listWg[iIndex].StrOpenTypeDoor1;
                            if (listWg[iIndex].WgDoorCount == DoorCount.双门)
                            {
                                strPoint = listWg[iIndex].StrNameDoor1;
                            }
                            else
                            {
                                strPoint = "";
                            }
                            if (strOpenType == OpenDoorType.刷卡.ToString())
                            {
                                strGroupName      = listWg[iIndex].StrOpenGroup1;
                                strOpenDoorPeople = listWg[iIndex].StrOpenName1;
                            }

                            lock (listWg)
                            {
                                listWg[iIndex].TimeOpenDoor1 = DateTime.Now;
                            }
                        }
                        else if (doorState == DoorsState.关门)
                        {
                            lock (listWg)
                            {
                                timeOpen = listWg[iIndex].TimeOpenDoor1;
                                listWg[iIndex].StrOpenTypeDoor1 = "";
                                listWg[iIndex].StrOpenGroup1    = "";
                                listWg[iIndex].StrOpenName1     = "";
                            }
                        }
                    }
                }
                else if (doorNo == DoorNo.门2)
                {
                    if (listWg[iIndex].DoorState2 != doorState)
                    {
                        blRecord = true;
                    }
                    if (blRecord)
                    {
                        lock (listWg)
                        {
                            listWg[iIndex].DoorState2 = doorState;
                        }
                        if (doorState == DoorsState.开门)
                        {
                            strOpenType = listWg[iIndex].StrOpenTypeDoor2;
                            strPoint    = listWg[iIndex].StrNameDoor2;
                            if (strOpenType == OpenDoorType.刷卡.ToString())
                            {
                                strGroupName      = listWg[iIndex].StrOpenGroup2;
                                strOpenDoorPeople = listWg[iIndex].StrOpenName2;
                            }
                            lock (listWg)
                            {
                                listWg[iIndex].TimeOpenDoor2 = DateTime.Now;
                            }
                        }
                        else if (doorState == DoorsState.关门)
                        {
                            lock (listWg)
                            {
                                timeOpen = listWg[iIndex].TimeOpenDoor2;
                                listWg[iIndex].StrOpenTypeDoor2 = "";
                                listWg[iIndex].StrOpenGroup2    = "";
                                listWg[iIndex].StrOpenName2     = "";
                            }
                        }
                    }
                }

                #endregion

                #region 产生记录

                if (blRecord)
                {
                    lock (MainControl.dtNewEvent)//Type ToolID Content People Time No IsClick
                    {
                        DataRow dr = MainControl.dtNewEvent.NewRow();
                        dr["Type"]  = EventType.门禁.ToString();
                        dr["Point"] = strPoint;
                        if (strOpenType == OpenDoorType.超级密码开门.ToString())
                        {
                            dr["Content"] = OpenDoorType.密码.ToString();
                            strOpenType   = OpenDoorType.密码.ToString();
                        }
                        else
                        {
                            dr["Content"] = doorState.ToString();
                        }

                        dr["People"] = strOpenDoorPeople;
                        dr["Time"]   = strTime;
                        MainControl.dtNewEvent.Rows.Add(dr);
                    }

                    if (doorState == DoorsState.开门)
                    {
                        MainControl.blVoiceOpenDoor = true;
                        MainControl.timeLastVoice   = DateTime.Now;

                        string str = "insert into tb_RecordDoorInOut (OpenType,Point,GroupName,UserName,OpenTime,CloseTime,DurationTime)" +
                                     "values ('" + strOpenType + "','" + strPoint + "','" + strGroupName + "','" + strOpenDoorPeople + "','" + strTime + "','','')";
                        datalogic.SqlComNonQuery(str);
                    }
                    else if (doorState == DoorsState.关门)
                    {
                        TimeSpan timeSpan    = DateTime.Now - timeOpen;
                        string   strDuration = clsCommon.CalculateTime(timeSpan);
                        string   strSql      = "update tb_RecordDoorInOut set CloseTime='" + strTime + "',DurationTime='" + strDuration + "' where " +
                                               "CloseTime='' and DurationTime='' and Point='" + strPoint + "'";
                        datalogic.SqlComNonQuery(strSql);
                    }
                }

                #endregion
            }
        }