Beispiel #1
0
 void BtnStopNMon_Click(object sender, RoutedEventArgs e)
 {
     StopNMon();
     if (mNMonCore != null)
     {
         mNMonCore.StopMon();
         mNMonCore = null;
     }
 }
Beispiel #2
0
 public override void Stop()
 {
     if (mNMonCore != null)
     {
         mNMonCore.StopMon();
     }
     mNMonCore = null;
     base.Stop();
 }
Beispiel #3
0
        private void DoStopNMonMessage(RequestMessage request)
        {
            ReturnMessage retMessage = new ReturnMessage();

            retMessage.Result    = true;
            retMessage.SessionID = SessionID;
            retMessage.Code      = 0;
            try
            {
                if (request.ListData == null ||
                    request.ListData.Count < 1)
                {
                    SendErrorMessage(request.Command, Defines.RET_PARAM_INVALID,
                                     string.Format("ListData is null or count invalid"));
                    return;
                }
                string strMonID = request.ListData[0];
                LogDebugMessage(request.Command,
                                string.Format("MonID:{0};", strMonID));
                if (mMonType != MonType.NMon)
                {
                    SendErrorMessage(request.Command, Defines.RET_CHECK_FAIL,
                                     string.Format("MonType invalid.\t{0}", mMonType));
                    return;
                }
                MonitorObject monObj = mListMonObjects.FirstOrDefault(o => o.MonID == strMonID);
                if (monObj == null)
                {
                    SendErrorMessage(request.Command, Defines.RET_NOT_EXIST,
                                     string.Format("Monitor object not in the monitor list"));
                    return;
                }
                if (mNMonCore == null)
                {
                    SendErrorMessage(request.Command, Defines.RET_OBJECT_NULL,
                                     string.Format("NMonCore is null"));
                    return;
                }
                var temp = mNMonCore.User as MonitorObject;
                if (temp == null || temp.MonID != monObj.MonID)
                {
                    SendErrorMessage(request.Command, Defines.RET_PARAM_INVALID,
                                     string.Format("MonitorObject invalid"));
                    return;
                }
                retMessage.Command = (int)Service10Command.ResStopNMon;
                retMessage.ListData.Add(strMonID);
                SendMessage(retMessage);
                mNMonCore.StopMon();
                mNMonCore = null;
            }
            catch (Exception ex)
            {
                SendErrorMessage(request.Command, Defines.RET_FAIL, ex.Message);
            }
        }
Beispiel #4
0
 void UCNMonPanel_Unloaded(object sender, RoutedEventArgs e)
 {
     if (mNMonCore != null)
     {
         mNMonCore.StopMon();
         mNMonCore = null;
     }
     if (mMonitorClient != null)
     {
         mMonitorClient.Stop();
         mMonitorClient = null;
     }
 }
Beispiel #5
0
 private void DealNMonStartNMonMessage(ReturnMessage retMessage)
 {
     try
     {
         if (retMessage.ListData.Count < 5)
         {
             AppendMessage(string.Format("ReturnMessage param count invalid."));
             return;
         }
         string strMonID          = retMessage.ListData[0];
         string strMonPort        = retMessage.ListData[1];
         string strTransAudioData = retMessage.ListData[2];
         string strAddress        = retMessage.ListData[3];
         string strChanID         = retMessage.ListData[4];
         AppendMessage(string.Format("MonID:{0};MonPort:{1};TransAudioData:{2};Address:{3};ChanID:{4}", strMonID,
                                     strMonPort, strTransAudioData, strAddress, strChanID));
         //strTransAudioData = "0";
         if (strTransAudioData == "0")
         {
             int intMonPort;
             int intChan;
             if (!int.TryParse(strMonPort, out intMonPort) ||
                 !int.TryParse(strChanID, out intChan))
             {
                 AppendMessage(string.Format("MonPort or ChanID invalid."));
                 return;
             }
             if (mNMonCore != null)
             {
                 mNMonCore.StopMon();
                 mNMonCore = null;
             }
             mNMonCore                 = new NMonCore(mNMonItem.MonObject);
             mNMonCore.Debug          += (s, msg) => AppendMessage(string.Format("[NMonCore]\t{0}", msg));
             mNMonCore.IsConnectServer = true;
             mNMonCore.IsDecodeData    = true;
             mNMonCore.IsPlayWave      = true;
             NETMON_PARAM param = new NETMON_PARAM();
             param.Host    = strAddress;
             param.Port    = intMonPort;
             param.Channel = intChan;
             AppendMessage(string.Format("Monitor param \tHost:{0};Port:{1};Chan:{2}", param.Host, param.Port,
                                         param.Channel));
             mNMonCore.StartMon(param);
         }
     }
     catch (Exception ex)
     {
         AppendMessage(ex.Message);
     }
 }
