Ejemplo n.º 1
0
        public async Task <TASK_PARAM> QueryTaskInfoAsync(int nChPort, string strMsvIP, /*int taskid,*/ Sobey.Core.Log.ILogger logger)
        {
            logger.Info($"MsvSDK prepare QueryTaskState(ip={strMsvIP})");
            try
            {
                TASK_PARAM info = IsTestDevice(strMsvIP, nChPort) ?
                                  await _clientSdk.Test_MSVQueryRuningTaskAsync(strMsvIP, nChPort, 0, logger).ConfigureAwait(true)
                    : await _clientSdk.MSVQueryRuningTaskAsync(strMsvIP, nChPort, logger).ConfigureAwait(true);

                if (info == null)
                {
                    logger.Error($" MSVQueryRuningTask net Error {_clientSdk.MSVGetLastErrorString()}");
                    return(null);
                }

                //string strbtime = info.tmBeg.ToString("yy-MM-dd hh:mm:ss");
                //string stretime = info.tmBeg.ToString("yy-MM-dd hh:mm:ss");
                //info.tmBeg = Convert.ToDateTime(strbtime);
                //info.tmEnd = Convert.ToDateTime(stretime);
                //MSVTskParam2ClientParam(info, ref tskparam);
                return(info);
            }
            catch (Exception e)
            {
                logger.Error($"MsvUdpClientCtrlSDK::QueryTaskState, Exception:{e.Message}");
                return(null);
            }
        }
Ejemplo n.º 2
0
        public async Task <TaskParam> TraceAsync(int nChPort, string strMsvIP, TaskParam pTaskparam, string strTaskName, string pCaptureparam, Sobey.Core.Log.ILogger logger)
        {
            MSV_RET ret;

            try
            {
                TASK_PARAM tmptaskparam = new TASK_PARAM();
                ClientParam2MSVTskParam(pTaskparam, ref tmptaskparam);
                TASK_ALL_PARAM_NEW task = new TASK_ALL_PARAM_NEW();
                task.taskParam.ulID    = tmptaskparam.ulID;
                task.taskParam.strName = strTaskName;
                task.nCutLen           = 10;
                task.captureParam      = pCaptureparam;
                //ret = _clientSdk.MSVStartRetrospectTask(strMsvIP, task, nChPort, logger);
                ret = await _clientSdk.MSVStartRetrospectTaskAsync(strMsvIP, task, nChPort, logger).ConfigureAwait(true);

                if (ret != MSV_RET.MSV_SUCCESS)
                {
                    logger.Error($"MSVStartRetrospectTask falied, error:{_clientSdk.MSVGetLastErrorString()} ");
                    return(pTaskparam);
                }
                logger.Info($"MSVStartRetrospectTask end......MsvUdpClientCtrlSDK Trace");
            }
            catch (Exception e)
            {
                logger.Error($"MsvUdpClientCtrlSDK::Trace falied, Exception:{e.Message} ");
                return(null);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public async Task <bool> RecordAsync(TASK_ALL_PARAM_NEW allparam, int nChPort, string strMsvIP, Sobey.Core.Log.ILogger logger)
        {
            MSV_RET ret;
            string  strMutPath = "";
            string  strPath    = "";
            int     nMsvRet    = 0;

            try
            {
                var _xml = new XmlDocument();
                _xml.LoadXml(allparam.captureParam);
                XmlElement _root    = _xml.DocumentElement;
                XmlNode    pathNode = _root.SelectSingleNode("multiDest");
                if (pathNode != null)
                {
                    strPath    = pathNode.InnerText;
                    strMutPath = string.Format("<multiDest><taskid>{0}</taskid>{1}</multiDest>", allparam.taskParam.ulID, strPath);
                    //ret = _clientSdk.MSVSetMulDestPath(strMsvIP, strMutPath, logger);
                    ret = await _clientSdk.MSVSetMulDestPathAsync(strMsvIP, nChPort, strMutPath, logger).ConfigureAwait(true);

                    if (ret == MSV_RET.MSV_NETERROR)
                    {
                        logger.Error($"MSVSetMulDestPath::taskName={allparam.taskParam.strName};Error:{_clientSdk.MSVGetLastErrorString()}!");
                    }
                }

                allparam.nCutLen = 10;
                logger.Info($"MsvSDK Record Prepare Cast MSVStartTaskNew Function ip={strMsvIP} port={nChPort} cutlen={allparam.nCutLen}");

                //ret = _clientSdk.MSVStartTaskNew(strMsvIP, m_taskAllParam, nChPort, logger);
                ret     = await _clientSdk.MSVStartTaskNewAsync(strMsvIP, allparam, nChPort, logger).ConfigureAwait(true);;
                nMsvRet = Convert.ToInt32(ret);
                if (ret == MSV_RET.MSV_NETERROR)
                {
                    logger.Error("MsvSDK Record Failed(MSV_NETERROR)!...........MsvUdpClientCtrlSDK::Record");
                    return(false);
                }
                if (ret != MSV_RET.MSV_SUCCESS)
                {
                    logger.Error($"MsvSDK Record Failed {ret} {_clientSdk.MSVGetLastErrorString()}");
                    return(false);
                }
                return(true);
            }
            catch (Exception e)
            {
                logger.Error($"MsvUdpClientCtrlSDK::Record, Exception:{e.Message}");
                return(false);
            }
        }
Ejemplo n.º 4
0
        //capture 刚发采集命令发完要完全确认状态
        public async Task <Device_State> QueryDeviceStateAsync(int nChPort, string strMsvIP, bool capture, Sobey.Core.Log.ILogger logger)
        {
            try
            {
                MSV_STATE state = await _clientSdk.MSVQueryStateAsync(strMsvIP, nChPort, logger).ConfigureAwait(true);

                if (state == null)
                {
                    logger.Error($"MSVQueryState MSV_NETERROR, {strMsvIP}:{nChPort}, error: {_clientSdk.MSVGetLastErrorString()}");
                    return(Device_State.DISCONNECTTED);
                }

                logger.Info($"MSVQueryState End, state:{state.msv_capture_state}......");

                if (capture)
                {
                    if (state.msv_capture_state == CAPTURE_STATE.CS_CAPTURE || state.msv_capture_state == CAPTURE_STATE.CS_CAPTURE_ACTIVE)
                    {
                        return(Device_State.WORKING);
                    }
                    else
                    {
                        return(Device_State.CONNECTED);
                    }
                }
                else
                {
                    if (state.msv_capture_state == CAPTURE_STATE.CS_PAUSE || state.msv_capture_state == CAPTURE_STATE.CS_CAPTURE)
                    {
                        return(Device_State.WORKING);
                    }
                    else
                    {
                        return(Device_State.CONNECTED);
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error($"MsvUdpClientCtrlSDK::QueryState, Exception {e.Message}");
                return(Device_State.DISCONNECTTED);
            }
        }
Ejemplo n.º 5
0
        public async Task <SDISignalDetails> QuerySignalStatusAsync(int nChPort, string strMsvIP, Sobey.Core.Log.ILogger logger)
        {
            SDISignalDetails _SDISignalDetails = new SDISignalDetails();
            bool             bIsBlack          = false;

            try
            {
                //ret = _clientSdk.MSVQuerySDIFormat(strMsvIP, ref status, ref bIsBlack, logger, nChPort);
                var retback = await _clientSdk.MSVQuerySDIFormatAsync(strMsvIP, logger, nChPort).ConfigureAwait(true);

                if (retback == null)
                {
                    logger.Error($"Cast Interface Function QuerySignalStatus Error!(error{_clientSdk.MSVGetLastErrorString()}");
                    return(null);
                }
                //处理数据
                if (retback.VideoFormat != SignalFormat._invalid_vid_format && retback.VideoFormat != SignalFormat._unknown_vid_format && retback.nWidth > 0)
                {
                    if (retback.nWidth <= 720)
                    {
                        _SDISignalDetails.nSDIFormat = 0;
                    }
                    else
                    {
                        _SDISignalDetails.nSDIFormat = 1;
                    }
                }

                _SDISignalDetails.nWidth     = retback.nWidth;
                _SDISignalDetails.nHeight    = retback.nHeight;
                _SDISignalDetails.nDFMode    = Convert.ToInt32(retback.TCMode);
                _SDISignalDetails.fFrameRate = retback.fFrameRate;
                _SDISignalDetails.bIsBlack   = Convert.ToBoolean(bIsBlack);
                return(_SDISignalDetails);
            }
            catch (System.Exception e)
            {
                logger.Error($"MsvUdpClientCtrlSDK::QuerySignalStatus Exception:{e.Message}");

                return(null);
            }
        }
Ejemplo n.º 6
0
        public async Task <long> StopAsync(int nChPort, string strMsvIP, int taskID, Sobey.Core.Log.ILogger logger)
        {
            try
            {
                long nRetTaskId = await _clientSdk.MSVStopTaskAsync(strMsvIP, taskID, nChPort, logger).ConfigureAwait(true);

                if (nRetTaskId <= 0)
                {
                    logger.Error($"MSVStopTask failed, error:{_clientSdk.MSVGetLastErrorString()} ");
                    return(0);
                }
                logger.Info($"MSVStopTask end,MsvUdpClientCtrlSDK::Stop nRetTaskId::{nRetTaskId} ");
                return(nRetTaskId);
            }
            catch (Exception e)
            {
                logger.Error($"MsvUdpClientCtrlSDK::Stop, Exception:{e.Message} ");
                return(0);
            }
        }
Ejemplo n.º 7
0
        private async Task OnCheckAllDeviceAsync(object type)
        {
            bool request = false;

            if (_lstTimerScheduleDevice.Count > 0)
            {
                foreach (var item in _lstTimerScheduleDevice)
                {
                    var state = await _msvClient.QueryDeviceStateAsync(item.ChannelIndex, item.Ip, false, Logger);

                    MSV_Mode msvmode = MSV_Mode.NETWORK;
                    if (state == Device_State.DISCONNECTTED)
                    {
                        msvmode = MSV_Mode.ERROR;
                        Logger.Warn($"QueryDeviceState {state}");
                    }

                    bool changedstate = false;
                    if (item.CurrentDevState != state || msvmode != item.LastMsvMode)
                    {
                        changedstate         = true;
                        item.LastDevState    = item.CurrentDevState;
                        item.LastMsvMode     = msvmode;
                        item.CurrentDevState = state;

                        if (!await _restClient.UpdateMSVChannelStateAsync(item.ChannelId, item.LastMsvMode, item.CurrentDevState).ConfigureAwait(true))
                        {
                            Logger.Error("OnCheckAllChannelsAsync UpdateMSVChannelStateAsync error");
                        }
                    }

                    if (item.LastDevState == Device_State.DISCONNECTTED &&
                        item.CurrentDevState == Device_State.CONNECTED &&
                        item.NeedStopFlag)
                    {
                        item.NeedStopFlag = false;
                    }

                    if (item.LastDevState == Device_State.DISCONNECTTED &&
                        item.CurrentDevState == Device_State.WORKING &&
                        changedstate)
                    {
                        var taskinfo = await _msvClient.QueryTaskInfoAsync(item.ChannelIndex, item.Ip, Logger);

                        if (taskinfo != null && taskinfo.ulID > 0)
                        {
                            var cptaskinfo = await _restClient.GetChannelCapturingTaskInfoAsync(item.ChannelId);

                            bool needstop = true;
                            if (cptaskinfo != null && cptaskinfo.TaskId == taskinfo.ulID)
                            {
                                Logger.Info("OnCheckAllChannelsAsync not needstop");
                                needstop = false;
                            }

                            if (needstop)
                            {
                                /*
                                 * 应该不用通知出去,任务那边监听可以管理
                                 */
                                item.NeedStopFlag = true;

                                await _msvClient.StopAsync(item.ChannelIndex, item.Ip, cptaskinfo.TaskId, Logger);
                            }
                            else
                            {
                                item.NeedStopFlag = false;
                            }
                        }
                    }
                }

                request = await _grainFactory.GetGrain <IDeviceInspections>(0).SubmitChannelInfoAsync(_grainKey, _lstTimerScheduleDevice, false);
            }

            if (request)
            {
                _lstTimerScheduleDevice = await _grainFactory.GetGrain <IDeviceInspections>(0).RequestChannelInfoAsync(_grainKey);
            }
        }
Ejemplo n.º 8
0
        public TASK_ALL_PARAM_NEW RecordReady(int nChPort, string strMsvIP, TaskParam pTaskparam, string strTaskName, string pCaptureparam, Sobey.Core.Log.ILogger logger)
        {
            if (pTaskparam == null)
            {
                logger.Error("RecordReady: pTaskparam is null!");
                return(null);
            }
            TASK_PARAM param     = new TASK_PARAM();
            TASK_PARAM taskParam = new TASK_PARAM();

            try
            {
                logger.Info($"MsvSDK Record Ready!,taskID:{pTaskparam.taskID},pCaptureparam:{pCaptureparam} ");
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(pCaptureparam);
                XmlNode root = doc.DocumentElement;
                //string curDate = DateTime.Now.ToString("yyyy-MM-dd") + '\\';
                string curDate = DateTime.Now.ToString("yyyy-MM-dd");
                if (root != null)
                {
                    //XmlNode _capTure = root.SelectSingleNode("CAPTUREPARAM");

                    XmlNode _fileName0 = root.SelectSingleNode("path0FileName");
                    if (_fileName0 != null)
                    {
                        string fileName0 = _fileName0.InnerText;
                        //fileName0 += curDate;
                        //                         int nIndex = fileName0.LastIndexOf('\\');
                        //                         if (nIndex == fileName0.Length - 1)
                        //                             fileName0 = fileName0.Substring(0, nIndex);
                        //                         int nPos = fileName0.LastIndexOf('\\');
                        //                         fileName0 = fileName0.Insert(nPos + 1, curDate);
                        //fileName0 = fileName0.Substring(0, nPos + 1);
                        //fileName0 = fileName0 + curDate;
                        fileName0            = fileName0.Replace("yyyy-mm-dd", curDate);
                        _fileName0.InnerText = fileName0;
                    }
                    else
                    {
                        logger.Error("Not find fileName0:");
                    }
                    XmlNode _fileName1 = root.SelectSingleNode("path1FileName");
                    if (_fileName1 != null)
                    {
                        string fileName1 = _fileName1.InnerText;
                        //fileName1 += curDate;
                        //                         int nIndex = fileName1.LastIndexOf('\\');
                        //                         if (nIndex == fileName1.Length - 1)
                        //                             fileName1 = fileName1.Substring(0, nIndex);
                        //                         int nPos = fileName1.LastIndexOf('\\');
                        //                         fileName1 = fileName1.Insert(nPos + 1, curDate);
                        //fileName1 = fileName1.Substring(0, nPos + 1);
                        //fileName1 = fileName1 + curDate;
                        fileName1            = fileName1.Replace("yyyy-mm-dd", curDate);
                        _fileName1.InnerText = fileName1;
                    }
                    else
                    {
                        logger.Error("Not find fileName1:");
                    }
                }
                else
                {
                    logger.Error("root is null");
                }
                pCaptureparam = doc.InnerXml;
                logger.Info($"MsvSDK Record Ready!, taskID:{pTaskparam.taskID}, lastCapture:{pCaptureparam}...........RecordReady");
                ClientParam2MSVTskParam(pTaskparam, ref param);
                taskParam.bRetrospect    = param.bRetrospect;
                taskParam.bUseTime       = param.bUseTime;
                taskParam.channel        = param.channel;
                taskParam.dwCutClipFrame = param.dwCutClipFrame;
                taskParam.nInOutCount    = param.nInOutCount;
                taskParam.strName        = param.strName;
                for (int i = 0; i < taskParam.nInOutCount; i++)
                {
                    taskParam.dwInFrame[i]    = param.dwInFrame[i];
                    taskParam.dwOutFrame[i]   = param.dwOutFrame[i];
                    taskParam.dwTotalFrame[i] = param.dwTotalFrame[i];
                }


                taskParam.nSignalID = param.nSignalID;
                taskParam.nTimeCode = param.nTimeCode;
                //m_taskparam.strDesc.Format(_T("%s"),pTaskparam->strDesc);
                //m_taskParam.strName = strTaskName;

                taskParam.tmBeg     = DateTime.Now;
                taskParam.tmEnd     = DateTime.Now;
                taskParam.ulID      = param.ulID;
                taskParam.TaskMode  = (TASK_MODE)param.TaskMode;
                taskParam.TaskState = (TASK_STATE)param.TaskState;

                //m_taskAllParam.captureParam = pCaptureparam;
                //m_taskAllParam.nCutLen = 10;
                //m_taskAllParam.taskParam = m_taskParam;
                //m_taskAllParam.taskParam.strName = strTaskName;
                logger.Info($"curent strTaskName: {strTaskName}");

                return(new TASK_ALL_PARAM_NEW()
                {
                    captureParam = pCaptureparam, nCutLen = 10, taskParam = taskParam
                });
            }
            catch (Exception e)
            {
                logger.Error($"MsvUdpClientCtrlSDK::RecordReady, Exception:{e.Message}");
                return(null);
            }
        }
Ejemplo n.º 9
0
        public async Task <SDISignalStatus> QuerySDIFormatAsync(int nChPort, string strMsvIP, Sobey.Core.Log.ILogger logger)
        {
            try
            {
                //ret = _clientSdk.MSVQuerySDIFormat(strMsvIP, ref singleType, ref bIsBack, logger, nChPort);
                var ret = await _clientSdk.MSVQuerySDIFormatAsync(strMsvIP, logger, nChPort).ConfigureAwait(true);

                if (ret == null)
                {
                    logger.Error($"Cast Interface Function MSVQuerySDIFormat Error!(error {_clientSdk.MSVGetLastErrorString()})...........MsvUdpClientCtrlSDK::QuerySDIFormat");
                    return(null);
                }

                logger.Info($"Cast Interface Function QuerySDIFormat!(vedioformat ={ret.VideoFormat} :width :{ret.nWidth})...........MsvUdpClientCtrlSDK::QuerySDIFormat");

                int  pnSingleType = 255;
                bool bValidVideo  = false;
                switch (ret.VideoFormat)
                {
                case SignalFormat._invalid_vid_format:
                    pnSingleType = 254;
                    break;

                //case 4095:
                //	{
                //		bValidVideo = TRUE;
                //	}
                case SignalFormat._unknown_vid_format:
                    pnSingleType = 255;
                    break;

                default:
                    bValidVideo = true;
                    break;
                }
                if (bValidVideo)
                {
                    if (ret.nWidth > 0 && ret.nWidth <= 720)
                    {
                        pnSingleType = 0;
                    }
                    else if (ret.nWidth >= 3840)
                    {
                        pnSingleType = 2;
                    }
                    else if (ret.nWidth > 720)
                    {
                        pnSingleType = 1;
                    }
                    else
                    {
                        pnSingleType = 254;
                        bValidVideo  = false;
                    }

                    ret.SignalType = pnSingleType;
                    return(ret);
                }
                return(null);
            }
            catch (System.Exception e)
            {
                logger.Error($"Cast Interface Function MSVQuerySDIFormat Exception! {e.Message})...........MsvUdpClientCtrlSDK::QuerySDIFormat");

                return(null);
            }
        }