Beispiel #1
0
        private void lockUdp_GetStringArgs(Udp sender, ReciveString reciveArgs)
        {
            string value = reciveArgs.Value;

            string[] buff = value.Split(new string[] { "~~~" }, StringSplitOptions.None);

            LockMain <T> .GetStatueList statue = (LockMain <T> .GetStatueList)Num.ToInt(buff[0]);
            switch (statue)
            {
            case LockMain <T> .GetStatueList.收到请求:
                nowStatueList = SetStatueList.请求;
                getRemotValue = true;
                break;

            case LockMain <T> .GetStatueList.等待:
                SetRemotInfo(statue, "远程主机已收到请求,请等待分配执行");
                break;

            case LockMain <T> .GetStatueList.允许执行互锁要求:
                SetRemotInfo(statue, "远程主机已允许执行互锁前的开关切换");
                isPlease = false;
                switch (nowStatueList)
                {
                case SetStatueList.请求:
                    if (SwitchOpen != null)
                    {
                        SwitchOpen();
                    }
                    nowStatueList = SetStatueList.执行要求完毕;
                    break;
                }
                break;

            case LockMain <T> .GetStatueList.正在执行互锁动作:

                SetRemotInfo(statue, "远程主机正在执行互锁动作");
                if (buff.Length > 1)
                {
                    if (GetRemotHostTestingValue != null)
                    {
                        GetRemotHostTestingValue(buff[1]);
                    }
                }
                break;

            case LockMain <T> .GetStatueList.互锁动作执行完毕:
                if (isStart)
                {
                    isStart = false;
                    SetRemotInfo(statue, "远程操作完成");
                    if (GetRemotHostTestValue != null)
                    {
                        GetRemotHostTestValue(buff[1]);
                    }
                    if (SwitchClose != null)
                    {
                        SwitchClose();
                    }
                }
                break;

            case LockMain <T> .GetStatueList.互锁请求正常结束:
                SetRemotInfo(statue, "远程主机已收到请求,互锁请求正常结束");
                nowStatueList = SetStatueList.除;
                isStop        = false;
                isPlease      = false;
                isStart       = false;
                break;

            case LockMain <T> .GetStatueList.除请求成功:
                SetRemotInfo(statue, "远程主机已收到请求,互锁请求已删除");
                nowStatueList = SetStatueList.除;
                isDel         = false;
                isPlease      = false;
                isStart       = false;
                isStop        = false;
                break;
            }
        }
Beispiel #2
0
        private void lockUpd_GetStringArgs(Udp sender, ReciveString reciveArgs)
        {
            string value = reciveArgs.Value;

            string[] buff  = value.Split(new string[] { "~~~" }, StringSplitOptions.None);
            T        index = (T)(Object)(buff[0]);

            LockClient <T> .SetStatueList statue = (LockClient <T> .SetStatueList)Num.ToInt(buff[1]);
            switch (statue)
            {
            case LockClient <T> .SetStatueList.连接测试:
                lockUdp.Write(string.Format("{0}", (int)GetStatueList.收到请求), reciveArgs.RemoteHost, reciveArgs.RemotePort);
                break;

            case LockClient <T> .SetStatueList.请求:
                if (!lockList.Contains(index))
                {
                    lockList.Add(index);
                }
                if (lockList.Count > 0)
                {
                    if ((string)(object)lockList[0] == (string)(object)index)
                    {
                        lockUdp.Write(string.Format("{0}", (int)GetStatueList.允许执行互锁要求), reciveArgs.RemoteHost, reciveArgs.RemotePort);
                    }
                    else
                    {
                        lockUdp.Write(string.Format("{0}", (int)GetStatueList.等待), reciveArgs.RemoteHost, reciveArgs.RemotePort);
                    }
                }
                else
                {
                    Error.Add("有添加的请求,但数组列为0", Environment.StackTrace);
                }
                break;

            case LockClient <T> .SetStatueList.执行要求完毕:
                if (lockList.Count > 0)
                {
                    if ((string)(object)lockList[0] != (string)(object)index)
                    {
                        Error.Add(string.Format("动作完成的工位和允许执行的工位不是同一个,大问题。允许工位为:{0},执行工位为:{1}", lockList[0], index), Environment.StackTrace);
                        return;
                    }
                    switch (nowStatueList)
                    {
                    case GetStatueList.收到请求:
                        if (AllTestNeedOk != null)
                        {
                            AllTestNeedOk();
                        }
                        nowStatueList = GetStatueList.正在执行互锁动作;
                        lockUdp.Write(string.Format("{0}", (int)GetStatueList.正在执行互锁动作), reciveArgs.RemoteHost, reciveArgs.RemotePort);
                        break;

                    case GetStatueList.正在执行互锁动作:
                        lockUdp.Write(string.Format("{0}~~~{1}", (int)GetStatueList.正在执行互锁动作, testingValue), reciveArgs.RemoteHost, reciveArgs.RemotePort);
                        break;

                    case GetStatueList.互锁动作执行完毕:
                        lockUdp.Write(string.Format("{0}~~~{1}", (int)GetStatueList.互锁动作执行完毕, testValue), reciveArgs.RemoteHost, reciveArgs.RemotePort);
                        break;
                    }
                }
                else
                {
                    Error.Add("有返回执行的工位请求,但数组列为0", Environment.StackTrace);
                }
                break;

            case LockClient <T> .SetStatueList.动作完毕取消请求:
                lockUdp.Write(string.Format("{0}", (int)GetStatueList.互锁请求正常结束), reciveArgs.RemoteHost, reciveArgs.RemotePort);
                if (lockList.Count > 0)
                {
                    if ((string)(object)lockList[0] == (string)(object)index)
                    {
                        nowStatueList = GetStatueList.收到请求;
                        testValue     = "";
                        testingValue  = "";
                        lockList.Remove(index);
                    }
                    else
                    {
                        Error.Add(string.Format("动作完成的工位和完成请求的工位不是同一个,大问题。允许工位为:{0},执行完成工位为:{1}", lockList[0], index), Environment.StackTrace);
                        return;
                    }
                }
                else
                {
                    Error.Add("有返回完毕的工位请求,但数组列为0", Environment.StackTrace);
                }
                break;

            case LockClient <T> .SetStatueList.除:

                if (lockList.Count > 0)
                {
                    if ((string)(object)lockList[0] == (string)(object)index)
                    {
                        nowStatueList = GetStatueList.收到请求;
                        testValue     = "";
                        testingValue  = "";
                        if (AllTestCancel != null)
                        {
                            AllTestCancel();
                        }
                    }
                }
                if (lockList.Contains(index))
                {
                    lockList.Remove(index);
                }
                lockUdp.Write(string.Format("{0}", (int)GetStatueList.除请求成功), reciveArgs.RemoteHost, reciveArgs.RemotePort);
                break;
            }
        }