Exemplo n.º 1
0
        public void SetControlMessage(TransmissionCotrolFunction fun)
        {
            switch (fun)
            {
            case TransmissionCotrolFunction.StartDataTransmission:
            {
                apci.ControlDomain1 = (1 << 2) | 0x03;

                break;
            }

            case TransmissionCotrolFunction.StopDataTransmission:
            {
                apci.ControlDomain1 = (1 << 4) | 0x03;

                break;
            }

            case TransmissionCotrolFunction.TestFrame:
            {
                apci.ControlDomain1 = (1 << 6) | 0x03;

                break;
            }

            case TransmissionCotrolFunction.AcknowledgementStartDataTransmission:
            {
                apci.ControlDomain1 = (1 << 3) | 0x03;

                break;
            }

            case TransmissionCotrolFunction.AcknowledgementStopDataTransmission:
            {
                apci.ControlDomain1 = (1 << 5) | 0x03;

                break;
            }

            case TransmissionCotrolFunction.AcknowledgementTestFrame:
            {
                apci.ControlDomain1 = (1 << 7) | 0x03;;

                break;
            }

            default:
            {
                throw new Exception("TransmissionCotrolFunction功能选择项不正确");
            }
            }
            apci.ControlDomain2        = 0;
            apci.ControlDomain3        = 0;
            apci.ControlDomain4        = 0;
            transmissionCotrolFunction = fun;
        }
Exemplo n.º 2
0
 /// <summary>
 /// 查找是否包含指定typeID的类型EventProperty,若有则返回。
 /// </summary>
 /// <param name="typeID">类型ID</param>
 /// <returns>EventProperty</returns>
 public EventProperty <TransmissionCotrolFunction> GetEventProcess(TransmissionCotrolFunction typeID)
 {
     try
     {
         return(eventList.Find(x => x.TypeID == typeID));
     }
     catch (ArgumentNullException)
     {
         return(null);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 发送传输控制指令
        /// </summary>
        /// <param name="tcf">传输控制功能</param>
        private void SendTCFCommand(TransmissionCotrolFunction tcf)
        {
            try
            {
                eventTransmissionManager.AddEventProcess(new EventProperty <TransmissionCotrolFunction>(tcf));
                var apciU = new APCITypeU(tcf);

                TCFProcess(apciU.GetAPCIDataArray(), (byte)apciU.GetAPCIDataArray().Length, 5000, tcf);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "SendTCFCommand");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 传输控制功能TCF, 消息处理未完成后处理
        /// </summary>
        /// <param name="n"></param>
        private void MeeageProcessNoCompleted(TransmissionCotrolFunction tcf)
        {
            Action <string> myDelegate = UpdateReciveTxt;

            Dispatcher.BeginInvoke(myDelegate, "应答失败\n");
            switch (tcf)
            {
            case TransmissionCotrolFunction.StartDataTransmission:
            {
                break;
            }

            default:
            {
                break;
            }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// TCF 处理流程
        /// </summary>
        /// <param name="data">消息帧转化后,发送的字节数组</param>
        /// <param name="len">发送的数据长度</param>
        /// <param name="ms">超时时间,单位ms</param>
        /// <param name="EventTCF eventTCF">事件控制帧</param>
        private bool TCFProcess(byte[] data, byte len, int ms, TransmissionCotrolFunction tcf)
        {
            if (data.Length < len)
            {
                return(false);
            }

            var mStartEvent = eventTransmissionManager.GetEventProcess(tcf);
            var process     = new ProcessControl <byte[], TransmissionCotrolFunction, TransmissionCotrolFunction>(data, tcf, tcf, StartMessageProcess,
                                                                                                                  MeeageProcessCompleted, MeeageProcessNoCompleted, ms, mStartEvent.Event);

            process.StartProcessThread();
            processList.Add(process);

            BeginInvokeUpdateHistory(data, len, "主站发送:U帧");


            return(true);
        }
Exemplo n.º 6
0
 public APCITypeU(TransmissionCotrolFunction fun)
 {
     apci = new ApplicationProtocalControlnformation();
     SetControlMessage(fun);
     apci.APDULength = 4; //仅仅只有APCI
 }
Exemplo n.º 7
0
 /// <summary>
 /// 移除指定typeID的类型EventProperty
 /// </summary>
 /// <param name="typeID">类型ID</param>
 public void RemoveEventProcess(TransmissionCotrolFunction typeID)
 {
     eventList.Remove(eventList.Find(x => x.TypeID == typeID));
 }