コード例 #1
0
        public static bool IsStringLike(DVR vr)
        {
            switch (vr)
            {
            case DVR.AE:
            case DVR.AS:
            case DVR.CS:
            case DVR.DS:
            case DVR.IS:
            case DVR.LO:
            case DVR.LT:
            case DVR.SH:
            case DVR.ST:
            case DVR.UT:
            case DVR.PN:
            {
                return(true);
            }

            default:
            {
                return(false);
            }
            }
        }
コード例 #2
0
        public static DPath GetDPath(DicomTag tag, DVR vr, string description, string sqRootPath, int sqIndex)
        {
            string strG = DHelper.Int2HexString(tag.Group);
            string strE = DHelper.Int2HexString(tag.Element);
            //string name = DHelper.GetTagName((uint)ele.Tag);

            // for shorten the DPath string length 20071010
            string name = "A";

            StringBuilder sb = new StringBuilder();

            if (sqRootPath != null && sqIndex >= 0)
            {
                sb.Append(sqRootPath).Append(Seperator).Append(sqIndex.ToString()).Append(Seperator);
            }
            sb.Append(strG).Append(Seperator).Append(strE).Append(Seperator).Append(name).Append(Seperator);
            string str = sb.ToString();

            DPath dpath = new DPath();

            dpath.Path        = str.TrimEnd(Seperator);
            dpath.Description = description;
            dpath.VR          = vr;
            return(dpath);
        }
コード例 #3
0
        private string getValue()
        {
            try
            {
                int vm = 0;
                DVR vr = DHelper.ConvertToDVR(DicomVR.UN);
                if (_element != null)
                {
                    vr = DHelper.ConvertToDVR(_element.ValueRepresentation);
                    //vm = _element.VM;
                }
                if (vr == DVR.UN)
                {
                    if (_element != null)        // do not implement _element yet, because error handler is using Element with (0000,0000), fix this in the future 20080312
                    {
                        return("");
                    }
                }

                // ----------------

                switch (vr)
                {
                case DVR.UN:
                case DVR.OB:
                case DVR.OF:
                case DVR.OW:
                case DVR.SQ:
                {
                    return("");
                }

                //VRs of LO, LT, SH, ST, and UT plus PN for person name are subject to character set extensions.
                //VRs AE, AS, CS, DS, and IS always use the default character set and have further restrictions on their contents.
                case DVR.LO:
                case DVR.LT:
                case DVR.SH:
                case DVR.ST:
                case DVR.UT:
                default:
                {
                    DicomMultiStringElement dicomMultiStringElement = _element as DicomMultiStringElement;

                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < dicomMultiStringElement.Count; i++)
                    {
                        sb.Append(dicomMultiStringElement.Get <string>(i)).Append(DHelper.ValueDelimiter);
                    }
                    return(sb.ToString().TrimEnd(DHelper.ValueDelimiter));
                }
                }
            }
            catch (Exception err)
            {
                DElement errEle = new DElement(_tag, _vr);
                LogMgt.Logger.Write(err.ToString());
            }
            return("");
        }
コード例 #4
0
        public bool ValidateValue()
        {
            int    tag  = GetTag();
            DVR    vr   = GetVR();
            string desc = this._comboxBoxTag.Text;

            return((tag != 0) && (vr != DVR.Unknown) && desc.Length > 0);
        }
コード例 #5
0
        public void StartRegistration()
        {
            m_LPREngine = (LPREngine)m_AppData.LPREngine;
            m_LPREngine.OnNewFilteredPlateGroupEvent += new LPREngine.NewPlateEvent(NewLPRResultsEvent_OnNewPlateEvent);

            m_EmailService = (EmailServices)m_AppData.EmailServices;
            m_DVR          = (DVR)m_AppData.DVR;
        }
コード例 #6
0
 public static DDateTime2 FromDateTime(DVR vr, string dicomString)
 {
     if (dicomString == null || dicomString.Length < 1)
     {
         return(null);
     }
     return(new DDateTime2(vr, dicomString));
 }
コード例 #7
0
        public DElement(int groupNumber, int elementNumber, DVR vr, string value)
        {
            IsRef = false;

            DicomVR  dicomVR  = DHelper.ConvertToDicomVR(vr);
            DicomTag dicomTag = new DicomTag((ushort)groupNumber, (ushort)elementNumber);

            _element = CreateEmptyElement(dicomTag, dicomVR);
            Value    = value;
        }
コード例 #8
0
        public DElement(int tag, DVR vr, DValueType type)
        {
            IsRef = false;

            DicomVR  dicomVR  = DHelper.ConvertToDicomVR(vr);
            DicomTag dicomTag = DHelper.Int2DicomTag(tag);

            _element = CreateEmptyElement(dicomTag, dicomVR);

            Type = type;
        }