Beispiel #6
0
        private void StopNMon()
        {
            try
            {
                StopNMonObject(false);

                if (mNMonCore != null)
                {
                    mNMonCore.StopMon();
                    mNMonCore = null;
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Beispiel #7
0
 void MainWindow_Closing(object sender, CancelEventArgs e)
 {
     if (mNMonCore != null)
     {
         mNMonCore.StopMon();
         mNMonCore = null;
     }
     if (mMonClient != null)
     {
         mMonClient.Stop();
         mMonClient = null;
     }
     if (mNMonClient != null)
     {
         mNMonClient.Stop();
         mNMonClient = null;
     }
 }
Beispiel #8
0
 private void DealNMonHeadMessage(NotifyMessage notMessage)
 {
     try
     {
         if (notMessage.ListData == null || notMessage.ListData.Count < 2)
         {
             AppendMessage(string.Format("NotifyMessage param count invalid."));
             return;
         }
         string strMonID = notMessage.ListData[0];
         string strHead  = notMessage.ListData[1];
         if (mNMonItem == null)
         {
             return;
         }
         if (mNMonItem.MonID != strMonID)
         {
             return;
         }
         MonitorObject monObj = mNMonItem.MonObject;
         if (monObj == null)
         {
             return;
         }
         byte[]       data = Converter.Hex2Byte(strHead);
         SNM_RESPONSE head = (SNM_RESPONSE)Converter.Bytes2Struct(data, typeof(SNM_RESPONSE));
         if (mNMonCore != null)
         {
             mNMonCore.StopMon();
             mNMonCore = null;
         }
         mNMonCore = new NMonCore(monObj);
         mNMonCore.IsConnectServer = false;
         mNMonCore.IsDecodeData    = false;
         mNMonCore.Debug          += (s, msg) => AppendMessage(string.Format("NMonCore:{0}", msg));
         mNMonCore.ReceiveHead(head);
     }
     catch (Exception ex)
     {
         AppendMessage(ex.Message);
     }
 }
Beispiel #9
0
 private void InitNMon(MonitorObject monObj, NETMON_PARAM param)
 {
     try
     {
         if (mNMonCore != null)
         {
             mNMonCore.StopMon();
             mNMonCore = null;
         }
         mNMonCore               = new NMonCore(monObj);
         mNMonCore.Debug        += (s, msg) => OnDebug(LogMode.Debug, string.Format("{0}\t{1}", s, msg));
         mNMonCore.HeadReceived += NMonCore_HeadReceived;
         mNMonCore.DataReceived += NMonCore_DataReceived;
         mNMonCore.IsPlayWave    = false;
         mNMonCore.StartMon(param);
     }
     catch (Exception ex)
     {
         OnDebug(LogMode.Error, string.Format("InitNMon fail.\t{0}", ex.Message));
     }
 }
Beispiel #10
0
 private void DealNMonHeadMessage(NotifyMessage notMessage)
 {
     try
     {
         if (notMessage.ListData == null || notMessage.ListData.Count < 2)
         {
             CurrentApp.WriteLog("NMonHeadMessage", string.Format("ListData count invalid"));
             return;
         }
         string strMonID = notMessage.ListData[0];
         string strHead  = notMessage.ListData[1];
         if (strMonID == mMonitorObject.MonID)
         {
             MonitorObject monObj = mMonitorObject;
             byte[]        data   = Converter.Hex2Byte(strHead);
             SNM_RESPONSE  head   = (SNM_RESPONSE)Converter.Bytes2Struct(data, typeof(SNM_RESPONSE));
             if (mNMonCore != null)
             {
                 mNMonCore.StopMon();
                 mNMonCore = null;
             }
             mMonitorItem.VoiceFormat   = head.format;
             mMonitorItem.TimeDeviation = mTimeDeviation;
             mMonitorItem.UpdateState();
             mNMonCore = new NMonCore(monObj);
             mNMonCore.IsConnectServer = false;
             mNMonCore.IsDecodeData    = false;
             mNMonCore.Debug          += (s, msg) =>
             {
                 CurrentApp.WriteLog("NMonCore", msg);
             };
             mNMonCore.ReceiveHead(head);
         }
     }
     catch (Exception ex)
     {
         CurrentApp.WriteLog("NMonHeadMessage", string.Format("Fail.\t{0}", ex.Message));
     }
 }
Beispiel #11
0
        public void CloseNMonPanel()
        {
            try
            {
                StopNMonObject(true);

                if (mNMonCore != null)
                {
                    mNMonCore.StopMon();
                    mNMonCore = null;
                }

                RemoveMonObject();
                if (PageParent != null)
                {
                    PageParent.ClosePanel(1);
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Beispiel #12
0
 void BtnStartMon_Click(object sender, RoutedEventArgs e)
 {
     if (!CheckInput())
     {
         return;
     }
     SubDebug(string.Format("Start monitor start."));
     if (TxtChannel0.Text != string.Empty)
     {
         //Create NetMonitor object,can simply create it like:
         //VLNMonCore core=new VLNMonCore()
         //if need't any particular settings
         NETMON_PARAM param = new NETMON_PARAM();
         param.Host    = TxtVoiceIp.Text;
         param.Port    = int.Parse(TxtMonitorPort.Text);
         param.Channel = int.Parse(TxtChannel0.Text);
         string   str  = "VLNMon0";
         NMonCore core = new NMonCore(str);
         core.Debug          += Core_Debug;
         core.HeadReceived   += Core_HeadReceived;
         core.DataReceived   += Core_DataReceived;
         core.IsConnectServer = CbConnectVoice.IsChecked == true;
         //core.IsConnectServer = false;
         core.IsDecodeData = CbDecodeData.IsChecked == true;
         //core.IsDecodeData = false;
         core.IsPlayWave = CbPlayWave.IsChecked == true;
         //core.IsPlayWave = true;
         core.IsSourceWaveWriteFile = CbWriteSrcFile.IsChecked == true;
         core.IsPcmWaveWriteFile    = CbWritePcmFile.IsChecked == true;
         core.WaveDirectory         = TxtWaveDir.Text;
         if (RbRight0.IsChecked == true)
         {
             core.Volume = 5;
         }
         else if (RbLeft0.IsChecked == true)
         {
             core.Volume = 3;
         }
         else
         {
             core.Volume = 1;
         }
         mVLNMonCores.Add(str, core);
         core.StartMon(param);
     }
     if (TxtChannel1.Text != string.Empty)
     {
         NETMON_PARAM param = new NETMON_PARAM();
         param.Host    = TxtVoiceIp.Text;
         param.Port    = int.Parse(TxtMonitorPort.Text);
         param.Channel = int.Parse(TxtChannel1.Text);
         string   str  = "VLNMon1";
         NMonCore core = new NMonCore(str);
         core.Debug          += Core_Debug;
         core.HeadReceived   += Core_HeadReceived;
         core.DataReceived   += Core_DataReceived;
         core.IsConnectServer = CbConnectVoice.IsChecked == true;
         core.IsDecodeData    = CbDecodeData.IsChecked == true;
         core.IsPlayWave      = CbPlayWave.IsChecked == true;
         //core.IsPlayWave = false;
         core.IsSourceWaveWriteFile = CbWriteSrcFile.IsChecked == true;
         core.IsPcmWaveWriteFile    = CbWritePcmFile.IsChecked == true;
         core.WaveDirectory         = TxtWaveDir.Text;
         if (RbRight1.IsChecked == true)
         {
             core.Volume = 5;
         }
         else if (RbLeft1.IsChecked == true)
         {
             core.Volume = 3;
         }
         else
         {
             core.Volume = 1;
         }
         mVLNMonCores.Add(str, core);
         core.StartMon(param);
     }
 }
Beispiel #13
0
        private void DealStartNMonMessage(ReturnMessage retMessage)
        {
            try
            {
                if (retMessage.ListData == null || retMessage.ListData.Count < 1)
                {
                    CurrentApp.WriteLog("DealStartNMon", string.Format("ListData is null or count invalid"));
                    return;
                }
                string strMonID = retMessage.ListData[0];
                if (strMonID != mMonitorObject.MonID)
                {
                    CurrentApp.WriteLog("DealStartNMon", string.Format("MonID invalid"));
                    return;
                }
                string strNMonPort        = "0";
                string strIsTransAudioS04 = "1";
                if (retMessage.ListData.Count > 1)
                {
                    strNMonPort = retMessage.ListData[1];
                }
                if (retMessage.ListData.Count > 2)
                {
                    strIsTransAudioS04 = retMessage.ListData[2];
                }
                mIsTransAudioS04 = strIsTransAudioS04 == "1";
                if (!mIsTransAudioS04)
                {
                    if (!int.TryParse(strNMonPort, out mNMonPort))
                    {
                        CurrentApp.WriteLog("DealStartNMon", string.Format("NMon port invalid.\t{0}", strNMonPort));
                        return;
                    }
                    if (mNMonCore != null)
                    {
                        mNMonCore.StopMon();
                        mNMonCore = null;
                    }
                    mNMonCore        = new NMonCore(mMonitorObject);
                    mNMonCore.Debug += (s, msg) =>
                    {
                        CurrentApp.WriteLog("NMonCore", msg);
                    };
                    mNMonCore.IsConnectServer = true;
                    mNMonCore.IsDecodeData    = true;
                    mNMonCore.IsPlayWave      = true;
                    mNMonCore.HeadReceived   += (s, head) =>
                    {
                        if (mMonitorItem != null)
                        {
                            mMonitorItem.VoiceFormat = head.format;
                        }
                    };
                    string       strHost = mMonitorObject.Other03;
                    int          monPort = mNMonPort;
                    int          channel = int.Parse(mMonitorObject.Other01);
                    NETMON_PARAM param   = new NETMON_PARAM();
                    param.Host    = strHost;
                    param.Port    = monPort;
                    param.Channel = channel;
                    CurrentApp.WriteLog("DealStartNMon",
                                        string.Format("Monitor param \tHost:{0} \tPort:{1} \tChannel:{2}", strHost, monPort, channel));

                    mNMonCore.StartMon(param);
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }