Пример #1
0
        private void WriteToFile(ProbeData probeData)
        {
            string filePath;

            switch (probeData.ProbeName)
            {
            case "Probe_1":
                //filePath = @"/home/tim/Documents/Programming/RabbitMQ/Worker/probe1.txt";
                filePath = @"C:\repos\RabbitMqEntityFrameworkTest\probe1.txt";
                break;

            case "Probe_2":
                //filePath = @"/home/tim/Documents/Programming/RabbitMQ/Worker/probe2.txt";
                filePath = @"C:\repos\RabbitMqEntityFrameworkTest\probe2.txt";
                break;

            default:
                //filePath = @"/home/tim/Documents/Programming/RabbitMQ/Worker/otherProbe1.txt";
                filePath = @"C:\repos\RabbitMqEntityFrameworkTest\otherProbe.txt";
                break;
            }

            var entry = $"{probeData.Time.ToString()}, {probeData.Temperature}";

            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(filePath, true))
            {
                file.WriteLine(entry);
            }
        }
        internal static LoadBalancerProbeListResult DeserializeLoadBalancerProbeListResult(JsonElement element)
        {
            Optional <IReadOnlyList <ProbeData> > value = default;
            Optional <string> nextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ProbeData> array = new List <ProbeData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ProbeData.DeserializeProbeData(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new LoadBalancerProbeListResult(Optional.ToList(value), nextLink.Value));
        }
Пример #3
0
    NXOpen.BlockStyler.Node AddNode(ProbeData data)
    {
        var node = tree_control0.CreateNode(data.ProbeName);

        node.GetNodeData().AddString(_propertyName, Newtonsoft.Json.JsonConvert.SerializeObject(data));
        tree_control0.InsertNode(node, null, null, NXOpen.BlockStyler.Tree.NodeInsertOption.AlwaysLast);
        return(node);
    }
Пример #4
0
 public ProbeDataReadingService(IProbeDataParsingService probeDataParsingService, ISerialPortConnectionService serialPortConnectionService)
 {
     this._probeDataParsingService     = probeDataParsingService;
     this._serialPortConnectionService = serialPortConnectionService;
     this._priorityMessageQueue        = new Queue <string>();
     this._readTriggeredData           = false;
     this._currentlyConnected          = false;
     this._probeData = new ProbeData();
 }
Пример #5
0
    /// <summary>
    /// 删除探针
    /// </summary>
    void DeleteProbe(ProbeData data)
    {
        var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CMM_INSPECTION", data.ProbeName);

        if (File.Exists(fileName + ".prt"))
        {
            File.Delete(fileName + ".prt");
        }
    }