コード例 #9
0
        private static object GetDT(DVR vr, string str)
        {
            System.DateTime dt;
            string          strDicom = str;

            if (vr == DVR.DA)
            {
                if (System.DateTime.TryParseExact(strDicom,
                                                  new string[] { "yyyyMMdd", "yyyy.MM.dd" }, null,
                                                  System.Globalization.DateTimeStyles.None, out dt))
                {
                    return(dt);
                }
            }
            else if (vr == DVR.TM)
            {
                // ignore millisecond ...
                int dotIndex = strDicom.IndexOf('.');
                if (dotIndex >= 0)
                {
                    strDicom = strDicom.Substring(0, dotIndex);
                }
                if (System.DateTime.TryParseExact(strDicom,
                                                  new string[] { "HHmmss", "HHmm", "HH", "HH:mm:ss" }, null,
                                                  System.Globalization.DateTimeStyles.None, out dt))
                {
                    return(dt);
                }
            }
            if (vr == DVR.DT)
            {
                // ignore millisecond ...
                int dotIndex = strDicom.IndexOf('.');
                if (dotIndex >= 0)
                {
                    strDicom = strDicom.Substring(0, dotIndex);
                }
                if (System.DateTime.TryParseExact(strDicom,
                                                  new string[] { "yyyyMMddHHmmss" }, null,
                                                  System.Globalization.DateTimeStyles.None, out dt))
                {
                    return(dt);
                }
            }
            return(null);
        }
コード例 #10
0
        public static bool IsDateTime(DVR vr)
        {
            switch (vr)
            {
            case DVR.DA:
            case DVR.TM:
            case DVR.DT:
            {
                return(true);
            }

            default:
            {
                return(false);
            }
            }
        }
コード例 #11
0
 private void setVR(DVR vr)
 {
     try
     {
         DicomVR dicomVR = DHelper.ConvertToDicomVR(vr);
         if (_element != null)
         {
             DicomTag tag = _element.Tag;
             //string val = Value;
             _element = CreateEmptyElement(tag, dicomVR);
             //Value = val;
         }
     }
     catch (Exception ex)
     {
         LogMgt.Logger.Write(ex.ToString());
     }
 }
コード例 #12
0
        public static string GetGWDTStartString(object dto, DVR vr)
        {
            if (dto == null)
            {
                return("");
            }

            if (vr == DVR.DA)
            {
                return(((DateTime)dto).ToString(GWDataDB.DateFormat));
            }
            else if (vr == DVR.TM)
            {
                return(((DateTime)dto).ToString(GWDataDB.TimeFormat));
            }
            else if (vr == DVR.DT)
            {
                return(((DateTime)dto).ToString(GWDataDB.DateTimeFormat));
            }

            return("");
        }
コード例 #13
0
        public static string GetGWDTEndString(object dto, DVR vr)
        {
            if (vr == DVR.DA)
            {
                if (dto == null)
                {
                    return(DateTime.MaxValue.ToString(GWDataDB.DateFormat));
                }
                else
                {
                    return(((DateTime)dto).ToString(GWDataDB.DateFormat) + " 23:59:59");
                }
            }
            else if (vr == DVR.TM)
            {
                if (dto == null)
                {
                    return(DateTime.MaxValue.ToString(GWDataDB.TimeFormat));
                }
                else
                {
                    return(((DateTime)dto).AddSeconds(1).ToString(GWDataDB.TimeFormat));
                }
            }
            else if (vr == DVR.DT)
            {
                if (dto == null)
                {
                    return(DateTime.MaxValue.ToString(GWDataDB.DateTimeFormat));
                }
                else
                {
                    return(((DateTime)dto).AddSeconds(1).ToString(GWDataDB.DateTimeFormat));
                }
            }

            return("");
        }
