public static LightTx MapTx(CachedTx tx)
        {
            LightTx lightTx = new LightTx();

            lightTx.publicKey = tx.publicKey;
            lightTx.hash      = tx.hash;
            lightTx.height    = tx.height;
            //map outputs
            lightTx.outputs = new List <LightOutput>();
            if (tx.outputs != null)
            {
                foreach (var outp in tx.outputs)
                {
                    var lightOutput = new LightOutput();
                    lightOutput.key = outp.key;
                    lightTx.outputs.Add(lightOutput);
                }
            }
            return(lightTx);
        }
Example #2
0
            //更新标签数值
            public void UpdateLabels()
            {
                GameObject CurrentLabel;
                float      Illumination = 0;
                //各种照度计数
                int TotalCount = 0;
                int CountPart1 = 0;
                int CountPart2 = 0;

                DaylightFactorMean = 0;
                illuminationMean   = 0;
                DaylightFactorMin  = 15000;
                float Factor = 0;
                int   count  = 0;

                //网络
                for (int i = 0; i < RowCount; i++)
                {
                    for (int j = 0; j < ColumnCount; j++)
                    {
                        Factor       = 0;                  //采光系数
                        Illumination = 0;                  //照度值
                        CurrentLabel = Labels [i * ColumnCount + j];
                        for (int Index = 0; Index < sideWindowsCount; Index++)
                        {
                            Factor = Factor + LightOutput.GetPointDaylightFactor(CurrentLabel.transform.position, sideWindowPositionArray [Index], sideWindowWidthArray [Index], sideWindowHeightArray [Index]);
                        }
                        //for (int Index = 0; Index < skylightsCount; Index++)
                        //{
                        //    Factor = Factor + LightOutput.GetSkylightPointFactor2(CurrentLabel.transform.position, skylightPositionArray[Index], skylightWidthArray[Index], skylightHeightArray[Index]);
                        //}
                        for (int Index = 0; Index < LampCount; Index++)
                        {
                            //LampIntensity的数组是不对的,因为shader限制除了一个室外照度来模仿采光系数,需要乘以室外照度
                            Illumination += LightOutput.GetPointIllumination(CurrentLabel.transform.position, LampPositionArray [Index], LampAngleArray [Index], LampIntensity [Index] * LightOutput.OutdoorIllumination, LampSpotAngle [Index], 'y');
                        }

                        Illumination += Factor * LightOutput.OutdoorIllumination;                        //总照度等于灯的照度加上采光照度
                        count++;
                        //DaylightFactorMean = 0.5f * (DaylightFactorMean + Factor);//计算平均采光系数
                        DaylightFactorMean = DaylightFactorMean + (Factor - DaylightFactorMean) / count;
                        //illuminationMean = 0.5f * (illuminationMean + Illumination);//计算平均照度
                        illuminationMean = illuminationMean + (Illumination - illuminationMean) / count;
                        if (Factor < DaylightFactorMin)
                        {
                            DaylightFactorMin = Factor;                            //计算最小照度
                        }

                        //计算各个部分占的百分比
                        TotalCount++;
                        if (Illumination < 200)
                        {
                            CountPart1++;
                        }
                        else if (Illumination < 500)
                        {
                            CountPart2++;
                        }
                        if (firstMode)
                        {
                            CurrentLabel.GetComponentInChildren <Text>().text = ((int)Illumination).ToString();
                        }
                        else
                        {
                            CurrentLabel.GetComponentInChildren <Text>().text = Factor.ToString("#0.##");
                        }
                    }
                }

                PercentPart1 = CountPart1 * 1.0f / TotalCount * 100;
                PercentPart2 = CountPart2 * 1.0f / TotalCount * 100;

                Illumination = 0;
                //折线图
                //dataOutput.ClearStaticGragh ();
                //chartUpdate.ClearStaticGragh ();//清空第二张折线图
                //for (int j = 0; j < sideWindowsCount; j++) {
                //	for (int i = 0; i < 25; i++) {
                //		Factor = 0;
                //		for (int Index = 0; Index < sideWindowsCount; Index++) {
                //			Factor = Factor + LightOutput.GetPointDaylightFactor (new Vector3 (sideWindowPositionArray [j].x, firstPosition.y, firstPosition.z) + new Vector3 (0, 0, i * StepLength), sideWindowPositionArray [Index], sideWindowWidthArray [Index], sideWindowHeightArray [Index]);
                //		}
                //		//for (int Index = 0; Index < skylightsCount; Index++)
                //		//{
                //		//    Factor = Factor + LightOutput.GetSkylightPointFactor2(new Vector3(sideWindowPositionArray[j].x, firstPosition.y, firstPosition.z) + new Vector3(0, 0, i * StepLength), skylightPositionArray[Index], skylightWidthArray[Index], skylightHeightArray[Index]);
                //		//}
                //		for (int Index = 0; Index < LampCount; Index++) {
                //			Illumination += LightOutput.GetPointIllumination (new Vector3 (sideWindowPositionArray [j].x, firstPosition.y, firstPosition.z) + new Vector3 (0, 0, i * StepLength), LampPositionArray [Index] * LightOutput.OutdoorIllumination, LampAngleArray [Index], LampIntensity [Index], LampSpotAngle [Index], 'y');
                //		}
                //		Illumination = Factor * LightOutput.OutdoorIllumination;
                //		StaticGraphValues [i] = (int)Illumination;
                //	}
                //	//dataOutput.OutputStaticGragh (StaticGraphValues, (j + 1).ToString ());
                //	//chartUpdate.OutputStaticGragh (StaticGraphValues, (j + 1).ToString ()); ;//更新第二张折线图
                //}
            }