Пример #6
0
 /// <summary>
 /// 是否小于探针半径
 /// </summary>
 static bool IsLessthanProbeR(List <Snap.NX.Curve> curves, Snap.Position p, ProbeData probe)
 {
     foreach (var item in curves)
     {
         var d = Compute.Distance(p, item);
         if (d <= probe.D / 2)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #7
0
    ProbeData GetProbeData()
    {
        ProbeData data = new ProbeData();

        data.ProbeName          = strProbeName.Value;
        data.SphereRadius       = expSphereRadius.Value;
        data.ArrowRadius        = expArrowRadius.Value;
        data.ArrowLength        = expArrowLength.Value;
        data.ExtensionBarRadius = expExtensionBarRadius.Value;
        data.ExtensionBarLength = expExtensionBarLength.Value;
        data.HeadRadius         = expHeadRadius.Value;
        data.HeadLength         = expHeadLength.Value;
        data.ProbeAB            = strProbeAB.GetValue().FirstOrDefault();
        return(data);
    }
Пример #8
0
        public void ProcessMessage(string message)
        {
            var probe = message.Substring(0, 7);
            var value = message.Substring(8);

            var time = DateTime.Now;

            var data = new ProbeData
            {
                ProbeName   = probe,
                Time        = time,
                Temperature = value
            };

            _context.ProbeData.Add(data);

            WriteToFile(data);

            _context.SaveChanges();
        }
        public static DeviceConfiguration Create(ProbeData probeData)
        {
            if (probeData != null && probeData.Device != null)
            {
                var table = new DataTable();
                table.Columns.Add("address");
                table.Columns.Add("name");
                table.Columns.Add("value");
                table.Columns.Add("attributes");

                var items = probeData.Device.GetAllDataItems();

                SetIds(table);
                SetEnabled(table);
                Description.Add(table, probeData.Device);
                Agent.Add(table, probeData.Address, probeData.Port, probeData.Device.Name);
                GeneratedEvents.DeviceStatus.Add(table, items);
                GeneratedEvents.ProductionStatus.Add(table, items);
                GeneratedEvents.CycleExecution.Add(table, items);
                GeneratedEvents.PartsCount.Add(table, items);
                Cycles.Add(table, items);
                Parts.Add(table, items);
                Overrides.Add(table, items);
                Oee.Add(table, items);

                // Manufacturer Specific Processing
                Manufacturers.Okuma.Process(table, probeData.Device);

                //var xml = Converters.DeviceConfigurationConverter.TableToXML(dt);
                var xml = DeviceConfiguration.TableToXml(table);

                return DeviceConfiguration.Read(xml);
            }

            return null;
        }
        public static DeviceConfiguration Create(ProbeData probeData)
        {
            if (probeData != null && probeData.Device != null)
            {
                var table = new DataTable();
                table.Columns.Add("address");
                table.Columns.Add("name");
                table.Columns.Add("value");
                table.Columns.Add("attributes");

                var items = probeData.Device.GetAllDataItems();

                SetIds(table);
                SetEnabled(table);
                Description.Add(table, probeData.Device);
                Agent.Add(table, probeData.Address, probeData.Port, probeData.Device.Name);
                GeneratedEvents.DeviceStatus.Add(table, items);
                GeneratedEvents.ProductionStatus.Add(table, items);
                GeneratedEvents.CycleExecution.Add(table, items);
                GeneratedEvents.PartsCount.Add(table, items);
                Cycles.Add(table, items);
                Parts.Add(table, items);
                Overrides.Add(table, items);
                Oee.Add(table, items);

                // Manufacturer Specific Processing
                Manufacturers.Okuma.Process(table, probeData.Device);

                //var xml = Converters.DeviceConfigurationConverter.TableToXML(dt);
                var xml = DeviceConfiguration.TableToXml(table);

                return(DeviceConfiguration.Read(xml));
            }

            return(null);
        }
        public ProbeData GetOrCreateMachine(string computerName, string domainName)
        {
            var result = _Context.ProbeData.SingleOrDefault(m => m.MachineName.ToLower() == computerName.ToLower() && m.DomainName.ToLower() == domainName.ToLower());

            if (result != null)
            {
                return(result);
            }

            var now  = DateTime.UtcNow;
            var data = new ProbeData()
            {
                MachineName = computerName,
                DomainName  = domainName,
                CreatedOn   = now,
                UpdatedOn   = now
            };

            _Context.ProbeData.Add(data);

            _Context.SaveChanges();

            return(data);
        }
Пример #12
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting up....");
            var config = new ConfigurationBuilder().AddJsonFile("appsettings.json", optional: false).Build();

            config.GetSection("DBConnection").Bind(_DBSettings);

            _DBSettings.ConnectionString = _DBSettings.ConnectionString.Replace(".\\", @".\");

            _Context          = new ProbeContext(_DBSettings.ConnectionString);
            _AssetDataService = new AssetServiceDataService(_Context);

            _MachineData = _AssetDataService.GetOrCreateMachine(Environment.MachineName, Environment.UserDomainName);


            GetOS();
            GetProcessors();
            GetIPs();
            GetHardDriveData();
            GetGPUs();
            GetNICs();
            GetPrinters();
            GetSoftware();
        }
Пример #13
0
        public void AllocateProbes(Vector3Int dimension, Transform probeVolume)
        {
            ProbeVolumeDimension = dimension;
            int destCount = dimension.x * dimension.y * dimension.z;
            int origCount = Probes.Count();

            if (dimension.x > 0 && dimension.y > 0 && dimension.z > 0)
            {
                needRender = true;
                //Probes.Clear();
                if (destCount < origCount)
                {
                    Probes.Clear();
                    DebugSpheres.Clear();
                    Probes.Capacity       = destCount;
                    DebugSpheres.Capacity = destCount;
                }

                if (destCount != origCount)
                {
                    if (radianceCubeArray != null)
                    {
                        radianceCubeArray.Release();
                        radianceCubeArray = null;
                    }

                    if (probeDepth != null)
                    {
                        probeDepth.Release();
                        probeDepth = null;
                    }

                    if (normalMapArray != null)
                    {
                        normalMapArray.Release();
                        normalMapArray = null;
                    }

                    if (depthMapArray != null)
                    {
                        depthMapArray.Release();
                        depthMapArray = null;
                    }

                    RenderTextureDescriptor radCubeArrayDesc = new RenderTextureDescriptor(PROBE_RES, PROBE_RES, RenderTextureFormat.RGB111110Float);
                    radCubeArrayDesc.dimension   = TextureDimension.CubeArray;
                    radCubeArrayDesc.volumeDepth = destCount * 6;
                    radianceCubeArray            = new RenderTexture(radCubeArrayDesc);

                    RenderTextureDescriptor normCubeArrayDesc = new RenderTextureDescriptor(PROBE_RES, PROBE_RES, RenderTextureFormat.RGB111110Float);
                    normCubeArrayDesc.dimension   = TextureDimension.CubeArray;
                    normCubeArrayDesc.volumeDepth = destCount * 6;
                    normalMapArray = new RenderTexture(normCubeArrayDesc);

                    RenderTextureDescriptor dephtArrayDesc = new RenderTextureDescriptor(PROBE_RES, PROBE_RES, RenderTextureFormat.RHalf);
                    dephtArrayDesc.dimension   = TextureDimension.CubeArray;
                    dephtArrayDesc.volumeDepth = destCount * 6;
                    depthMapArray = new RenderTexture(dephtArrayDesc);

                    RenderTextureDescriptor depthDesc = new RenderTextureDescriptor(PROBE_RES, PROBE_RES, RenderTextureFormat.Depth);
                    depthDesc.dimension   = TextureDimension.CubeArray;
                    depthDesc.volumeDepth = 6 * destCount;
                    probeDepth            = new RenderTexture(depthDesc);

                    if (radianceMapOctan != null)
                    {
                        radianceMapOctan.Release();
                        radianceMapOctan = null;
                    }

                    if (normalMapOctan != null)
                    {
                        normalMapOctan.Release();
                        normalMapOctan = null;
                    }

                    if (depthMapOctan != null)
                    {
                        depthMapOctan.Release();
                        depthMapOctan = null;
                    }

                    RenderTextureDescriptor radianceMapOctanDesc = new RenderTextureDescriptor(PROBE_RES, PROBE_RES, RenderTextureFormat.RGB111110Float);
                    radianceMapOctanDesc.dimension         = TextureDimension.Tex2DArray;
                    radianceMapOctanDesc.volumeDepth       = destCount;
                    radianceMapOctanDesc.enableRandomWrite = true;
                    radianceMapOctan = new RenderTexture(radianceMapOctanDesc);
                    radianceMapOctan.Create();

                    RenderTextureDescriptor normalMapOctanDesc = new RenderTextureDescriptor(PROBE_RES, PROBE_RES, RenderTextureFormat.RGB111110Float);
                    normalMapOctanDesc.dimension         = TextureDimension.Tex2DArray;
                    normalMapOctanDesc.volumeDepth       = destCount;
                    normalMapOctanDesc.enableRandomWrite = true;
                    normalMapOctan = new RenderTexture(normalMapOctanDesc);
                    normalMapOctan.Create();

                    RenderTextureDescriptor depthMapOctanDesc = new RenderTextureDescriptor(PROBE_RES, PROBE_RES, RenderTextureFormat.RHalf);
                    depthMapOctanDesc.dimension         = TextureDimension.Tex2DArray;
                    depthMapOctanDesc.volumeDepth       = destCount;
                    depthMapOctanDesc.enableRandomWrite = true;
                    depthMapOctan = new RenderTexture(depthMapOctanDesc);
                    depthMapOctan.Create();

                    if (depthMapMinMipOctan != null)
                    {
                        depthMapMinMipOctan.Release();
                        depthMapMinMipOctan = null;
                    }

                    RenderTextureDescriptor depthMapMinMipOctanDesc = new RenderTextureDescriptor(PROBE_RES / MIP_SIZE, PROBE_RES / MIP_SIZE, RenderTextureFormat.RHalf);
                    depthMapMinMipOctanDesc.dimension         = TextureDimension.Tex2DArray;
                    depthMapMinMipOctanDesc.volumeDepth       = destCount;
                    depthMapMinMipOctanDesc.enableRandomWrite = true;
                    depthMapMinMipOctan = new RenderTexture(depthMapMinMipOctanDesc);
                    depthMapMinMipOctan.Create();
                }

                for (int i = 0; i < dimension.x; i++)
                {
                    for (int j = 0; j < dimension.y; j++)
                    {
                        for (int k = 0; k < dimension.z; k++)
                        {
                            int     index = i * dimension.y * dimension.z + j * dimension.z + k;
                            Vector3 coord = new Vector3((float)i / (dimension.x - 1) - 0.5f, (float)j / (dimension.y - 1) - 0.5f, (float)k / (dimension.z - 1) - 0.5f);
                            coord = probeVolume.localToWorldMatrix.MultiplyPoint(coord);
                            if (index >= origCount)
                            {
                                Probe newProbe = new Probe(coord, new Vector4(i, j, k, 0));
                                Probes.Add(newProbe);
                                GameObject   debugSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                                MeshRenderer mesh        = debugSphere.GetComponent <MeshRenderer>();
                                if (mesh)
                                {
                                    Material probeMat = new Material(ProbeDebugShader);
                                    probeMat.SetFloat("_DebugProbeID", index);
                                    mesh.sharedMaterial = probeMat;
                                }
                                debugSphere.SetActive(showDebug);
                                debugSphere.transform.position = coord;
                                DebugSpheres.Add(debugSphere);
                            }
                            else
                            {
                                Probes[index].position = coord;
                                Probes[index].probeID  = new Vector4(i, j, k, 0);
                                if (DebugSpheres.Count < i + 1)
                                {
                                    DebugSpheres.Add(GameObject.CreatePrimitive(PrimitiveType.Sphere));
                                }
                                else if (DebugSpheres[index] == null)
                                {
                                    DebugSpheres[index] = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                                }

                                MeshRenderer mesh = DebugSpheres[i].GetComponent <MeshRenderer>();
                                if (mesh)
                                {
                                    Material probeMat = mesh.sharedMaterial;
                                    if (probeMat.shader.name != "Unlit/GI_ProbeDebug")
                                    {
                                        probeMat = new Material(ProbeDebugShader);
                                    }

                                    probeMat.SetFloat("_DebugProbeID", index);
                                    mesh.sharedMaterial = probeMat;
                                }

                                DebugSpheres[index].transform.position = coord;
                                DebugSpheres[index].SetActive(showDebug);
                            }
                        }
                    }
                }

                ProbeDatas.Clear();
                for (int i = 0; i < Probes.Count; i++)
                {
                    ProbeData pData = new ProbeData()
                    {
                        position    = Probes[i].position,
                        probeID     = Probes[i].probeID,
                        scaleOffset = Probes[i].scaleOffset
                    };
                    ProbeDatas.Add(pData);
                }

                CoreUtils.SafeRelease(ProbeDataBuffer);
                ProbeDataBuffer = new ComputeBuffer(Probes.Count, System.Runtime.InteropServices.Marshal.SizeOf(typeof(ProbeData)));
                ProbeDataBuffer.SetData(ProbeDatas);
            }
            else
            {
                UnityEngine.Debug.LogError("Probe count must be greater than 1 in every dimension.");
            }
        }
Пример #14
0
    /// <summary>
    /// 创建探针模型
    /// </summary>
    bool CreateProbe(ProbeData data)
    {
        bool result = true;
        var  mark   = Globals.SetUndoMark(Globals.MarkVisibility.Visible, "IsIntervene");

        try
        {
            Snap.NX.CoordinateSystem wcs = Globals.WorkPart.NXOpenPart.WCS.CoordinateSystem;
            var vector   = wcs.AxisZ;
            var position = new Snap.Position(0, 0, data.SphereRadius);
            //创建探球
            var body = Snap.Create.Sphere(position, data.SphereRadius * 2).Body;
            body.IsHidden = true;
            body.Faces.ToList().ForEach(u =>
            {
                u.Name = SnapEx.ConstString.CMM_INSPECTION_SPHERE;
            });
            //创建测针
            var body1 = Snap.Create.Cylinder(position, position + (data.ArrowLength * vector), data.ArrowRadius * 2).Body;
            body1.IsHidden = true;
            position       = position + (data.ArrowLength * vector);
            //创建加长杆
            var body2 = Snap.Create.Cylinder(position, position + (data.ExtensionBarLength * vector), data.ExtensionBarRadius * 2).Body;
            body2.IsHidden = true;
            //创建测头
            position = position + (data.ExtensionBarLength * vector);
            var body3 = Snap.Create.Cylinder(position, position + (data.HeadLength * vector), data.HeadRadius * 2).Body;
            body3.IsHidden = true;
            body3.Faces.ToList().ForEach(u =>
            {
                if (SnapEx.Helper.Equals(u.GetFaceDirection(), vector) && u.ObjectSubType == Snap.NX.ObjectTypes.SubType.FacePlane)
                {
                    u.Name = SnapEx.ConstString.CMM_INSPECTION_AXISPOINT;
                }
            });
            var r = Snap.Create.Unite(body, body1, body2, body3);
            r.Orphan();

            body.Name = data.ProbeName;

            var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CMM_INSPECTION", data.ProbeName);
            if (File.Exists(fileName + ".prt"))
            {
                File.Delete(fileName + ".prt");
            }
            var dir = Path.GetDirectoryName(fileName);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            SnapEx.Create.ExtractBody(new List <NXOpen.Body> {
                body
            }, fileName, false, true);
        }
        catch (Exception ex)
        {
            theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, ex.Message);
            result = false;
        }
        Globals.UndoToMark(mark, null);
        return(result);
    }
Пример #15
0
        public string GetProbes(
            string srcIP     = null,
            string dstIP     = null,
            string startTime = null,
            string endTime   = null,
            string type      = null,
            string rate      = null)
        {
            var query = "SELECT * FROM PROBEDB.csv";
            var opts  = new List <string>();

            //check each query parameter
            if (srcIP != null)
            {
                //pull back query with a particular srcIP
                opts.Add("srcIP=" + srcIP);
            }

            if (dstIP != null)
            {
                //pull  back query with a particular dstIP
                opts.Add("dstIP=" + dstIP);
            }

            if (startTime != null)
            {
                //get records that are greater than this time
                opts.Add("startTime > " + startTime);
            }

            if (endTime != null)
            {
                //get records that are less than this time
                opts.Add("endTime < " + endTime);
            }

            if (type != null)
            {
                //get records that are of this type
                //type of probing, horizontal, vertical or strobed
                opts.Add("type=" + type);
            }

            if (rate != null)
            {
                if (rate.Contains('>'))
                {
                    var r = rate.Remove('>');
                    opts.Add("rate > " + r);
                }
                else if (rate.Contains('<'))
                {
                    var r = rate.Remove('<');
                    opts.Add("rate < " + r);
                }
                else
                {
                    opts.Add("rate=" + rate);
                }
                //rate : packets/second of the events
            }

            //Combine all the query conditions
            if (opts.Count > 0)
            {
                query += " WHERE " + string.Join(" AND ", opts.ToArray());
            }

            //run the query against a csv database of results
            string strConn = @"Driver={Microsoft Text Driver (*.txt; *.csv)};" +
                             "Dbq=C:;Extensions=csv,txt";

            OdbcConnection objCSV = new OdbcConnection(strConn);

            objCSV.Open();

            OdbcCommand    oCmd = new OdbcCommand(query, objCSV);
            OdbcDataReader oDR  = oCmd.ExecuteReader();

            var probes = new List <ProbeData>();

            while (oDR.Read())
            {
                //convert the readof the csv file into
                //json objects
                var data = new ProbeData();
                for (int i = 0; i < oDR.FieldCount; i++)
                {
                    switch (oDR.GetName(i))
                    {
                    case "srcIP": data.srcIP = oDR.GetValue(i).ToString();
                        break;

                    case "dstIP": data.dstIP = oDR.GetValue(i).ToString();
                        break;

                    case "startTime":
                        data.startTime = oDR.GetValue(i).ToString();
                        break;

                    case "endTime":
                        data.endTime = oDR.GetValue(i).ToString();
                        break;

                    case "type":
                        data.type = oDR.GetValue(i).ToString();
                        break;

                    case "rate":
                        data.rate = oDR.GetValue(i).ToString();
                        break;

                    default:
                        break;
                    }
                }

                probes.Add(data);
            }

            return(Newtonsoft.Json.JsonConvert.SerializeObject(probes, Newtonsoft.Json.Formatting.Indented));
        }
 void Format(ProbeData data, ref StringBuilder builder) =>
 builder.AppendLine($"\t\t{data.PropertyName} => {data.PropertyValue}");
Пример #17
0
 public ProbeDataViewModel(ISourceConfigViewModelBase sourceConfig, ProbeData probeData)
 {
     this._sourceConfig         = sourceConfig;
     this._probeData            = probeData;
     probeData.PropertyChanged += OnProbeDataChanged;
 }