コード例 #14
0
ファイル: LPRServiceCore.cs プロジェクト: mutita/anpr
        public void Start(bool AsService)
        {
            try
            {
                m_AppData.RunninAsService = AsService;


                //////////////////////////////////////
                //
                // setup system wide health statistics

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Drive].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_2].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_1].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_GPS].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Hotswap].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Service].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel1].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel2].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel3].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel4].StatString.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_DVR_DirectyToStorageQ].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_DVR_MotionDetectedQ].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_DVR_NewFrameQ].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_DVR_NewLPRRecordQ].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_FG_AllFramesConsumerPushQ].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_FG_MotionDetectedConsumerPushQ].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_FG_MotionDetectionQ].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_LPR_LPRFinalPlateGroupOutputQ].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_LPR_LPRPerFrameReadingQ].Accumulator.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.QueueOverruns.QueueOverruns_LPR_LPRProcessQ].Accumulator.RegisterForUse(true);


                //////////////////////////////////////
                //
                // start error reporting lib  ( decides if local and/or remote reporting)

                m_AppData.Logger = new ErrorLog(m_AppData);

                m_Log = (ErrorLog)m_AppData.Logger;

                m_Log.Log("Starting LPR Services", ErrorLog.LOG_TYPE.INFORMATIONAL);
                m_Log.Log("using file in path: " + UserSettings.GetAppPath(), ErrorLog.LOG_TYPE.INFORMATIONAL);

                //////////////////////////////////////
                //
                // start email lib (used by error reporting lib for remote error notifications and by the watch list processor)

                m_Log.Log("Loading Email module", ErrorLog.LOG_TYPE.INFORMATIONAL);

                m_AppData.EmailServices = new EmailServices(m_AppData);
                m_Email = (EmailServices)m_AppData.EmailServices;



                //////////////////////////////////////
                //
                // load the Frame Generator

                m_Log.Log("Loading Frame Generator module", ErrorLog.LOG_TYPE.INFORMATIONAL);
                m_AppData.FrameGenerator = (object)new FrameGenerator(m_AppData, AsService);


                //////////////////////////////////////
                //
                // load the DVR

                m_AppData.DVRMode = APPLICATION_DATA.DVR_MODE.STORE_ON_MOTION;
                m_Log.Log("Loading DVR module", ErrorLog.LOG_TYPE.INFORMATIONAL);
                m_DVR         = new DVR(m_AppData);
                m_AppData.DVR = (object)m_DVR;


                //////////////////////////////////////
                //
                // start the TCP Server
                if (m_AppData.RunninAsService)
                {
                    m_Log.Log("Loading TCP module", ErrorLog.LOG_TYPE.INFORMATIONAL);
                    m_RCServer = new RemoteConnectionServer.RemoteConnectionServer(m_AppData);
                }



                //////////////////////////////////////
                //
                // load the LPR Engine

                m_Log.Log("Loading LPR Engine", ErrorLog.LOG_TYPE.INFORMATIONAL);
                m_LPREngine         = new LPREngine(m_AppData);
                m_AppData.LPREngine = m_LPREngine;

                //////////////////////////////////////
                //
                // load the Watch List Processor

                m_Log.Log("Loading Watch List module", ErrorLog.LOG_TYPE.INFORMATIONAL);

                m_WatchList = new WatchLists(m_AppData);


                //  now that all modules are loaded, let them register with each other for event communications
                m_Log.Log("Starting registrations", ErrorLog.LOG_TYPE.INFORMATIONAL);
                if (m_AppData.RunninAsService)
                {
                    m_RCServer.StartRegistration();
                }
                m_DVR.StartRegistration();
                m_LPREngine.StartRegistration();
                m_WatchList.StartRegistration();



                // now let all modules start their threads
                if (m_AppData.RunninAsService)
                {
                    m_Log.Log("Starting TCP Server", ErrorLog.LOG_TYPE.INFORMATIONAL);
                    m_RCServer.StartThreads();
                }

                m_Log.Log("Starting DVR", ErrorLog.LOG_TYPE.INFORMATIONAL);
                m_DVR.StartThreads();

                m_Log.Log("Starting LPR Engine", ErrorLog.LOG_TYPE.INFORMATIONAL);
                m_LPREngine.StartThreads();

                m_Log.Log("Starting Watch list processor", ErrorLog.LOG_TYPE.INFORMATIONAL);
                m_WatchList.StartThreads();

                m_Log.Log("Starting Email Services", ErrorLog.LOG_TYPE.INFORMATIONAL);
                m_Email.StartThreads();

                // is everyone happy?
                //if (!m_DVR.GetDVRReady || !((FrameGenerator)m_AppData.FrameGenerator).GetReadyStatus)
                //{
                //    m_Log.Log("Error, self destruct", ErrorLog.LOG_TYPE.FATAL);
                //    m_AppData.SelfDestruct();
                //}
            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }
        }
