public HexPixel() { powVal = 0.0; recomentPow = 0.0; marker = 0.0; markerType = MT.None; }
/// <summary> /// Initializes a random number engine based on the selected type. /// /// To switch engines, a new object will have to be created. In practice /// this can be handled automatically just by changing the engine type enum. /// </summary> /// <param name="engine"></param> public RandomNumber(RandomNumberEngine engine) { switch( engine ) { case RandomNumberEngine.RANDOM_DOTNET_BUILTIN: _netEngine = new Random(); break; case RandomNumberEngine.RANDOM_R250_521: _r250521Engine = new R250_521(); break; case RandomNumberEngine.RANDOM_MERSENNE_TWISTER: _mtEngine = new MT(); break; default: throw new IndexOutOfRangeException( "RandomNumber(): Bad random number generator setting"); } _engine = engine; }
/// <summary> /// Consumer-producer based multithreading work distribution /// Each thread waits for a new Assignment to be added to availableAssignments queue /// Most of the time is number of items in availableAssignments expected to be several times larger than number of threads /// </summary> private new void Consume() { MT.InitThreadData(); while (!finished || !availableAssignments.IsEmpty) { availableAssignments.TryDequeue(out Assignment newAssignment); if (newAssignment == null) // TryDequeue was not succesfull { continue; } lock ( consoleLock ) { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine(@"Start of rendering of assignment [{0}, {1}, {2}, {3}]", newAssignment.x1, newAssignment.y1, newAssignment.x2, newAssignment.y2); } float[] colorArray = newAssignment.Render(true, renderer); lock ( consoleLock ) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(@"Rendering of assignment [{0}, {1}, {2}, {3}] finished. Sending result to server.", newAssignment.x1, newAssignment.y1, newAssignment.x2, newAssignment.y2); } SendRenderedImage(colorArray, newAssignment.x1, newAssignment.y1); lock ( consoleLock ) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(@"Result of assignment [{0}, {1}, {2}, {3}] sent.", newAssignment.x1, newAssignment.y1, newAssignment.x2, newAssignment.y2); } } }
public static void PowerMatrix(float[][] matrix, double exp) { if (exp == 1.0) { return; } if (exp == 0.0) { foreach (var R in matrix) { for (int j = 0; j < R.Length; j++) { R[j] = 1.0f; } } return; } MT.ForEach(matrix, R => { for (int j = 0; j < R.Length; j++) { R[j] = (float)Math.Pow(R[j], exp); } }); }
public List <string> Expression(List <string> selectedIds, double threshold) { const short maxExprIndex = 13; // number of expressed levels. const short indexShift = 38; double[][] M = (double[][])(NumTable.Matrix); int cellNr = NumTable.Rows; int geneNr = NumTable.Columns; IList <int> selectedCells = NumTable.IndexOfRows(selectedIds); IList <int> selectedGenes = NumTable.IndexOfColumns(selectedIds); List <string> expressedId = new List <string>(); if (threshold == 0) // mark the genes/cells which have higher expression than the average of selected genes/cells. { if (GeneToCell) // Finding expressed cells for selected genes. Gene->Cell operation. { double[] expression = new double[cellNr]; // total expression of each cell. MT.Loop(0, cellNr, row => { foreach (int col in selectedGenes) { expression[row] += M[row][col]; } }); double meanExp = expression.Sum() / cellNr; double maxExp = expression.Max(); double step = (maxExp - meanExp) / maxExprIndex; this.Genes = selectedGenes.Count; this.Cells = 0; for (int i = 0; i < cellNr; i++) // for each cells. { double delta = expression[i] - meanExp; int bIdx = row2bodyIdx[i]; if (delta > 0) { short v = Math.Min(maxExprIndex, (short)(delta / step)); BodyList[bIdx].Type = (short)(indexShift + v); this.Cells++; expressedId.Add(BodyList[bIdx].Id); } else { BodyList[bIdx].Type = OrgBodies[bIdx].Type; } } } else { double[] expression = new double[geneNr]; // total expression of each gene. MT.Loop(0, geneNr, col => { foreach (int row in selectedCells) { expression[col] += M[row][col]; } }); double meanExp = expression.Sum() / geneNr; double maxExp = expression.Max(); double step = (maxExp - meanExp) / maxExprIndex; // Finding expressed genes for selected cells. Cell->Gene operation. this.Cells = selectedCells.Count; this.Genes = 0; for (int i = 0; i < geneNr; i++) // for each gene. { double delta = expression[i] - meanExp; int bIdx = col2bodyIdx[i]; if (delta > 0) { int v = Math.Min(maxExprIndex, (int)(delta / step)); BodyList[bIdx].Type = (short)(indexShift + v); this.Genes++; expressedId.Add(BodyList[bIdx].Id); } else { BodyList[bIdx].Type = OrgBodies[bIdx].Type; } } } } else // Mark all those cells/genes which have above global average expressions. { if (GeneToCell) { short[] expressed = new short[cellNr]; // count of expressed genes for each cell. MT.Loop(0, cellNr, row => { foreach (int col in selectedGenes) { if (M[row][col] > threshold) { expressed[row] += 1; } } }); this.Genes = selectedGenes.Count; this.Cells = expressed.Count(v => v > 0); for (int i = 0; i < cellNr; i++) { short v = Math.Min(maxExprIndex, expressed[i]); int bIdx = row2bodyIdx[i]; BodyList[bIdx].Type = (short)((v > 0) ? (indexShift + v) : OrgBodies[bIdx].Type); if (v > 0) { expressedId.Add(BodyList[bIdx].Id); } } } else { short[] expressed = new short[geneNr]; // count of expressed cells for each gene. MT.Loop(0, geneNr, col => { foreach (int row in selectedCells) { if (M[row][col] > threshold) { expressed[col] += 1; } } }); this.Cells = selectedCells.Count; this.Genes = expressed.Count(v => v > 0); for (int i = 0; i < geneNr; i++) { short v = Math.Min(maxExprIndex, expressed[i]); int bIdx = col2bodyIdx[i]; BodyList[bIdx].Type = (short)((v > 0) ? (indexShift + v) : OrgBodies[bIdx].Type); if (v > 0) { expressedId.Add(BodyList[bIdx].Id); } } } } return(expressedId); }
protected virtual void OnNavigateBarButtonSelected(MT.Common.Controls.OutlookStyleNavigateBar.NavigateBarButton tNavigationButton) { if (NavigationChangedEvent != null) NavigationChangedEvent(this, new SPNavigatorFormOptionsChangedEventArgs(tNavigationButton)); }
/// <summary> /// [Re]-renders the whole image (in separate thread). /// </summary> private void RenderImage() { Cursor.Current = Cursors.WaitCursor; // determine output image size: int width = ImageWidth; if (width <= 0) { width = panel1.Width; } int height = ImageHeight; if (height <= 0) { height = panel1.Height; } Bitmap newImage = new Bitmap(width, height, PixelFormat.Format24bppRgb); if (imf == null) { imf = FormSupport.getImageFunction(FormSupport.getScene()); rend = null; } imf.Width = width; imf.Height = height; if (rend == null) { rend = FormSupport.getRenderer(imf); } rend.Width = width; rend.Height = height; rend.Adaptive = 8; rend.ProgressData = progress; progress.SyncInterval = 5000L; progress.Reset(); CSGInnerNode.ResetStatistics(); MT.InitThreadData(); lock ( sw ) { sw.Reset(); sw.Start(); } rend.RenderRectangle(newImage, 0, 0, width, height); long elapsed; lock ( sw ) { sw.Stop(); elapsed = sw.ElapsedMilliseconds; } string msg = string.Format(CultureInfo.InvariantCulture, "{0:f1}s [ {1}x{2}, r{3:#,#}k, i{4:#,#}k, bb{5:#,#}k, t{6:#,#}k ]", 1.0e-3 * elapsed, width, height, (Intersection.countRays + 500L) / 1000L, (Intersection.countIntersections + 500L) / 1000L, (CSGInnerNode.countBoundingBoxes + 500L) / 1000L, (CSGInnerNode.countTriangles + 500L) / 1000L); SetText(msg); Console.WriteLine("Rendering finished: " + msg); SetImage(newImage); Cursor.Current = Cursors.Default; StopRendering(); }
/// <summary> /// Redraws the whole image. /// </summary> private void RenderImage() { Cursor.Current = Cursors.WaitCursor; SetGui(false); width = ImageWidth; if (width <= 0) { width = panel1.Width; } height = ImageHeight; if (height <= 0) { height = panel1.Height; } superSampling = (int)numericSupersampling.Value; Bitmap im = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); MT.InitThreadData(); if (data == null) { data = FormSupport.getData(textParam.Text); // animation data } IImageFunction imf = FormSupport.getImageFunction(textParam.Text, data); imf.Width = width; imf.Height = height; IRenderer rend = FormSupport.getRenderer(textParam.Text, imf); rend.Width = width; rend.Height = height; rend.Adaptive = 0; rend.ProgressData = progress; progress.Continue = true; // animation: ITimeDependent imftd = imf as ITimeDependent; if (imftd != null) { imftd.Time = (double)numTime.Value; } Stopwatch sw = new Stopwatch(); sw.Start(); rend.RenderRectangle(im, 0, 0, width, height); sw.Stop(); labelElapsed.Text = string.Format(CultureInfo.InvariantCulture, "Elapsed: {0:f1}s", 1.0e-3 * sw.ElapsedMilliseconds); SetImage((Bitmap)im.Clone()); string fileName = Util.FileNameString(textParam.Text) + ".png"; im.Save(fileName, System.Drawing.Imaging.ImageFormat.Png); im.Dispose(); SetGui(true); Cursor.Current = Cursors.Default; }
/// <summary> /// Redraws the whole image. /// </summary> private void RenderImage() { Cursor.Current = Cursors.WaitCursor; buttonRender.Enabled = false; buttonRenderAnim.Enabled = false; buttonRes.Enabled = false; width = ImageWidth; if (width <= 0) { width = panel1.Width; } height = ImageHeight; if (height <= 0) { height = panel1.Height; } superSampling = (int)numericSupersampling.Value; outputImage = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); IRayScene scene = FormSupport.getScene(textParam.Text); // scene prototype IImageFunction imf = FormSupport.getImageFunction(scene); imf.Width = width; imf.Height = height; IRenderer rend = FormSupport.getRenderer(imf); rend.Width = width; rend.Height = height; rend.Adaptive = 0; rend.ProgressData = progress; progress.Continue = true; // animation: ITimeDependent sc = scene as ITimeDependent; if (sc != null) { sc.Time = (double)numTime.Value; } MT.InitThreadData(); Stopwatch sw = new Stopwatch(); sw.Start(); rend.RenderRectangle(outputImage, 0, 0, width, height); sw.Stop(); labelElapsed.Text = string.Format("Elapsed: {0:f1}s", 1.0e-3 * sw.ElapsedMilliseconds); pictureBox1.Image = outputImage; buttonRender.Enabled = true; buttonRenderAnim.Enabled = true; buttonRes.Enabled = true; Cursor.Current = Cursors.Default; }
/// <summary> /// Validates VAT number /// </summary> /// <returns>Corrected VAT number in VatNumber object</returns> public static VatNumber Validate(string vat, EUCountry euCountry) { string countryCode = euCountry.ToString().ToUpper(); vat = vat.ToUpper(); CountryBase countryBase; switch (euCountry) { case EUCountry.AT: countryBase = new AT(); break; case EUCountry.BE: countryBase = new BE(); break; case EUCountry.BG: countryBase = new BG(); break; case EUCountry.CY: countryBase = new CY(); break; case EUCountry.CZ: countryBase = new CZ(); break; case EUCountry.DE: countryBase = new DE(); break; case EUCountry.DK: countryBase = new DK(); break; case EUCountry.EE: countryBase = new EE(); break; case EUCountry.EL: countryBase = new EL(); break; case EUCountry.ES: countryBase = new ES(); break; case EUCountry.FI: countryBase = new FI(); break; case EUCountry.FR: countryBase = new FR(); break; case EUCountry.GB: countryBase = new GB(); break; case EUCountry.HR: countryBase = new HR(); break; case EUCountry.HU: countryBase = new HU(); break; case EUCountry.IE: countryBase = new IE(); break; case EUCountry.IT: countryBase = new IT(); break; case EUCountry.LT: countryBase = new LT(); break; case EUCountry.LU: countryBase = new LU(); break; case EUCountry.LV: countryBase = new LV(); break; case EUCountry.MT: countryBase = new MT(); break; case EUCountry.NL: countryBase = new NL(); break; case EUCountry.PL: countryBase = new PL(); break; case EUCountry.PT: countryBase = new PT(); break; case EUCountry.RO: countryBase = new RO(); break; case EUCountry.SE: countryBase = new SE(); break; case EUCountry.SI: countryBase = new SI(); break; case EUCountry.SK: countryBase = new SK(); break; default: throw new InvalidCountryException(); } if (countryBase.StripLetters) { return(new VatNumber(euCountry, countryBase.Validate(Strip(vat)))); } return(new VatNumber(euCountry, countryBase.Validate(StripNoLetters(vat, countryCode)))); }
void PreCalculate() { if (dataset != null) { var bs = dataset.BodyList; INumberTable nt = dataset.GetNumberTableView(); int nrows = nt.Rows - nt.Columns; toIdx = Enumerable.Range(0, bs.Count).Where(i => !bs[i].Disabled).ToArray(); // Indexes of enabled bodies. int[] selectedRows = toIdx.Where(i => i < nrows).ToArray(); int[] selectedColumns = toIdx.Where(i => i >= nrows).Select(i => i - nrows).ToArray(); if ((selectedColumns.Length == 0) || (selectedRows.Length == 0)) { throw new TException("No-zero number of genes and cells must be selected!"); } P = new float[selectedRows.Length][]; MT.Loop(0, P.Length, row => { float[] R = P[row] = new float[selectedColumns.Length]; double[] dsR = nt.Matrix[selectedRows[row]] as double[]; for (int col = 0; col < selectedColumns.Length; col++) { R[col] = (float)dsR[selectedColumns[col]]; } }); // Reverse toIdx; int[] rIdx = Enumerable.Repeat(-1, bs.Count).ToArray(); for (int i = 0; i < toIdx.Length; i++) { rIdx[toIdx[i]] = i; } toIdx = rIdx; } float[][] Q = Transpose(P); // Q is the transpose of P. // Calculate the distance tables for P and Q. bool isPCor = (metricMode == MetricMode.CorCor) || (metricMode == MetricMode.CorEuc); bool isQCor = (metricMode == MetricMode.CorCor) || (metricMode == MetricMode.EucCor); if (isPCor) { Normalize(P); } if (isQCor) { Normalize(Q); } using (var gpu = new VisuMap.DxShader.GpuDevice()) using (var cc = gpu.CreateConstantBuffer <ShaderConstant>(0)) using (var sd = gpu.LoadShader("SingleCellAnalysis.DotProduct.cso", Assembly.GetExecutingAssembly())) { dtP = CallShadere(gpu, cc, sd, P, isPCor); dtQ = CallShadere(gpu, cc, sd, Q, isQCor); } /* * affinity-propagation enhances structure if colums or rows within clusters are * light occupied with high randomness. AP however dilutes clusters with few members. * For instance, singlton gene cluster (with only gene) will suppressed by AP due to * its aggregation with neighboring genes (which should be consdiered as separate * clusters.) * * ProbagateAffinity(dtQ, P); // Column<->Column affinity => Column->Row affinity * ProbagateAffinity(dtP, Q); // Row<->Row affinity => Row->Column affinity. */ // Calculates the distance between rows and columns into P. P = AffinityToDistance(P, Q); Q = null; var app = SingleCellPlugin.App.ScriptApp; double linkBias = app.GetPropertyAsDouble("SingleCell.Separation", 1.0); double pScale = app.GetPropertyAsDouble("SingleCell.CellScale", 1.0); double qScale = app.GetPropertyAsDouble("SingleCell.GeneScale", 1.0); //PowerMatrix(P, linkBias); // Scaling dtP, dtQ to the range of P. Func <float[][], float> aFct = AverageSqrt; double av = aFct(P); pScale *= av / aFct(dtP); qScale *= av / aFct(dtQ); ScaleMatrix(dtP, pScale); ScaleMatrix(dtQ, qScale); //ScaleMatrix(P, linkBias); ShiftMatrix(P, (float)(linkBias * av)); }
static float[][] CallShadere(DxShader.GpuDevice gpu, CBuf cc, ComputeShader sd, float[][] M, bool isCorrelation) { cc.c.N = M.Length; int columns = M[0].Length; const int groupSize = 256; int distSize = groupSize * cc.c.N; float[][] dMatrix = new float[M.Length][]; for (int row = 0; row < M.Length; row++) { dMatrix[row] = new float[row]; } int maxColumns = MaxGpuFloats / cc.c.N; int secSize = Math.Min(columns, (maxColumns > 4096) ? 4096 : (maxColumns - 32)); float[] uploadBuf = new float[cc.c.N * secSize]; using (var dataBuf = gpu.CreateBufferRO(cc.c.N * secSize, 4, 0)) using (var distBuf = gpu.CreateBufferRW(distSize, 4, 0)) using (var distStaging = gpu.CreateStagingBuffer(distBuf)) { gpu.SetShader(sd); for (int s0 = 0; s0 < columns; s0 += secSize) { int s1 = Math.Min(s0 + secSize, columns); WriteMarix(gpu, dataBuf, M, s0, s1, uploadBuf); float[] blockDist = new float[distSize]; for (cc.c.iBlock = 1; cc.c.iBlock < cc.c.N; cc.c.iBlock += groupSize) { cc.c.columns = s1 - s0; cc.Upload(); gpu.Run(groupSize); int iBlock2 = Math.Min(cc.c.iBlock + groupSize, cc.c.N); int bSize = (iBlock2 - cc.c.iBlock) * (iBlock2 + cc.c.iBlock - 1) / 2; gpu.ReadRange <float>(blockDist, 0, distStaging, distBuf, bSize); int offset = 0; for (int row = cc.c.iBlock; row < iBlock2; row++) { float[] R = dMatrix[row]; for (int k = 0; k < row; k++) { R[k] += blockDist[offset + k]; } offset += row; } Application.DoEvents(); } } } if (isCorrelation) { MT.ForEach(dMatrix, R => { for (int col = 0; col < R.Length; col++) { R[col] = 1.0f - R[col]; } }); } else // Euclidean distance is wanted. { float[] norm2 = new float[M.Length]; Array.Clear(norm2, 0, M.Length); int L = M[0].Length; MT.ForEach(M, (R, row) => { float sumSquared = 0.0f; for (int col = 0; col < L; col++) { sumSquared += R[col] * R[col]; } norm2[row] = sumSquared; }); MT.Loop(1, M.Length, row => { float[] R = dMatrix[row]; for (int col = 0; col < row; col++) { R[col] = (float)Math.Sqrt(Math.Abs(norm2[row] + norm2[col] - 2 * R[col])); } }); } return(dMatrix); }
public void Test_MT_CorrectionMT_SAP() { MT mts = new MT(); int count = mts.CorrectionMT_SAP(DateTime.Parse("2016-12-01 00:00:00")); }
public void Test_MT_CompareMT_SAP() { MT mts = new MT(); List <trSostav> list = mts.CompareMT_SAP(DateTime.Parse("2016-12-01 00:00:00")); }
/// <summary> /// Worker thread (picks up individual frames and renders them one by one). /// </summary> protected void RenderWorker(object spec) { // Thread-specific data. WorkerThreadInit init = spec as WorkerThreadInit; if (init == null) { return; } MT.InitThreadData(); // Worker loop. while (true) { double myTime; double myEndTime; int myFrameNumber; lock (progress) { if (!progress.Continue || time > end) { sem.Release(); // chance for the main animation thread to give up as well.. return; } // I've got a frame to compute. myTime = time; myEndTime = (time += dt); myFrameNumber = frameNumber++; } // Set up the new result record. Result r = new Result(); r.image = new Bitmap(init.width, init.height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); r.frameNumber = myFrameNumber; // Set specific time to my scene. if (init.scene != null) { #if DEBUG Debug.WriteLine($"Scene #{init.scene.getSerial()} setTime({myTime})"); #endif init.scene.Time = myTime; } if (init.rend is ITimeDependent arend) { arend.Start = myTime; arend.End = myEndTime; } if (init.imfunc != null) { init.imfunc.Start = myTime; init.imfunc.End = myEndTime; } // Render the whole frame... init.rend.RenderRectangle(r.image, 0, 0, init.width, init.height); // ...and put the result into the output queue. lock (queue) { queue.Enqueue(r); } sem.Release(); // notify the main animation thread } }
/// <summary> /// Redraws the whole image. /// </summary> private void RenderImage() { Cursor.Current = Cursors.WaitCursor; EnableRendering(false); ActualWidth = ImageWidth; if (ActualWidth <= 0) { ActualWidth = panel1.Width; } ActualHeight = ImageHeight; if (ActualHeight <= 0) { ActualHeight = panel1.Height; } superSampling = (int)numericSupersampling.Value; double minTime = (double)numFrom.Value; double maxTime = (double)numTo.Value; double fps = (double)numFps.Value; // 1. preprocessing - compute simulation, animation data, etc. _ = FormSupport.getScene( true, out _, out _, ref ActualWidth, ref ActualHeight, ref superSampling, ref minTime, ref maxTime, ref fps, textParam.Text); // 2. compute regular frame (using the pre-computed context). IRayScene scene = FormSupport.getScene( false, out IImageFunction imf, out IRenderer rend, ref ActualWidth, ref ActualHeight, ref superSampling, ref minTime, ref maxTime, ref fps, textParam.Text); // Update GUI. if (ImageWidth > 0) // preserving default (form-size) resolution { ImageWidth = ActualWidth; ImageHeight = ActualHeight; UpdateResolutionButton(); } UpdateSupersampling(superSampling); UpdateAnimationTiming(minTime, maxTime, fps); // IImageFunction. if (imf == null) // not defined in the script { imf = FormSupport.getImageFunction(scene); } else if (imf is RayCasting imfrc) { imfrc.Scene = scene; } imf.Width = ActualWidth; imf.Height = ActualHeight; // IRenderer. if (rend == null) // not defined in the script { rend = FormSupport.getRenderer(superSampling); } rend.ImageFunction = imf; rend.Width = ActualWidth; rend.Height = ActualHeight; rend.Adaptive = 0; rend.ProgressData = progress; progress.Continue = true; // Animation time has to be set. if (scene is ITimeDependent sc) { sc.Time = (double)numTime.Value; } // Output image. outputImage = new Bitmap(ActualWidth, ActualHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb); MT.InitThreadData(); Stopwatch sw = new Stopwatch(); sw.Start(); rend.RenderRectangle(outputImage, 0, 0, ActualWidth, ActualHeight); sw.Stop(); labelElapsed.Text = string.Format("Elapsed: {0:f1}s", 1.0e-3 * sw.ElapsedMilliseconds); pictureBox1.Image = outputImage; EnableRendering(true); Cursor.Current = Cursors.Default; }
//ADD TAG GameObject Extention public static void AddTag (this GameObject go, string newTag) { MultiTags CurrentGameComponent = go.GetComponent<MultiTags> (); if (CurrentGameComponent == null) { go.AddComponent<MultiTags>(); CurrentGameComponent = go.GetComponent<MultiTags> (); } if (!HasTagPrivate (CurrentGameComponent,newTag)) { MT newItem = new MT(); newItem.Name = newTag; CurrentGameComponent.localTagList.Add(newItem); } }
/// <summary> /// [Re]-renders the whole image (in separate thread). /// </summary> private void RenderImage() { Cursor.Current = Cursors.WaitCursor; // determine output image size: int width = ImageWidth; if (width <= 0) { width = panel1.Width; } int height = ImageHeight; if (height <= 0) { height = panel1.Height; } Bitmap newImage = new Bitmap(width, height, PixelFormat.Format24bppRgb); int threads = checkMultithreading.Checked ? Environment.ProcessorCount : 1; int t; // thread ordinal number WorkerThreadInit[] wti = new WorkerThreadInit[threads]; // separate renderer, image function and the scene for each thread (safety precaution) for (t = 0; t < threads; t++) { IRayScene sc = FormSupport.getScene(); IImageFunction imf = getImageFunction(sc, width, height); IRenderer r = getRenderer(imf, width, height); wti[t] = new WorkerThreadInit(r, sc as ITimeDependent, imf as ITimeDependent, newImage, width, height, t, threads); } progress.SyncInterval = ((width * (long)height) > (2L << 20)) ? 30000L : 10000L; progress.Reset(); CSGInnerNode.ResetStatistics(); lock ( sw ) { sw.Reset(); sw.Start(); } if (threads > 1) { Thread[] pool = new Thread[threads]; for (t = 0; t < threads; t++) { pool[t] = new Thread(new ParameterizedThreadStart(RenderWorker)); } for (t = threads; --t >= 0;) { pool[t].Start(wti[t]); } for (t = 0; t < threads; t++) { pool[t].Join(); pool[t] = null; } } else { MT.InitThreadData(); wti[0].rend.RenderRectangle(newImage, 0, 0, width, height); } long elapsed; lock ( sw ) { sw.Stop(); elapsed = sw.ElapsedMilliseconds; } string msg = string.Format(CultureInfo.InvariantCulture, "{0:f1}s [ {1}x{2}, mt{3}, r{4:#,#}k, i{5:#,#}k, bb{6:#,#}k, t{7:#,#}k ]", 1.0e-3 * elapsed, width, height, threads, (Intersection.countRays + 500L) / 1000L, (Intersection.countIntersections + 500L) / 1000L, (CSGInnerNode.countBoundingBoxes + 500L) / 1000L, (CSGInnerNode.countTriangles + 500L) / 1000L); SetText(msg); Console.WriteLine("Rendering finished: " + msg); SetImage(newImage); Cursor.Current = Cursors.Default; StopRendering(); }
internal static string CreateMO(string OAdC, string AdC, string text, DateTimeOffset SCTS, MessageFormat format, MT MT) { int localTRN = TRN_MO++; TRN_MO = TRN_MO % 100; string Msg = string.Empty; string Xser = string.Empty; string Mt = string.Empty; if (MT != 0) { Mt = ((int)MT).ToString(); } string NB = string.Empty; int iNB = 0; if (format == MessageFormat.Unicode) { //According to Spec EMI. if we want to send SMS coded to Unicode, the MT must set to 4. Msg = TextToUnicodeHexString(text); iNB = Msg.Length; NB = iNB.ToString(); Mt = "4"; // Unicode not compressed Xser = "020108"; } else if (format == MessageFormat.GSM7) { Msg = TextToGSM8HexString(text); iNB = Msg.Length; NB = iNB.ToString(); Xser = "020100"; // En GSM 7bit Not Compressed } else { //We encoded in GSM by default //According to Spec EMI. if we want to send SMS coded to 8-bit, the MT must set to 4. Msg = TextToGSM8HexString(text); Mt = "4"; Xser = "0201F4"; // GSM format not compressed NB = string.Empty; } string mo = STX + localTRN.ToString("00") + "/LLLLL/O/52/" + AdC + "/" + OAdC + "/////////////" + SCTS.ToString(SCTSFormat) + "////" + Mt + "/" + NB + "/" + Msg + "//////////" + Xser + "///SS" + ETX; string length = (mo.Length - 2).ToString("00000"); mo = mo.Replace("LLLLL", length); mo = CheckSum(mo); return(mo); }
private void FrMain_Load(object sender, EventArgs e) { EM_RES ret; VAR.msg.ShowMsgCfg(1000, (Msg.EM_MSGTYPE) 0xffff); VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, "系统启动..."); //load sys config VAR.gsys_set.LoadSysCfg(); VAR.gsys_set.status = EM_SYS_STA.UNKOWN; VAR.gsys_set.bclose = false; VAR.sys_inf.Set(EM_ALM_STA.WAR_YELLOW_FLASH, "正在加载", 2, true); //加载产品 try { //if (COM.NGDef == null) // COM.NGDef = new NGCodeDef(); //COM.NGDef.LoadCfg(); //if (COM.product == null) COM.product = new Product(); //ret = COM.product.LoadDat(VAR.gsys_set.cur_product_name); //if (ret != EM_RES.OK) VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, "产品数据加载失败!"); //else VAR.msg.AddMsg(Msg.EM_MSGTYPE.NOR, "产品数据加载成功!"); //foreach (WS ws in COM.list_ws) //{ // ws.LoadCfg(); //} ////加载吸头 //COM.XtInit(VAR.gsys_set.cur_product_name); ////加载仓储 //COM.TrayBoxInit(); } catch (Exception ex) { MessageBox.Show(ex.Message); } //硬件初始化 Task TaskHWInit = new Task(() => { ret = MT.Init(Path.GetFullPath("..") + "\\syscfg\\"); if (ret != EM_RES.OK) { VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, "板卡初始化失败!"); } else { VAR.msg.AddMsg(Msg.EM_MSGTYPE.NOR, "板卡初始化成功!"); } } ); TaskHWInit.Start(); //相机初始化 //Task TaskCamInit = new Task(() => //{ // ret = MT.Init(Path.GetFullPath("..") + "\\syscfg\\"); // if (ret != EM_RES.OK) VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, "板卡始化失败!"); // else VAR.msg.AddMsg(Msg.EM_MSGTYPE.NOR, "板卡始化成功!"); //} //ret = COM.CamInit(); //if (ret != EM_RES.OK) VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, "相机初始化失败!"); //else VAR.msg.AddMsg(Msg.EM_MSGTYPE.NOR, "相机初始化成功!"); //); //TaskHWInit.Start(); //COM.CamInit(); //create form //Task TaskFormInit = new Task(() => //{ // if (frsys == null) frsys = new FrSys(); // frsys.bupdate = false; // if (frrst == null) frrst = new FrRst(); // frrst.bupdate = false; // if (frproduct == null) frproduct = new FrProduct(); // frproduct.bupdate = false; // if (frrun == null) frrun = new FrRun(); // frrun.bupdate = false; // pnl_sub.Controls.Clear(); // frrun.TopLevel = false; // frrun.FormBorderStyle = FormBorderStyle.None; //} //); //TaskFormInit.Start(); form_sel("rbtn_run");//显示运行界面 Application.DoEvents(); Thread.Sleep(10); // timer_reconnect.Enabled = true; // if (frrun != null) frrun.bupdate = true; VAR.sys_inf.Set(EM_ALM_STA.WAR_YELLOW_FLASH, "待回零", 10, true); if (MT.isReady) { ////钩子侦测按键 //k_hook.KeyDownEvent += new KeyEventHandler(hook_KeyDown);//钩住键按下 //k_hook.KeyUpEvent += new KeyEventHandler(hook_KeyUp);//钩住键按下 //k_hook.Start();//安装键盘钩子 } MT.SetSafeFunc(); //MT.GPIO_OUT_TT_REV.ChkSafe = Turntable.ChkSafe; //MT.GPIO_OUT_TT_FWD.ChkSafe = Turntable.ChkSafe; }
/// <summary> /// Worker thread (picks up individual frames and renders them one by one). /// </summary> protected void RenderWorker(object spec) { // thread-specific data: WorkerThreadInit init = spec as WorkerThreadInit; if (init == null) { return; } MT.InitThreadData(); // worker loop: while (true) { double myTime; double myEndTime; int myFrameNumber; lock ( progress ) { if (!progress.Continue || time > end) { sem.Release(); // chance for the main animation thread to give up as well.. return; } // got a frame to compute: myTime = time; myEndTime = (time += dt); myFrameNumber = frameNumber++; } // set up the new result record: Result r = new Result(); r.image = new Bitmap(init.width, init.height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); r.frameNumber = myFrameNumber; // set specific time to my scene: if (init.scene != null) { init.scene.Time = myTime; } ITimeDependent anim = init.rend as ITimeDependent; if (anim != null) { anim.Start = myTime; anim.End = myEndTime; } if (init.imfunc != null) { init.imfunc.Start = myTime; init.imfunc.End = myEndTime; } // render the whole frame: init.rend.RenderRectangle(r.image, 0, 0, init.width, init.height); // ... and put the result into the output queue: lock ( queue ) { queue.Enqueue(r); } sem.Release(); // notify the main animation thread } }
public void Save(string filePath) { MT.SaveImage(filePath); }
/// <summary> /// Worker thread (picks up individual frames and renders them one by one). /// </summary> protected void RenderWorker() { // thread-specific data: ITimeDependent datatd = data as ITimeDependent; object myData = (datatd == null) ? data : datatd.Clone(); MT.InitThreadData(); IImageFunction imf = FormSupport.getImageFunction(textParam.Text, myData); imf.Width = width; imf.Height = height; ITimeDependent imftd = imf as ITimeDependent; IRenderer rend = FormSupport.getRenderer(textParam.Text, imf); rend.Width = width; rend.Height = height; rend.Adaptive = 0; // turn off adaptive bitmap synthesis completely (interactive preview not needed) rend.ProgressData = progress; // worker loop: while (true) { double myTime; int myFrameNumber; lock ( progress ) { if (!progress.Continue || time > end) { sem.Release(); // chance for the main animation thread to give up as well.. return; } // got a frame to compute: myTime = time; time += dt; myFrameNumber = frameNumber++; } // set up the new result record: Result r = new Result(); r.image = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); r.frameNumber = myFrameNumber; // set specific time to my image function: if (imftd != null) { imftd.Time = myTime; } // render the whole frame: rend.RenderRectangle(r.image, 0, 0, width, height); // ... and put the result into the output queue: lock ( queue ) { queue.Enqueue(r); } sem.Release(); // notify the main animation thread } }
public Bitmap ToBitmap() { return(MT.ToBitmap()); }
public void Dispose() { MT?.Dispose(); MT = null; }
public Img GetResized(SysSize size) { var resized = MT.Resize(size.ToCvSize()); return(new Img(resized)); }
public static void MoteTracerMaintenanceRemoval(this CompDecorate comp) { comp.LivingMotes.RemoveAll(MT => MT.MoteIsDead()); }
public void ProcessRequest(HttpContext context) { //context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); string serviceCode = context.Request.QueryString["serviceCode"]; if (!string.IsNullOrEmpty(serviceCode)) { serviceCode = serviceCode.ToUpper(); } string msisdn = context.Request.QueryString["msisdn"]; string type = context.Request.QueryString["Type"]; string serviceId = "8979"; const string reType = "text"; string reContent = string.Empty; log4net.ILog log = log4net.LogManager.GetLogger("File"); log.Debug(" "); log.Debug(" "); log.Debug("--------------------VOTE MOBI FROM Mr.T-------------------------"); log.Debug("User_ID: " + msisdn); log.Debug("Command_Code: " + serviceCode); log.Debug("Type: " + type); log.Debug(" "); log.Debug(" "); if (serviceCode == "V1" || serviceCode == "V2" || serviceCode == "G1" || serviceCode == "G2")//DV VOTE1 & VOTE2 { int votePersonId = 1; string personName = "Mai Tho"; string commandCode = "VOTE1"; int dislikePersonId = 0; if (serviceCode == "V2") { votePersonId = 2; personName = "Linh Miu"; commandCode = "VOTE2"; } else if (serviceCode == "G1") { votePersonId = 2; dislikePersonId = 1; personName = "Mai Tho"; commandCode = "GACH1"; } else if (serviceCode == "G2") { votePersonId = 1; dislikePersonId = 2; personName = "Linh Miu"; commandCode = "GACH2"; } if (type == "1")//DK DV LAN DAU { var entity = new VoteRegisteredInfo(); entity.User_ID = msisdn; entity.Request_ID = "0"; entity.Service_ID = serviceId; entity.Command_Code = commandCode; entity.Service_Type = 1; entity.Charging_Count = 0; entity.FailedChargingTime = 0; entity.RegisteredTime = DateTime.Now; entity.ExpiredTime = DateTime.Now.AddDays(1); entity.Registration_Channel = "SMS"; entity.Status = 1; entity.Operator = "vms"; entity.Vote_Count = 1; entity.Vote_PersonId = votePersonId; entity.IsDislike = dislikePersonId; if (serviceCode == "V1" || serviceCode == "V2") { DataTable dt = VoteRegisterController.NewVoteRegisterInsert(entity); if (dt.Rows[0]["RETURN_ID"].ToString() == "0")//CHUA DK USER { reContent = AppEnv.GetSetting("Vote_Sms_RegisterSucess_Mt2_Like_Mobi").Replace("VoteCount", "1").Replace("VoteTop", "100"); } else if (dt.Rows[0]["RETURN_ID"].ToString() == "1") { int voteCount = ConvertUtility.ToInt32(dt.Rows[0]["VOTE_SUM"]); string voteTop = GetTopVote(voteCount); reContent = AppEnv.GetSetting("Vote_Sms_RegisterSucess_Mt2_Like_Mobi").Replace("VoteCount", voteCount.ToString()).Replace("VoteTop", voteTop); } #region LOG DOANH THU NewVoteLogDoanhThu(msisdn, "0", serviceId, "VOTE1"); #endregion } //else //{ // DataTable dt = VoteRegisterController.VoteRegisterInsert(entity); // DataTable dtDislike = VoteRegisterController.VoteRegisterDislikeInsert(entity); // if (dt.Rows[0]["RETURN_ID"].ToString() == "0")//DK DICH VU LAN DAU // { // reContent = AppEnv.GetSetting("Vote_Sms_RegisterSucess_Mt2_Like_Mobi").Replace("PersonName", personName); // } // else if (dt.Rows[0]["RETURN_ID"].ToString() == "1") // { // reContent = AppEnv.GetSetting("Vote_Sms_AlreadyRegister_Mobi"); // } //} } else if (type == "2")//UPDATE LUOT VOTE (SUB HANG NGAY) { DataTable info = VoteRegisterController.NewVoteGetUserInfo(msisdn); if (info != null && info.Rows.Count > 0) { var logInfo = new ViSport_S2_Charged_Users_LogInfo(); logInfo.ID = ConvertUtility.ToInt32(info.Rows[0]["ID"].ToString()); logInfo.User_ID = msisdn; logInfo.Request_ID = info.Rows[0]["Request_ID"].ToString(); logInfo.Service_ID = info.Rows[0]["Service_ID"].ToString(); logInfo.Command_Code = info.Rows[0]["Command_Code"].ToString(); logInfo.Service_Type = 0;//Charged Sub Service_Type logInfo.Charging_Count = ConvertUtility.ToInt32(info.Rows[0]["Charging_Count"].ToString()); logInfo.FailedChargingTimes = ConvertUtility.ToInt32(info.Rows[0]["FailedChargingTimes"].ToString()); logInfo.RegisteredTime = DateTime.Now; logInfo.ExpiredTime = DateTime.Now.AddDays(1); logInfo.Registration_Channel = info.Rows[0]["Registration_Channel"].ToString(); logInfo.Status = ConvertUtility.ToInt32(info.Rows[0]["Status"].ToString()); logInfo.Operator = info.Rows[0]["Operator"].ToString(); logInfo.Price = 2000; logInfo.Vote_PersonId = ConvertUtility.ToInt32(info.Rows[0]["Vote_PersonId"].ToString()); logInfo.Reason = "Succ"; if (serviceCode == "V1" || serviceCode == "V2") { VoteRegisterController.NewInsertLogLike(logInfo); DataTable dt = VoteRegisterController.NewVoteGetUserInfo(msisdn); int voteCount = ConvertUtility.ToInt32(dt.Rows[0]["Vote_Count"]); string voteTop = GetTopVote(voteCount); reContent = AppEnv.GetSetting("Vote_Sms_RegisterSucess_Mt2_Like_Mobi").Replace("VoteCount", voteCount.ToString()).Replace("VoteTop", voteTop); //DataTable dt = VoteRegisterController.GetVoteAccountInfo(msisdn, info.Rows[0]["Command_Code"].ToString()); //reContent = AppEnv.GetSetting("Vote_Sms_ChargedSubSucess_Like").Replace("PersonName", dt.Rows[0]["Name"].ToString()); //reContent = reContent.Replace("VoteCount", dt.Rows[0]["Count"].ToString()); //reContent = reContent.Replace("VoteTop", dt.Rows[0]["Top"].ToString()); } //else if(serviceCode == "G1" || serviceCode == "G2") //{ // if (info.Rows[0]["Vote_PersonId"].ToString() == "1") // { // logInfo.Vote_PersonId = 2; // } // else if (info.Rows[0]["Vote_PersonId"].ToString() == "2") // { // logInfo.Vote_PersonId = 1; // } // VoteRegisterController.InsertLogDisLike(logInfo); // DataTable dt = VoteRegisterController.GetVoteAccountInfo(msisdn, info.Rows[0]["Command_Code"].ToString()); // reContent = AppEnv.GetSetting("Vote_Sms_ChargedSubSucess_UnLike").Replace("PersonName", dt.Rows[0]["Name"].ToString()); // reContent = reContent.Replace("DislikeCount", dt.Rows[0]["Count"].ToString()); // reContent = reContent.Replace("DislikeTop", dt.Rows[0]["Top"].ToString()); //} } } else if (type == "3")//HUY DICH VU { DataTable dt = VoteRegisterController.NewVoteRegisterUserLock(msisdn); if (dt.Rows[0]["RETURN_ID"].ToString() == "0")//CHUA DK USER { reContent = AppEnv.GetSetting("Vote_Sms_LockUserError_Mobi"); } else if (dt.Rows[0]["RETURN_ID"].ToString() == "1") { reContent = AppEnv.GetSetting("Vote_Sms_LockUserSuccess_Mobi"); } //DataTable dt = VoteRegisterController.VoteRegisterUserLock(msisdn, 1); //if (dt.Rows[0]["RETURN_ID"].ToString() == "0")//CHUA DK USER //{ // reContent = AppEnv.GetSetting("Vote_Sms_LockUserError_Mobi"); //} //else if (dt.Rows[0]["RETURN_ID"].ToString() == "1") //{ // reContent = AppEnv.GetSetting("Vote_Sms_LockUserSuccess_Mobi"); //} } } if (serviceCode == "T1") //DV GAME THANH_NU { if (type == "1") //DK DV LAN DAU { var entity = new ThanhNuRegisteredUsers(); entity.UserId = msisdn; entity.RequestId = "0"; entity.ServiceId = "2288"; entity.CommandCode = "DK"; entity.ServiceType = 1; entity.ChargingCount = 0; entity.FailedChargingTimes = 0; entity.RegisteredTime = DateTime.Now; entity.ExpiredTime = DateTime.Now.AddDays(1); entity.RegistrationChannel = "SMS"; entity.Status = 1; entity.Operator = GetTelco(msisdn); #region GOI HAM DK BEN DOI TAC string partnerResult = AppEnv.ThanhNuDangKy(msisdn); log.Debug(" "); log.Debug("**********"); log.Debug("Partner_Thanh_Nu_smsKichHoat : " + partnerResult); log.Debug("**********"); log.Debug(" "); string[] arrValue = partnerResult.Split('|'); if (arrValue[0].Trim() == "1") { ViSport_S2_Registered_UsersController.ThanhNuRegisterUserStatusUpdate(msisdn, 1); reContent = "Ban da la thanh vien cua Game Thanh Nu. Click vao link sau de dang nhap Game " + arrValue[1]; } else if (arrValue[0].Trim() == "0") { DataTable value = ViSport_S2_Registered_UsersController.ThanhNuRegisterUserInsert(entity); if (value.Rows[0]["RETURN_ID"].ToString() == "0") { reContent = "Chuc mung Quy Khach da dang ky thanh cong Game Thanh Nu Gia cuoc 1000d-ngay, Goi dich vu se duoc tu dong gia han hang ngay.Kich hoat tai khoan " + arrValue[1] + " .De huy dang ky, Quy Khach soan HUY TN gui 2288."; } else if (value.Rows[0]["RETURN_ID"].ToString() == "1") { ViSport_S2_Registered_UsersController.ThanhNuRegisterUserStatusUpdate(msisdn, 1); reContent = "Ban da la thanh vien cua Game Thanh Nu. Click vao link sau de dang nhap Game " + arrValue[1]; } } #endregion } else if (type == "2")//CHARGED SUB { var partnerService = new vn.thanhnu.Service(); DataTable dtUser = ViSport_S2_Registered_UsersController.ThanhNuGetUserInfo(msisdn); if (dtUser != null && dtUser.Rows.Count > 0) { string partnerResult = partnerService.smsGiaHan(msisdn, "1"); if (partnerResult.Trim() == "1") { reContent = "Goi dich vu Game Thanh Nu cua Quy Khach da duoc gia han thanh cong. Quy khach duoc cong 110 G_Coin vao tk. Cam on Quy Khach da su dung goi dich vu ."; } #region LOG DOANH THU //LOG DOANH THU var e = new ThanhNuChargedUserLogInfo(); e.ID = ConvertUtility.ToInt32(dtUser.Rows[0]["ID"].ToString()); e.User_ID = msisdn; e.Request_ID = "0"; e.Service_ID = serviceId; e.Command_Code = "DK"; e.Service_Type = 0; e.Charging_Count = 0; e.FailedChargingTime = 0; e.RegisteredTime = DateTime.Now; e.ExpiredTime = DateTime.Now.AddDays(1); e.Registration_Channel = "SMS"; e.Status = 1; e.Operator = GetTelco(msisdn); e.Reason = "Succ"; e.Price = 1000; e.PartnerResult = partnerResult; ViSport_S2_Registered_UsersController.ThanhNuChargedUserLog(e); #endregion } } else if (type == "3")//HUY DICH VU { #region GOI HAM HUY BEN DOI TAC string partnerResult = AppEnv.ThanhNuHuy(msisdn); if (partnerResult.Trim() == "1") { DataTable value = ViSport_S2_Registered_UsersController.ThanhNuRegisterUserStatusUpdate(msisdn, 0); if (value.Rows[0]["RETURN_ID"].ToString() == "1") { reContent = "Toan bo tai khoan Game Thanh Nu cua Quy khach se bi huy.De dang ki lai Qk vui long soan tin DK TN gui 2288"; } } #endregion } } var aSerializer = new JavaScriptSerializer(); var obj = new MT(); var ct1 = new ContentInfo(); obj.List = new ContentInfo[1]; ct1.Type = reType; ct1.Content = reContent; obj.List[0] = ct1; string strReturn = aSerializer.Serialize(obj); log.Debug(" "); log.Debug(" "); log.Debug("strReturn: " + strReturn); log.Debug(" "); log.Debug(" "); context.Response.ContentType = "text/html"; context.Response.Write(strReturn); }
public SPNavigatorFormOptionsChangedEventArgs(MT.Common.Controls.OutlookStyleNavigateBar.NavigateBarButton NavButton) { _navButton = NavButton; }
public void SendSMSFormList(object obj) { try { List <QueueService> listSend = (List <QueueService>)obj; MTQueueReportProvider providerMTR = new MTQueueReportProvider(); MTProvider providerMT = new MTProvider(); QueueServiceProvider qsProvider = new QueueServiceProvider(); EncryptAndDecrypt ead = new EncryptAndDecrypt(); SubTelcoProvider stProvider = new SubTelcoProvider(); RouteTelcoProvider routeProvider = new RouteTelcoProvider(); while (listSend != null && listSend.Count > 0) { //string str_result = "0:NONE_ROUTE"; QueueService model = listSend[0]; //if(model.Receiver.Contains("904993309") || model.Receiver.Contains("988018028")) //{ // str_result = SendSMS(model, false, ead, stProvider, routeProvider); //} string str_result = SendSMS(model, false, ead, stProvider, routeProvider); var results = str_result.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).ToList(); int result = Convert.ToInt32(results[0]); if (result == 501 || result == 502 || result == 503 || result == 555) { //FAIL MT mt = new MT() { Content = model.Content, DateCreate = model.DateCreate, Dest = model.Dest, Password = model.Password, Priority = model.Priority, ProcessingCode = model.ProcessingCode, Receiver = model.Receiver, Source = model.Source, Status = ConfigType.MT_STATUS_NOT_NOTIFY_ERROR, TimeSend = DateTime.Now, TransID = model.TransID, TransTime = model.TransTime, User = model.User, Result = result, SMSID = model.SMSID, RouteName = results[1] }; providerMT.Insert(mt); } else { //SUCCESS MTQueueReport mt = new MTQueueReport() { Content = model.Content, DateCreate = model.DateCreate, Dest = model.Dest, Password = model.Password, Priority = model.Priority, ProcessingCode = model.ProcessingCode, Receiver = model.Receiver, Source = model.Source, Status = ConfigType.MT_STATUS_NOT_NOTIFY, TimeSend = DateTime.Now, TransID = model.TransID, TransTime = model.TransTime, User = model.User, Result = result, SMSID = model.SMSID, RouteName = results[1] }; providerMTR.Insert(mt); } logger.Info("SendSMS [" + results[1] + "] : " + model.Receiver + " | " + model.Content + " | " + result); listSend.RemoveAt(0); qsProvider.DeleteById(model.Id); Thread.Sleep(10); } _doneEvent.Set(); } catch (Exception ex) { logger.Error(ex); _doneEvent.Set(); Thread.Sleep(1000); //SendSMSFormList(listSend); } }
public override void OnInspectorGUI () { MultiTags myScript = (MultiTags)target; EditorGUILayout.LabelField ("--------------------------------------------------------------------------------------------------------------------"); GUI.color = Color.green; EditorGUILayout.LabelField ("LOCAL ASSIGNED TAGS: "); GUI.color = Color.white; GUILayout.Space (10); foreach (var item in myScript.localTagList.ToArray()) { EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Tag: ", GUILayout.Width(40)); //EditorGUILayout.TextField(item.Name); EditorGUILayout.SelectableLabel(item.Name, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); GUI.color = Color.red + Color.yellow; if (GUILayout.Button ("Remove", GUILayout.Width (55))) { myScript.localTagList.Remove (item); } GUI.color = Color.white; EditorGUILayout.EndHorizontal (); if (!HasTagGlobal(item.Name)) { EditorGUILayout.BeginHorizontal (); GUI.color = Color.yellow; EditorGUILayout.LabelField ("warning: (" + item.Name + ") is not a global tag.",GUILayout.Height(25)); GUI.color = Color.white; EditorGUILayout.EndHorizontal (); } } EditorGUILayout.LabelField ("--------------------------------------------------------------------------------------------------------------------"); EditorGUILayout.LabelField ("--------------------------------------------------------------------------------------------------------------------"); GUI.color = Color.cyan; expandGlobals = EditorGUILayout.Foldout (expandGlobals, "GLOBAL PROJECT TAGS: "); GUI.color = Color.white; if (expandGlobals) { foreach (var itemG in GlobalTagHolder.TagHolder.GlobalTagList.ToArray()) { EditorGUILayout.BeginHorizontal (); if (myScript.gameObject.HasTag(itemG.Name)) { GUI.color = Color.green; EditorGUILayout.LabelField ("Assigned ", GUILayout.Width(55) ); GUI.color = Color.white; } else { GUI.color = Color.green; //EditorGUILayout.LabelField ("Tag: " + item); if (GUILayout.Button ("Assign", GUILayout.Width (55))) { myScript.localTagList.Add (itemG); } GUI.color = Color.white; } EditorGUILayout.LabelField ("Tag: ", GUILayout.Width(40)); // EditorGUILayout.LabelField ("Tag: " + itemG.Name); EditorGUILayout.SelectableLabel(itemG.Name, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); GUI.color = Color.red + Color.red; if (GUILayout.Button ("Destroy", GUILayout.Width (55))) { GlobalTagHolder.TagHolder.GlobalTagList.Remove (itemG); GlobalTagHolder.TagHolder.Save(); } GUI.color = Color.white; // EditorGUILayout.LabelField ("Description: " + itemAll.Description.ToString (), GUILayout.MaxWidth (160)); //item.Description = EditorGUILayout.TextField ("Description: ", item.Description, GUILayout.MaxWidth(120)); //EditorGUILayout.Separator(); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); // itemAll.ID = (byte)EditorGUILayout.IntField ("ReID: ", itemAll.ID, GUILayout.MaxWidth (180)); // itemAll.Name = EditorGUILayout.TextField ("Rename: ", itemAll.Name); EditorGUILayout.EndHorizontal (); // EditorGUILayout.LabelField ("-----------"); } EditorGUILayout.LabelField ("--------------------------------------------------------------------------------------------------------------------"); } GUILayout.Space (20); EditorGUILayout.BeginHorizontal (); //tagDescription = GUILayout.TextField(tagDescription,20); tagDescription = EditorGUILayout.TextField ("Tag Name: ", tagDescription); GUI.color = Color.cyan; if (GUILayout.Button ("Add New Tag", GUILayout.Width (100))) { tagDescription = tagDescription.Trim(); if (string.IsNullOrEmpty(tagDescription)) { return; } MT itemLocal = new MT (); MT itemGlobal = new MT (); itemLocal.Name = tagDescription; // item.ID = 44; // itemLocal.tagGUID = Guid.NewGuid().ToString();; itemGlobal.Name = itemLocal.Name; // itemGlobal.tagGUID = itemLocal.tagGUID; if (!HasTagGlobal(tagDescription)) { GlobalTagHolder.TagHolder.GlobalTagList.Add (itemGlobal); GlobalTagHolder.TagHolder.Save(); } if (!myScript.gameObject.HasTag(tagDescription)) { myScript.localTagList.Add (itemLocal); } tagDescription = string.Empty; } GUI.color = Color.white; EditorGUILayout.EndHorizontal (); GUILayout.Space (20); expandCodeExample = EditorGUILayout.Foldout (expandCodeExample, "CODE EXAMPLE: "); if (expandCodeExample) { GUILayout.TextArea (stringToEdit, 200); } GUILayout.Space (20); // DrawDefaultInspector (); if (GUI.changed) { // Debug.Log ("I Changed"); // foreach (var item in myScript.multiTag) { // if (String.IsNullOrEmpty(item.TestGUID())) { // // item.SetGUID(Guid.NewGuid().ToString()); // // } // } } }
public override void OnInspectorGUI() { MultiTags myScript = (MultiTags)target; //////// GUI.color = Color.green; EditorGUILayout.LabelField("LOCAL ASSIGNED TAGS: "); GUI.color = Color.white; GUILayout.Space(10); foreach (var item in myScript.localTagList.ToArray()) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Tag: ", GUILayout.Width(40)); EditorGUILayout.SelectableLabel(item.Name, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); GUI.color = Color.red + Color.yellow; if (GUILayout.Button("Remove", GUILayout.Width(55))) { myScript.localTagList.Remove(item); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (!HasTagGlobal(item.Name)) { EditorGUILayout.BeginHorizontal(); GUI.color = Color.yellow; EditorGUILayout.LabelField("warning: (" + item.Name + ") is not a global tag.", GUILayout.Height(25)); GUI.color = Color.white; EditorGUILayout.EndHorizontal(); } } //////// GUI.color = Color.cyan; expandGlobals = EditorGUILayout.Foldout(expandGlobals, "GLOBAL PROJECT TAGS: "); GUI.color = Color.white; if (expandGlobals) { foreach (var itemG in GlobalTagHolder.TagHolder.GlobalTagList.ToArray()) { EditorGUILayout.BeginHorizontal(); if (myScript.gameObject.HaveTags(itemG.Name)) { GUI.color = Color.green; EditorGUILayout.LabelField("Assigned ", GUILayout.Width(55)); GUI.color = Color.white; } else { GUI.color = Color.green; if (GUILayout.Button("Assign", GUILayout.Width(55))) { myScript.localTagList.Add(itemG); } GUI.color = Color.white; } EditorGUILayout.LabelField("Tag: ", GUILayout.Width(40)); EditorGUILayout.SelectableLabel(itemG.Name, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); GUI.color = Color.red + Color.red; if (GUILayout.Button("Destroy", GUILayout.Width(55))) { GlobalTagHolder.TagHolder.GlobalTagList.Remove(itemG); GlobalTagHolder.TagHolder.Save(); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.EndHorizontal(); } //////// } EditorGUILayout.BeginHorizontal(); tagDescription = EditorGUILayout.TextField("Tag Name: ", tagDescription); GUI.color = Color.cyan; if (GUILayout.Button("Add New Tag", GUILayout.Width(100))) { tagDescription = tagDescription.Trim(); if (string.IsNullOrEmpty(tagDescription)) { return; } MT itemLocal = new MT(); MT itemGlobal = new MT(); itemLocal.Name = tagDescription; itemGlobal.Name = itemLocal.Name; if (!HasTagGlobal(tagDescription)) { GlobalTagHolder.TagHolder.GlobalTagList.Add(itemGlobal); GlobalTagHolder.TagHolder.Save(); } if (!myScript.gameObject.HaveTags(tagDescription)) { myScript.localTagList.Add(itemLocal); } tagDescription = string.Empty; } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); }
//----------------------------------------------------------------------------- public Lab3(int N) { // Preparations MA = new Matrix(N, 0); b = 0; a = 400000000; // Semaphores Semaphore_Calculation1EndIn = new Semaphore[P]; for (int i = 0; i < P; i++) { Semaphore_Calculation1EndIn[i] = new Semaphore(0, P); } // Mutexes Mutex_SetA = new Mutex(false); // Events // manual Event_InputFinishIn1 = new EventWaitHandle(false, EventResetMode.ManualReset); Event_InputFinishIn3 = new EventWaitHandle(false, EventResetMode.ManualReset); Event_InputFinishIn4 = new EventWaitHandle(false, EventResetMode.ManualReset); // automatic Event_Calculation2EndIn = new EventWaitHandle[P]; for (int i = 0; i < P; i++) { Event_Calculation2EndIn[i] = new EventWaitHandle(false, EventResetMode.AutoReset); } // Threads Thread[] threads = new Thread[P]; //----------------------------------------------------------------------------- for (int thread = 0; thread < P; thread++) { int index = thread; threads[thread] = new Thread(() => { int tid = index + 1; int low = (tid - 1) * H; int high = tid * H; if (doOutput) { Console.WriteLine(":> Thread " + tid + " started!"); } // 1. Input switch (tid) { case 1: Z = FillVectorOnes(); break; case 3: MO = FillMatrixOnes(); MS = FillMatrixOnes(); break; case 4: MT = FillMatrixOnes(); break; default: break; } // 2. Signal T1..6 about input finish switch (tid) { case 1: Event_InputFinishIn1.Set(); break; case 3: Event_InputFinishIn3.Set(); break; case 4: Event_InputFinishIn4.Set(); break; default: break; } // 3. Wait for input finish in T1, T3, T4 Event_InputFinishIn1.WaitOne(); Event_InputFinishIn3.WaitOne(); Event_InputFinishIn4.WaitOne(); // 4. Copy MTi = MT Matrix MTi; lock (Lock_CopyMt) { MTi = MT.copy(); } // 5. int ai = FindMin(ref Z, low, high); // 6. Mutex_SetA.WaitOne(); a = Min(a, ai); Mutex_SetA.ReleaseMutex(); // 7. int bi = FindMax(ref Z, low, high); // 8. b = Max(b, bi); // 9. Signal T1..6 about Calculation1 finish Semaphore_Calculation1EndIn[tid - 1].Release(P); // 10. Wait for Calculation1 finish in T1..6 for (int i = 0; i < P; i++) { Semaphore_Calculation1EndIn[i].WaitOne(); } // 11. Copy a, b Monitor.Enter(Monitor_SetAb); try { ai = a; bi = b; } finally { Monitor.Exit(Monitor_SetAb); } // 12. Calculation2 for (int i = low; i < high; i++) { for (int j = 0; j < N; j++) { int product = 0; for (int k = 0; k < N; k++) { product += MO[i, k] * MTi[k, j]; } MA[i, j] = bi * product + ai * MS[i, j]; } } // 13. Wait for Calculation2 finish in T1..6 Event_Calculation2EndIn[tid - 1].Set(); switch (tid) { case 1: for (int i = 0; i < P; i++) { Event_Calculation2EndIn[i].WaitOne(); } break; default: break; } // 14. Output switch (tid) { case 1: if (N <= outputThreshold) { OutputMatrix(ref MA); } break; default: break; } if (doOutput) { Console.WriteLine(":> Finished Thread " + tid); } }); } //----------------------------------------------------------------------------- for (int i = 0; i < 6; i++) { threads[i].Start(); } for (int i = 0; i < 6; i++) { threads[i].Join(); } }
/// <summary> /// [Re]-renders the whole image (in separate thread). /// </summary> private void RenderImage() { Cursor.Current = Cursors.WaitCursor; // determine output image size: int width = ImageWidth; if (width <= 0) { width = panel1.Width; } int height = ImageHeight; if (height <= 0) { height = panel1.Height; } Bitmap newImage = new Bitmap(width, height, PixelFormat.Format24bppRgb); if (imf == null) { imf = FormSupport.getImageFunction(FormSupport.getScene()); rend = null; } imf.Width = width; imf.Height = height; RayTracing rt = imf as RayTracing; if (rt != null) { rt.DoShadows = checkShadows.Checked; rt.DoReflections = checkReflections.Checked; rt.DoRefractions = checkRefractions.Checked; } if (rend == null) { rend = FormSupport.getRenderer(imf); } rend.Width = width; rend.Height = height; rend.Adaptive = 8; rend.ProgressData = progress; SupersamplingImageSynthesizer ss = rend as SupersamplingImageSynthesizer; if (ss != null) { ss.Supersampling = (int)numericSupersampling.Value; ss.Jittering = checkJitter.Checked ? 1.0 : 0.0; } progress.SyncInterval = ((width * (long)height) > (2L << 20)) ? 30000L : 10000L; progress.Reset(); CSGInnerNode.ResetStatistics(); lock ( sw ) { sw.Reset(); sw.Start(); } if (checkMultithreading.Checked && Environment.ProcessorCount > 1) { Thread[] pool = new Thread[Environment.ProcessorCount]; int t; for (t = 0; t < pool.Length; t++) { pool[t] = new Thread(new ParameterizedThreadStart(this.RenderWorker)); } for (t = pool.Length; --t >= 0;) { pool[t].Start(new WorkerThreadInit(newImage, width, height, t, pool.Length)); } for (t = 0; t < pool.Length; t++) { pool[t].Join(); pool[t] = null; } } else { MT.InitThreadData(); rend.RenderRectangle(newImage, 0, 0, width, height); } long elapsed; lock ( sw ) { sw.Stop(); elapsed = sw.ElapsedMilliseconds; } string msg = string.Format(CultureInfo.InvariantCulture, "{0:f1}s [ {1}x{2}, f{3:#,#}, mt{4}, r{5:#,#}k, i{6:#,#}k, bb{7:#,#}k, t{8:#,#}k ]", 1.0e-3 * elapsed, width, height, CSGInnerNode.countFaces, checkMultithreading.Checked ? Environment.ProcessorCount : 1, (Intersection.countRays + 500L) / 1000L, (Intersection.countIntersections + 500L) / 1000L, (CSGInnerNode.countBoundingBoxes + 500L) / 1000L, (CSGInnerNode.countTriangles + 500L) / 1000L); SetText(msg); Console.WriteLine("Rendering finished: " + msg); SetImage(newImage); Cursor.Current = Cursors.Default; StopRendering(); }
protected Manifest(MT manifestType) : this((int)manifestType, manifestType.GetEnumDisplayName()) { }
public override void OnInspectorGUI() { MultiTags myScript = (MultiTags)target; EditorGUILayout.LabelField("--------------------------------------------------------------------------------------------------------------------"); GUI.color = Color.green; EditorGUILayout.LabelField("LOCAL ASSIGNED TAGS: "); GUI.color = Color.white; GUILayout.Space(10); foreach (var item in myScript.localTagList.ToArray()) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Tag: ", GUILayout.Width(40)); //EditorGUILayout.TextField(item.Name); EditorGUILayout.SelectableLabel(item.Name, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); GUI.color = Color.red + Color.yellow; if (GUILayout.Button("Remove", GUILayout.Width(55))) { myScript.localTagList.Remove(item); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (!HasTagGlobal(item.Name)) { EditorGUILayout.BeginHorizontal(); GUI.color = Color.yellow; EditorGUILayout.LabelField("warning: (" + item.Name + ") is not a global tag.", GUILayout.Height(25)); GUI.color = Color.white; EditorGUILayout.EndHorizontal(); } } EditorGUILayout.LabelField("--------------------------------------------------------------------------------------------------------------------"); EditorGUILayout.LabelField("--------------------------------------------------------------------------------------------------------------------"); GUI.color = Color.cyan; expandGlobals = EditorGUILayout.Foldout(expandGlobals, "GLOBAL PROJECT TAGS: "); GUI.color = Color.white; if (expandGlobals) { foreach (var itemG in GlobalTagHolder.TagHolder.GlobalTagList.ToArray()) { EditorGUILayout.BeginHorizontal(); if (myScript.gameObject.HasTag(itemG.Name)) { GUI.color = Color.green; EditorGUILayout.LabelField("Assigned ", GUILayout.Width(55)); GUI.color = Color.white; } else { GUI.color = Color.green; //EditorGUILayout.LabelField ("Tag: " + item); if (GUILayout.Button("Assign", GUILayout.Width(55))) { myScript.localTagList.Add(itemG); } GUI.color = Color.white; } EditorGUILayout.LabelField("Tag: ", GUILayout.Width(40)); // EditorGUILayout.LabelField ("Tag: " + itemG.Name); EditorGUILayout.SelectableLabel(itemG.Name, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); GUI.color = Color.red + Color.red; if (GUILayout.Button("Destroy", GUILayout.Width(55))) { GlobalTagHolder.TagHolder.GlobalTagList.Remove(itemG); GlobalTagHolder.TagHolder.Save(); } GUI.color = Color.white; // EditorGUILayout.LabelField ("Description: " + itemAll.Description.ToString (), GUILayout.MaxWidth (160)); //item.Description = EditorGUILayout.TextField ("Description: ", item.Description, GUILayout.MaxWidth(120)); //EditorGUILayout.Separator(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); // itemAll.ID = (byte)EditorGUILayout.IntField ("ReID: ", itemAll.ID, GUILayout.MaxWidth (180)); // itemAll.Name = EditorGUILayout.TextField ("Rename: ", itemAll.Name); EditorGUILayout.EndHorizontal(); // EditorGUILayout.LabelField ("-----------"); } EditorGUILayout.LabelField("--------------------------------------------------------------------------------------------------------------------"); } GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); //tagDescription = GUILayout.TextField(tagDescription,20); tagDescription = EditorGUILayout.TextField("Tag Name: ", tagDescription); GUI.color = Color.cyan; if (GUILayout.Button("Add New Tag", GUILayout.Width(100))) { tagDescription = tagDescription.Trim(); if (string.IsNullOrEmpty(tagDescription)) { return; } MT itemLocal = new MT(); MT itemGlobal = new MT(); itemLocal.Name = tagDescription; // item.ID = 44; // itemLocal.tagGUID = Guid.NewGuid().ToString();; itemGlobal.Name = itemLocal.Name; // itemGlobal.tagGUID = itemLocal.tagGUID; if (!HasTagGlobal(tagDescription)) { GlobalTagHolder.TagHolder.GlobalTagList.Add(itemGlobal); GlobalTagHolder.TagHolder.Save(); } if (!myScript.gameObject.HasTag(tagDescription)) { myScript.localTagList.Add(itemLocal); } tagDescription = string.Empty; } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); GUILayout.Space(20); expandCodeExample = EditorGUILayout.Foldout(expandCodeExample, "CODE EXAMPLE: "); if (expandCodeExample) { GUILayout.TextArea(stringToEdit, 200); } GUILayout.Space(20); // DrawDefaultInspector (); if (GUI.changed) { // Debug.Log ("I Changed"); // foreach (var item in myScript.multiTag) { // if (String.IsNullOrEmpty(item.TestGUID())) { // // item.SetGUID(Guid.NewGuid().ToString()); // // } // } } }