private void RenderModel(SmModel model, Vector3 position, Vector3 rotation, Vector3 scale, bool selected, int modelLocation, int colorLocation) { // Get the position and rotation of the object Matrix4 positionMat = Matrix4.CreateTranslation(position); Matrix4 rotXMat = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(rotation.X)); Matrix4 rotYMat = Matrix4.CreateRotationY(MathHelper.DegreesToRadians(rotation.Y)); Matrix4 rotZMat = Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(rotation.Z)); Matrix4 scaleMat = Matrix4.CreateScale(scale); Matrix4 finalMat = scaleMat * (rotXMat * rotYMat * rotZMat) * positionMat; // Set the position in the shader GL.UniformMatrix4(modelLocation, false, ref finalMat); // Render filled triangles GL.Uniform4(colorLocation, whiteColor); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); GL.Enable(EnableCap.PolygonOffsetFill); GL.PolygonOffset(1, 1); model.Render(); // Render outlined triangles GL.Disable(EnableCap.PolygonOffsetFill); GL.Uniform4(colorLocation, blackColor); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); GL.Enable(EnableCap.PolygonOffsetLine); GL.PolygonOffset(-1, -1); model.Render(); // Check if this is the currently selected object if (selected) { // Render the bounding box GL.Uniform4(colorLocation, blueColor); GL.LineWidth(3.0f); model.boundingBox.Render(); } GL.Disable(EnableCap.PolygonOffsetLine); GL.LineWidth(1.0f); }
/// <summary> /// 处理参数包,将底层的包转成上层需要的Cpm /// </summary> /// <param name="machineCode">参数所属机台</param> /// <param name="sm">单个参数数据包,一个数据包含多个 Cpm</param> /// <param name="ip"></param> void updateMachieCpms(string machineCode, SmModel sm, string ip) { var cpmsDirect = Cpm.ConvertBySmModel(machineCode, sm, ip); var cpms = new List <Cpm>(); IDictionary <int, Cpm> updatedCpmsDiffDict = new Dictionary <int, Cpm>(); //计算出功率因数、最大值、最小值,这些参数 var cpmsRelate = getRelateCpm(machineCode, ip, cpmsDirect); if (cpmsDirect != null) { cpms.AddRange(cpmsDirect); cpms.AddRange(cpmsRelate); } var pickTime = DateTime.Now; foreach (var cpm in cpms) { if (OnlineCpmDict[machineCode].TryGetValue(cpm.Code, out var storeCpm)) { //Rfid 数据是在 DMesCore 更新 if (!DefinedParamCode.IsRfidParam(cpm.Code)) { storeCpm.Update(cpm.Value, cpm.ValueType, pickTime); } } else { Logger.Error($"参数 {cpm.Code} 未注册", 36000); } } //差异更新,使用linq 2017-11-13 (from c in cpms where ( (c.Value != null && !string.IsNullOrEmpty(c.Value?.ToString())) && (!OnlineCpmDict[machineCode].ContainsKey(c.Code) || OnlineCpmDict[machineCode][c.Code].Value.ToString() != c.Value.ToString()) ) select c ).ForEach(cpm => { cpm.PickTime = pickTime; updatedCpmsDiffDict[cpm.Code] = cpm; }); //一定要先派遣所有更新,再派遣部分更新 //这样就保证了reducer里面数据的唯一性 if (cpms.Count > 0) { App.Store.Dispatch(new CpmActions.CpmUpdatedAll(machineCode, cpms)); dispatchLogicSetting(machineCode, cpms); } //所有变化的参数 if (updatedCpmsDiffDict.Count > 0) { var diffCpms = updatedCpmsDiffDict.Values.ToList(); App.Store.Dispatch(new CpmActions.CpmUpdateDiff(machineCode, updatedCpmsDiffDict)); dispatchDiffLogicSetting(machineCode, diffCpms); } //检查Mq的Bom表数据报警 dispatchCheckBomAlarm(machineCode, cpms); //检查Plc上下限报警 dispatchCheckPlcAlarm(machineCode, cpms); }