コード例 #15
0
        private static void FillDataSet <TC>(Hashtable dr, ref int index, int depth, XCollection <TC> qcList, DicomDataset eleList)
            where TC : MappingItem, IDicomMappingItem
        {
            int count = qcList.Count;

            for (; index < count; index++)
            {
                TC qc = qcList[index] as TC;
                if (qc.Translating.Type == TranslatingType.FixValue)
                {
                    continue;
                }
                if (qc.DPath.Type == DPathType.BeginItem)
                {
                    continue;
                }
                if (qc.DPath.Type == DPathType.EndItem && depth > 0)
                {
                    break;
                }
                if (!qc.DPath.Enable)
                {
                    continue;
                }

                //int tag = qc.DPath.GetTag(depth);
                //DicomItem ele = eleList(tag);
                List <string> tagList = qc.DPath.GetTagGE(depth);
                if (tagList == null)
                {
                    continue;
                }

                ushort    uGroup   = DHelper.HexString2ushort(tagList[0]);
                ushort    uElement = DHelper.HexString2ushort(tagList[1]);
                DicomItem ele      = eleList.Get <DicomItem>(new DicomTag(uGroup, uElement));
                if (ele == null || ConvertDicomVRToDVR(ele.ValueRepresentation) != qc.DPath.VR)
                {
                    if (qc.DPath.VR == DVR.SQ)
                    {
                        continue;
                    }
                    dr[qc.SourceField] = GetSQLString <TC>(qc, (ele == null) ? "" : eleList.Get <string>(new DicomTag(uGroup, uElement)));
                    continue;
                }

                if (qc.DPath.VR == DVR.SQ)
                {
                    int           d             = depth + 1;
                    DicomDataset  sqList        = null;
                    DicomSequence dicomSequence = (DicomSequence)ele;
                    if (dicomSequence.Items.Count > 0)     //support one sequence item only
                    {
                        sqList = dicomSequence.Items[0];
                    }
                    index++;
                    if (sqList == null)
                    {
                        sqList = new DicomDataset();
                    }
                    FillDataSet <TC>(dr, ref index, d, qcList, sqList);
                    break;
                }
                else
                {
                    string value = eleList.Get <string>(new DicomTag(uGroup, uElement));
                    if (DHelper.IsDateTime(qc.DPath.VR))
                    {
                        DVR realVR = qc.DPath.VR;

                        // ------ merge TM to DT ------
                        if (uGroup == DicomTag.ScheduledProcedureStepStartDate.Group && uElement == DicomTag.ScheduledProcedureStepStartDate.Element)
                        {
                            string eleTM = eleList.Get <string>(DicomTag.ScheduledProcedureStepStartTime);
                            if (eleTM != null)
                            {
                                string   strTM     = eleTM;
                                string[] strTMList = strTM.Split('-');
                                string[] strDAList = value.Split('-');
                                if (strTMList.Length > 0 && strDAList.Length > 0)
                                {
                                    if (strDAList.Length == 1 && strDAList[0].Length > 0)
                                    {
                                        if (strTMList.Length == 1 && strTMList[0].Length > 0)
                                        {
                                            realVR = DVR.DT;
                                            if (strTM.Length > 6)
                                            {
                                                strTM = strTM.Substring(0, 6);
                                            }
                                            value += strTM;
                                        }
                                        else if (strTMList.Length == 2)
                                        {
                                            realVR = DVR.DT;
                                            string beginTM = strTMList[0];
                                            string endTM   = strTMList[1];
                                            if (beginTM.Length < 1)
                                            {
                                                beginTM = "000000";
                                            }
                                            if (endTM.Length < 1)
                                            {
                                                endTM = "235959";
                                            }
                                            if (beginTM.Length > 6)
                                            {
                                                beginTM = beginTM.Substring(0, 6);
                                            }
                                            if (endTM.Length > 6)
                                            {
                                                endTM = endTM.Substring(0, 6);
                                            }
                                            value = strDAList[0] + beginTM + "-" + strDAList[0] + endTM;
                                        }
                                    }
                                    else if (strDAList.Length == 2)
                                    {
                                        if (strTMList.Length == 1 && strTMList[0].Length > 0)
                                        {
                                            realVR = DVR.DT;
                                            if (strTM.Length > 6)
                                            {
                                                strTM = strTM.Substring(0, 6);
                                            }
                                            value = strDAList[0] + strTM + "-" + strDAList[1] + strTM;
                                        }
                                        else if (strTMList.Length == 2)
                                        {
                                            realVR = DVR.DT;
                                            string beginTM = strTMList[0];
                                            string endTM   = strTMList[1];
                                            if (beginTM.Length < 1)
                                            {
                                                beginTM = "000000";
                                            }
                                            if (endTM.Length < 1)
                                            {
                                                endTM = "235959";
                                            }
                                            if (beginTM.Length > 6)
                                            {
                                                beginTM = beginTM.Substring(0, 6);
                                            }
                                            if (endTM.Length > 6)
                                            {
                                                endTM = endTM.Substring(0, 6);
                                            }
                                            value = strDAList[0] + beginTM + "-" + strDAList[1] + endTM;
                                        }
                                    }
                                }
                            }
                        }
                        // ----------------------------

                        if (qc.DPath.Range == DRangeType.None)
                        {
                            DDateTime2 singleddt = DDateTime2.FromDateTime(realVR, value);
                            object     singledt  = (singleddt != null) ? singleddt.GetDateTime() : null;
                            //value = (singledt != null) ? ((DateTime)singledt).ToString(GWDataDB.DateTimeFormat) : "";
                            value = GetGWDTStartString(singledt, realVR);
                            dr[qc.SourceField] = GetSQLString <TC>(qc, value);
                            continue;
                        }

                        TC qcStart = qc;
                        if (qcStart.DPath.Range != DRangeType.Begin)
                        {
                            continue;
                        }

                        TC qcEnd = qcList[index + 1];
                        if (qcEnd == null || qcEnd.DPath.Range != DRangeType.End)
                        {
                            continue;
                        }

                        index++;

                        object     dtStart = null, dtEnd = null;
                        DDateTime2 ddt = DDateTime2.FromDateTime(realVR, value);
                        if (ddt != null)
                        {
                            switch (ddt.Type)
                            {
                            case DDateTimeType.SINGLE:
                            {
                                dtStart = dtEnd = ddt.GetDateTime();
                                break;
                            }

                            case DDateTimeType.START_ONLY:
                            {
                                dtStart = ddt.GetStartDateTime();
                                break;
                            }

                            case DDateTimeType.END_ONLY:
                            {
                                dtEnd = ddt.GetEndDateTime();
                                break;
                            }

                            case DDateTimeType.RANGE:
                            {
                                dtStart = ddt.GetStartDateTime();
                                dtEnd   = ddt.GetEndDateTime();
                                break;
                            }
                            }
                        }

                        string strStart = "", strEnd = "";
                        strStart = GetGWDTStartString(dtStart, realVR);
                        strEnd   = GetGWDTEndString(dtEnd, realVR);
                        dr[qcStart.SourceField] = strStart;
                        dr[qcEnd.SourceField]   = strEnd;
                    }
                    else if (qc.DPath.VR == DVR.PN)
                    {
                        value = PersonNameRule.Parse(value);
                        dr[qc.SourceField] = GetSQLString <TC>(qc, value);
                    }
                    else
                    {
                        dr[qc.SourceField] = GetSQLString <TC>(qc, value);
                    }
                    break;
                }
            }
        }
コード例 #16
0
        private static void FillElement <TR>(DicomDataset ds, DicomTag tagIn, DVR vrIn, ref int index, int depth, XCollection <TR> qrList, DataRow dr)
            where TR : QueryResultItem, IDicomMappingItem
        {
            TR qr = qrList[index] as TR;

            if (!qr.DPath.Enable)
            {
                return;
            }

            switch (qr.DPath.VR)
            {
            case DVR.Unknown: return;

            case DVR.SQ:
            {
                index++;
                int          count   = qrList.Count;
                DicomDataset eleList = null;
                for (; index < count; index++)
                {
                    qr = qrList[index] as TR;
                    switch (qr.DPath.Type)
                    {
                    case DPathType.BeginItem:
                    {
                        eleList = new DicomDataset();
                        continue;
                    }

                    case DPathType.EndItem:
                    {
                        DicomSequence dicomSequence = new DicomSequence(tagIn);
                        if (eleList != null)
                        {
                            dicomSequence.Items.Add(eleList);
                        }
                        TR qrNext = ((index + 1) < qrList.Count) ? qrList[index + 1] : null;
                        if (qrNext == null || qrNext.DPath.Type != DPathType.BeginItem)
                        {
                            return;
                        }
                        continue;
                    }

                    default:
                    {
                        if (eleList == null)
                        {
                            continue;
                        }
                        if (!qr.DPath.Enable)
                        {
                            continue;
                        }
                        //int tag = qr.DPath.GetTag(depth + 1);
                        List <string> tagList  = qr.DPath.GetTagGE(depth + 1);
                        ushort        uGroup   = DHelper.HexString2ushort(tagList[0]);
                        ushort        uElement = DHelper.HexString2ushort(tagList[1]);
                        DicomTag      tag      = new DicomTag(uGroup, uElement);

                        //DElement ele = new DElement(tag, qr.DPath.VR);
                        FillElement <TR>(eleList, tag, qr.DPath.VR, ref index, depth + 1, qrList, dr);
                        //eleList.Add(ele);
                        break;
                    }
                    }
                }
                break;
            }

            default:
            {
                string value = null;
                object obj   = dr[qr.TargetField];
                if (obj != null)
                {
                    value = obj.ToString();
                }
                if (value == null)
                {
                    value = "";
                }

                if (DHelper.IsDateTime(qr.DPath.VR))
                {
                    try
                    {
                        if (value.Length > 0)
                        {
                            DateTime dt = DateTime.Parse(value);
                            //DDateTime ddt = DDateTime.FromDateTime(qr.DPath.VR, dt);
                            DicomDateTime ddt = new DicomDateTime(tagIn, dt);
                            //rootSQElement.Value = ddt.ToDicomString();
                            ds.Add(ddt);
                        }
                        else
                        {
                            //rootSQElement.Value = value;
                            ds.Add <string>(tagIn, value);
                        }
                    }
                    catch (Exception err)
                    {
                        //SetError(err);
                        //rootSQElement.Value = value;
                        ds.Add <string>(tagIn, value);
                    }
                }
                else
                {
                    //rootSQElement.Value = value;
                    ds.Add <string>(tagIn, value);
                }


                break;
            }
            }
        }
コード例 #17
0
 public DListViewItem(UInt32 tag, DVR vr)
 {
     _tag = tag;
     _vr  = vr;
 }
コード例 #18
0
 private DDateTime2(DVR dvr, string dcmString)
 {
     vr          = dvr;
     dicomString = dcmString;
     Initialize();
 }
コード例 #19
0
        public static DicomVR ConvertToDicomVR(DVR vr)
        {
            if (vr == DVR.AE)
            {
                return(DicomVR.AE);
            }
            else if (vr == DVR.AS)
            {
                return(DicomVR.AS);
            }
            else if (vr == DVR.AT)
            {
                return(DicomVR.AT);
            }
            else if (vr == DVR.CS)
            {
                return(DicomVR.CS);
            }
            else if (vr == DVR.DA)
            {
                return(DicomVR.DA);
            }
            else if (vr == DVR.DS)
            {
                return(DicomVR.DS);
            }
            else if (vr == DVR.DT)
            {
                return(DicomVR.DT);
            }
            else if (vr == DVR.FD)
            {
                return(DicomVR.FD);
            }
            else if (vr == DVR.FL)
            {
                return(DicomVR.FL);
            }
            else if (vr == DVR.IS)
            {
                return(DicomVR.IS);
            }
            else if (vr == DVR.LO)
            {
                return(DicomVR.LO);
            }
            else if (vr == DVR.LT)
            {
                return(DicomVR.LT);
            }
            else if (vr == DVR.OB)
            {
                return(DicomVR.OB);
            }
            else if (vr == DVR.FD)
            {
                //no
                return(DicomVR.OD);
            }
            else if (vr == DVR.OF)
            {
                return(DicomVR.OF);
            }
            else if (vr == DVR.OW)
            {
                return(DicomVR.OW);
            }
            else if (vr == DVR.PN)
            {
                return(DicomVR.PN);
            }
            else if (vr == DVR.SH)
            {
                return(DicomVR.SH);
            }
            else if (vr == DVR.SL)
            {
                return(DicomVR.SL);
            }
            else if (vr == DVR.SQ)
            {
                return(DicomVR.SQ);
            }
            else if (vr == DVR.SS)
            {
                return(DicomVR.SS);
            }
            else if (vr == DVR.ST)
            {
                return(DicomVR.ST);
            }
            else if (vr == DVR.TM)
            {
                return(DicomVR.TM);
            }
            else if (vr == DVR.Unknown)
            {
                //no
                return(DicomVR.UC);
            }
            else if (vr == DVR.UI)
            {
                return(DicomVR.UI);
            }
            else if (vr == DVR.UL)
            {
                return(DicomVR.UL);
            }
            else if (vr == DVR.UN)
            {
                return(DicomVR.UN);
            }
            else if (vr == DVR.UT)
            {
                //no
                return(DicomVR.UR);
            }
            else if (vr == DVR.US)
            {
                return(DicomVR.US);
            }
            else if (vr == DVR.UT)
            {
                return(DicomVR.UT);
            }

            return(DicomVR.NONE);
        }
コード例 #20
0
 public DElement(int tag, DVR vr)
     : this(tag, vr, DValueType.Unknown)
 {
 }
コード例 #21
0
        /// <summary>
        /// 播放命令操作
        /// </summary>
        /// <param name="tvConfig"></param>
        public void PlayOnTV(TvConfig tvConfig)
        {
            // 处理数据对象,转换为封装的 Camera 等对象
            CameraPanel cameraPanel = new CameraPanel {
                LayoutInfo = tvConfig.LayoutInfo
            };

            if (tvConfig.MonitorInfo != null)
            {
                List <int> indexs = tvConfig.MonitorInfo.Select(t => t.Index).Distinct().ToList();
                foreach (int index in indexs)
                {
                    List <MonitorInfo> monitors  = tvConfig.MonitorInfo.Where(t => t.Index == index).ToList();
                    CameraPanelItem    panelItem = new CameraPanelItem {
                        Index = index, RtspStrs = new List <string>(), RtmpStrs = new List <string>()
                    };
                    if (monitors.Count > 1)
                    {
                        CameraGroup cameraGroup = new CameraGroup
                        {
                            Interval = monitors[0].TimeInterval
                        };
                        foreach (var monitor in monitors)
                        {
                            DVR dvr = new DVR()
                            {
                                IP       = monitor.Ip,
                                Port     = monitor.AdminPort,
                                UserName = monitor.User,
                                Password = monitor.PassWord,
                                Id       = monitor.Id
                            };
                            Camera camera = new Camera
                            {
                                StreamType = monitor.StreamType,
                                DVR        = dvr,
                                Number     = monitor.Channel
                            };
                            cameraGroup.Items.Add(camera);
                            panelItem.RtspStrs.Add(monitor.Rtsp);
                            panelItem.RtmpStrs.Add(monitor.Rtmp);
                        }

                        panelItem.CameraGroup = cameraGroup;
                        panelItem.Flag        = monitors[0].Flag;
                        panelItem.PlayType    = PlayContentType.Group;
                    }
                    else
                    {
                        MonitorInfo monitor = monitors[0];
                        DVR         dvr     = new DVR()
                        {
                            IP       = monitor.Ip,
                            Port     = monitor.AdminPort,
                            UserName = monitor.User,
                            Password = monitor.PassWord,
                            Id       = monitor.Id
                        };

                        Camera camera = new Camera()
                        {
                            DVR        = dvr,
                            StreamType = monitor.StreamType,
                            Number     = monitor.Channel
                        };
                        panelItem.RtspStrs.Add(monitor.Rtsp);
                        panelItem.RtmpStrs.Add(monitor.Rtmp);
                        panelItem.Camera   = camera;
                        panelItem.Flag     = monitor.Flag;
                        panelItem.PlayType = PlayContentType.One;
                    }
                    cameraPanel.Cameras.Add(panelItem);
                }
            }

            gridVideo.SetValue(GridHelpers.CamearPanelProperty, cameraPanel);
        }
コード例 #22
0
ファイル: LPRService.cs プロジェクト: mutita/anpr
        public void Start()
        {
            //////////////////////////////////////
            //
            // start error reporting lib  ( decides if local and/or remote reporting)

            m_AppData.Logger = new ErrorLog(m_AppData);

            m_Log = (ErrorLog)m_AppData.Logger;

            //////////////////////////////////////
            //
            // start email lib (used by error reporting lib for remote error notifications and by the watch list processor)

            m_AppData.EmailServices = new EmailServices(m_AppData);
            m_Email = (EmailServices)m_AppData.EmailServices;



            //////////////////////////////////////
            //
            // load the Frame Generator

            m_AppData.FrameGenerator = (object)new FrameGenerator(m_AppData);


            //////////////////////////////////////
            //
            // load the DVR

            m_DVR         = new DVR(m_AppData);
            m_AppData.DVR = (object)m_DVR;


            //////////////////////////////////////
            //
            // start the TCP Server
            m_RCServer = new RemoteConnectionServer.RemoteConnectionServer(m_AppData);

            //m_TCPServerThread = new Thread(TCPServer);
            //m_TCPServerThread.Start();


            //////////////////////////////////////
            //
            // load the LPR Engine

            m_LPREngine         = new LPREngine(m_AppData);
            m_AppData.LPREngine = m_LPREngine;

            //////////////////////////////////////
            //
            // load the Watch List Processor

            m_WatchList = new WatchLists(m_AppData);


            //  now that all modules are loaded, let them register with each other for event communications
            m_RCServer.StartRegistration();
            m_DVR.StartRegistration();
            m_LPREngine.StartRegistration();
            m_WatchList.StartRegistration();



            // now let all modules start their threads
            m_RCServer.StartThreads();
            m_DVR.StartThreads();
            m_LPREngine.StartThreads();
            m_WatchList.StartThreads();
            m_Email.StartThreads();

            // is everyone happy?
            if (!m_DVR.GetDVRReady || !((FrameGenerator)m_AppData.FrameGenerator).GetReadyStatus)
            {
                m_AppData.SelfDestruct();
            }
        }
コード例 #23
0
        private static DVR Parse0X45_dvr(IEnumerable <byte> arr)
        {
            var dvr = new DVR();

            return(dvr);
        }
コード例 #24
0
        /// <summary>
        /// 播放命令操作
        /// </summary>
        /// <param name="tvConfig"></param>
        public void PlayOnTV(TvConfig tvConfig)
        {
            // 当布局变化时视频信息会变,清楚全部的 CameraPanelItem 信息
            if (tvConfig.LayoutInfo != null)
            {
                this.cameras = new Dictionary <int, CameraPanelItem>();
            }

            // 处理数据对象,转换为封装的 Camera 等对象
            CameraPanel cameraPanel = new CameraPanel {
                LayoutInfo = tvConfig.LayoutInfo
            };

            if (tvConfig.MonitorInfo != null)
            {
                List <int> indexs = tvConfig.MonitorInfo.Select(t => t.Index).Distinct().ToList();
                foreach (int index in indexs)
                {
                    List <MonitorInfo> monitors  = tvConfig.MonitorInfo.Where(t => t.Index == index).ToList();
                    CameraPanelItem    panelItem = new CameraPanelItem {
                        Index = index
                    };
                    if (monitors.Count > 1)
                    {
                        CameraGroup cameraGroup = new CameraGroup
                        {
                            Interval = monitors[0].TimeInterval
                        };
                        foreach (var monitor in monitors)
                        {
                            DVR dvr = new DVR()
                            {
                                IP       = monitor.Ip,
                                Port     = monitor.AdminPort,
                                UserName = monitor.User,
                                Password = monitor.PassWord,
                                Id       = monitor.Id
                            };
                            Camera camera = new Camera
                            {
                                StreamType = monitor.StreamType,
                                DVR        = dvr,
                                Number     = monitor.Channel
                            };
                            cameraGroup.Items.Add(camera);
                        }

                        panelItem.CameraGroup = cameraGroup;
                        panelItem.Flag        = monitors[0].Flag;
                        panelItem.PlayType    = PlayContentType.Group;
                    }
                    else
                    {
                        MonitorInfo monitor = monitors[0];
                        DVR         dvr     = new DVR()
                        {
                            IP       = monitor.Ip,
                            Port     = monitor.AdminPort,
                            UserName = monitor.User,
                            Password = monitor.PassWord,
                            Id       = monitor.Id
                        };

                        Camera camera = new Camera()
                        {
                            DVR        = dvr,
                            StreamType = monitor.StreamType,
                            Number     = monitor.Channel
                        };
                        panelItem.Camera   = camera;
                        panelItem.Flag     = monitor.Flag;
                        panelItem.PlayType = PlayContentType.One;

                        if (monitor.Ip == null && monitor.User == null)
                        {
                            panelItem.Flag = 0;
                        }
                    }
                    cameraPanel.Cameras.Add(panelItem);

                    if (this.cameras.ContainsKey(index))
                    {
                        this.cameras.Remove(index);
                    }
                    this.cameras.Add(index, panelItem);
                }

                // 登录各个设备,为后面播放,
                // 这里再返回赋值,因为每次都需要登录信息,否则失败
                foreach (var item2 in cameraPanel.Cameras)
                {
                    if (item2.Camera != null)
                    {
                        item2.Camera.DVR.Connection(false);
                    }
                    else if (item2.CameraGroup != null)
                    {
                        foreach (var item in item2.CameraGroup.Items)
                        {
                            item.DVR.Connection(false);
                        }
                    }
                }
            }

            this.gridVideo.SetValue(GridHelpers.CamearPanelProperty, cameraPanel);
        }
コード例 #25
0
 public DElement(int groupNumber, int elementNumber, DVR vr)
     : this(groupNumber, elementNumber, vr, DValueType.Unknown)
 {
 }
コード例 #26
0
 public PrivateTag(string tag, DVR vr)
 {
     _tag = tag;
     _vr  = vr;
 }
コード例 #27
0
        private static void FillElement <TR>(DicomDataset ds, DicomTag tagIn, DVR vrIn, ref int index, int depth, XCollection <TR> qrList, DataRow[] drList)
            where TR : QueryResultItem, IDicomMappingItem
        {
            if (drList.Length < 1)
            {
                return;
            }
            DataRow dr = drList[0];

            TR qr = qrList[index] as TR;

            if (!qr.DPath.Enable)
            {
                return;
            }

            if (qr.DPath.VR == DVR.Unknown)
            {
                return;
            }
            else if (qr.DPath.VR == DVR.SQ)
            {
                index++;
                int count = qrList.Count;
                List <DicomDataset> eleListSequence = null;
                bool isProctolCodeSQ = (qr.DPath.GetTag() == Tags.ScheduledProtocolCodeSequence); //0x00400008

                // use this to create a temporary patch to Japan according to requirement of sending multiple items in Requested Procedure Sequence, which is not allow in DICOM standard, 20090403
                //bool isProctolCodeSQ = (qr.DPath.GetTag() == 0x00321064);

                for (; index < count; index++)
                {
                    qr = qrList[index] as TR;
                    switch (qr.DPath.Type)
                    {
                    case DPathType.BeginItem:
                    {
                        eleListSequence = new List <DicomDataset>();
                        if (isProctolCodeSQ)
                        {
                            foreach (DataRow d in drList)
                            {
                                DicomDataset eleList = new DicomDataset();
                                eleListSequence.Add(eleList);
                            }

                            //Program.Log.Write("--- Begin Protocol Code Sequence ---" + eleListSequence.Count.ToString());
                        }
                        else
                        {
                            //Program.Log.Write("--- Begin Sequence ---" + DHelper.GetTagName((uint)rootSQElement.Tag));

                            DicomDataset eleList = new DicomDataset();
                            eleListSequence.Add(eleList);
                        }
                        continue;
                    }

                    case DPathType.EndItem:
                    {
                        if (eleListSequence == null)
                        {
                            continue;
                        }

                        DicomSequence dicomSequence = new DicomSequence(tagIn);
                        if (isProctolCodeSQ)
                        {
                            foreach (DicomDataset eleList in eleListSequence)
                            {
                                dicomSequence.Items.Add(eleList);
                            }

                            //Program.Log.Write("--- End Protocol Code Sequence ---" + rootSQElement.Sequence.Count.ToString());
                        }
                        else
                        {
                            //Program.Log.Write("--- End Sequence ---" + DHelper.GetTagName((uint)rootSQElement.Tag));

                            if (eleListSequence.Count > 0)
                            {
                                dicomSequence.Items.Add(eleListSequence[0]);
                            }
                        }

                        TR qrNext = qrList[index + 1];
                        if (qrNext == null || qrNext.DPath.Type != DPathType.BeginItem)
                        {
                            return;
                        }
                        continue;
                    }

                    default:
                    {
                        if (eleListSequence == null)
                        {
                            continue;
                        }
                        if (!qr.DPath.Enable)
                        {
                            continue;
                        }
                        //int tag = qr.DPath.GetTag(depth + 1);
                        List <string> tagList  = qr.DPath.GetTagGE(depth);
                        ushort        uGroup   = DHelper.HexString2ushort(tagList[0]);
                        ushort        uElement = DHelper.HexString2ushort(tagList[1]);
                        DicomTag      tag      = new DicomTag(uGroup, uElement);
                        if (isProctolCodeSQ)
                        {
                            int beginIndex = index;
                            for (int i = 0; i < eleListSequence.Count; i++)
                            {
                                if (i == 0)
                                {
                                    FillElement <TR>(eleListSequence[i], tag, qr.DPath.VR, ref index, depth + 1, qrList, new DataRow[] { drList[i] });
                                }
                                else
                                {
                                    FillElement <TR>(eleListSequence[i], tag, qr.DPath.VR, ref beginIndex, depth + 1, qrList, new DataRow[] { drList[i] });
                                }

                                //Program.Log.Write("--- Add Protocol Code Sequence Item ---"
                                //    + i.ToString() + "  "
                                //    + DHelper.GetTagName((uint)tag));
                            }
                        }
                        else
                        {
                            //Program.Log.Write("--- Add Sequence Item ---" + DHelper.GetTagName((uint)tag));

                            if (eleListSequence.Count > 0)
                            {
                                FillElement <TR>(eleListSequence[0], tag, qr.DPath.VR, ref index, depth + 1, qrList, drList);
                            }
                        }
                        break;
                    }
                    }
                }
            }
            else
            {
                string value = null;
                object obj   = dr[qr.TargetField];
                if (obj != null)
                {
                    value = obj.ToString();
                }
                if (value == null)
                {
                    value = "";
                }

                ds.Add(tagIn, value);
            }
        }