protected bool HasLink(IIOContainer pinContainer) { try { var connected = pinContainer.GetPluginIO().IsConnected; foreach (var associated in pinContainer.AssociatedContainers) { connected |= associated.GetPluginIO().IsConnected; } return(connected); } catch (InvalidComObjectException) { // [Import]s not yet ready. try another time. // its safe to assume that no pins have been created yet. FLogger.Log(LogType.Warning, "Not fully initialized [" + this.GetType().Name + "]."); return(false); } catch (Exception) { string nodePath = PluginHost.GetNodePath(false); FLogger.Log(LogType.Error, "Failed to protect a " + this.GetType().Name + " node: " + nodePath); return(false); } }
private bool RecompileIfNeeded(CSProject project) { if (!IsAssemblyUpToDate(project)) { FLogger.Log(LogType.Message, "Assembly of {0} is not up to date. Need to recompile ...", project.Name); var isLoaded = project.IsLoaded; if (!isLoaded) { project.Load(); } project.ProjectCompiledSuccessfully -= project_ProjectCompiled; project.Compile(); project.ProjectCompiledSuccessfully += project_ProjectCompiled; if (!isLoaded) { project.Unload(); } if (project.CompilerResults.Errors.HasErrors) { FLogger.Log(LogType.Error, GetCompileErrorsLog(project, project.CompilerResults)); return(false); } } return(true); }
//called when data for any output pin is requested public override void Evaluate(int SpreadMax) { var FieldCount = Getters.Count; if (FLearn[0] && FInput.SliceCount > 0 && FInput[0] != null) { var type = FInput[0].GetType(); FLogger.Log(LogType.Debug, "Learning Type... " + type.FullName); FieldInfo[] fields = type.GetFields(); FieldCount = fields.Length; FName.SliceCount = FieldCount; Getters.Clear(); var formular = new MessageFormular(type.FullName, ""); for (var i = 0; i < FieldCount; i++) { var name = fields[i].Name; FName[i] = name; var fieldInfo = type.GetField(name); try { formular.Append(new FormularFieldDescriptor(fieldInfo.FieldType, name, 1), true); var getter = fieldInfo.CompileGetter(); Getters.Add(name, getter); FLogger.Log(LogType.Debug, "Success: " + fieldInfo.FieldType.Name + " " + name); } catch (Exception) { FLogger.Log(LogType.Debug, "Failed: " + fieldInfo.FieldType.Name + " " + name); //FLogger.Log(ex, LogType.Debug); } } Formular = formular; } SpreadMax = FInput.SliceCount; FOutput.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { var m = new Message(Formular.Name); foreach (var fieldName in Formular.FieldNames) { var getter = Getters[fieldName]; var bin = BinFactory.New(Formular[fieldName].Type); bin.Add(getter(FInput[i])); m[fieldName] = bin; } FOutput[i] = m; } }
public override void WriteAll() { FLogger.Log(LogType.Message, "ChunkWriter: Started writing all files"); IOMessages.CurrentState = "Started writing all files"; foreach (Chunk chunk in _chunkManager.ChunkList) { Write(chunk); } }
public override void ReadAll() { FLogger.Log(LogType.Message, "ChunkReader: Started caching all files"); IOMessages.CurrentState = "Started caching all files"; foreach (Chunk chunk in _chunkManager.ChunkList) { Read(chunk); } }
public bool RemoveFromFactory() { if ((State == SearchPathState.DisablePending) || (IsGarbage)) { FLogger.Log(LogType.Debug, "removing " + Dir + " from " + Factory.Name); Factory.RemoveDir(Dir); State = SearchPathState.Disabled; return(true); } return(false); }
protected void DeleteArtefacts(string dir) { // Nothing to do if not existent. if (FHDEHost.IsBlackBoxMode || !Directory.Exists(dir)) { return; } // Dynamic plugins generate a new assembly everytime they are compiled. // Cleanup old assemblies. var mostRecentFiles = new Dictionary <string, Tuple <string, DateTime> >(); foreach (var file in Directory.GetFiles(dir, "*.dll")) { try { var match = MsBuildProject.DynamicRegExp.Match(file); if (match.Success) { var fileName = match.Groups[1].Value; var currentFileTupe = new Tuple <string, DateTime>(file, File.GetLastWriteTime(file)); if (mostRecentFiles.ContainsKey(fileName)) { // We've seen this file before. var mostRecentFileTuple = mostRecentFiles[fileName]; if (currentFileTupe.Item2 > mostRecentFileTuple.Item2) { // Current file is newer than most recent -> delete most recent and set current as new most recent. mostRecentFiles[fileName] = currentFileTupe; File.Delete(mostRecentFileTuple.Item1); File.Delete(mostRecentFileTuple.Item1.Replace(".dll", ".pdb")); } else { // Current file is older than most recent -> delete it. File.Delete(currentFileTupe.Item1); File.Delete(currentFileTupe.Item1.Replace(".dll", ".pdb")); } } else { mostRecentFiles.Add(fileName, currentFileTupe); } } } catch (Exception e) { FLogger.Log(e); } } }
#pragma warning restore protected override SvgDocument ReadDocument(int slice) { SvgDocument doc = null; try { doc = SvgDocument.Open(FFilenameIn[slice]); } catch (Exception e) { FLogger.Log(e); } return(doc); }
Dictionary <ushort, Tuple <string, QOS> > FUnsubscribeStatus = new Dictionary <ushort, Tuple <string, QOS> >(); //matches unsubscribe commands to packet ids #endregion fields public override void Dispose() { try { foreach (var tup in FSubscriptions) { FClient.Unsubscribe(new string[] { tup.Item1 }); } } catch (Exception e) { FLogger.Log(e); } base.Dispose(); }
#pragma warning restore protected override SvgDocument ReadDocument(int slice) { SvgDocument doc = null; try { var s = new MemoryStream(UTF8Encoding.Default.GetBytes(FXMLIn[slice])); doc = SvgDocument.Open(s, null); } catch (Exception e) { FLogger.Log(e); } return(doc); }
private void Reconstruct() { if (this.scanner.IsScanning()) { string desktop = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); var time = DateTime.Now.ToString("hhmmss", System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat); var fileName = desktop + "\\" + string.Format("model-{0}.{1}", time, PXCM3DScan.FileFormatToString(this.fileFormat)); FLogger.Log(LogType.Debug, "fileName: " + fileName); var sts = this.scanner.Reconstruct(this.fileFormat, fileName); if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR) { FLogger.Log(LogType.Debug, sts.ToString()); } } }
protected override void UpdateFrame() { // フレームを取得する pxcmStatus ret = this.senseManager.AcquireFrame(true); if (ret < pxcmStatus.PXCM_STATUS_NO_ERROR) { if (ret == pxcmStatus.PXCM_STATUS_EXEC_ABORTED) { // do noting } else { throw new Exception("フレームの取得に失敗しました: " + ret.ToString()); } } // フレームデータを取得する PXCMCapture.Sample sample = this.senseManager.QuerySample(); if (sample == null) { FLogger.Log(LogType.Debug, "フレームデータの取得に失敗しました"); return; } if (FInMode[0] == Mode.Color) { this.image = sample.color; } else if (FInMode[0] == Mode.Depth) { this.image = sample.depth; } if (this.image != null) { this.invalidate = true; } // 手のデータを更新する this.UpdateHandFrame(); this.senseManager.ReleaseFrame(); }
public CustomQueryInterfaceResult GetInterface(ref Guid iid, out IntPtr ppv) { if (iid.Equals(Guid.Parse("00000112-0000-0000-c000-000000000046"))) { ppv = Marshal.GetComInterfaceForObject(LayoutPanel, typeof(IOleObject)); return(CustomQueryInterfaceResult.Handled); } else if (iid.Equals(Guid.Parse("458AB8A2-A1EA-4d7b-8EBE-DEE5D3D9442C"))) { ppv = Marshal.GetComInterfaceForObject(LayoutPanel, typeof(IWin32Window)); return(CustomQueryInterfaceResult.Handled); } else { FLogger.Log(LogType.Debug, "missing: " + iid.ToString()); ppv = IntPtr.Zero; return(CustomQueryInterfaceResult.NotHandled); } }
public bool AddToFactory() { if (State == SearchPathState.AddPending) { if (File.Exists(Nodelist) && Factory.AllowCaching) { FLogger.Log(LogType.Debug, "adding " + Dir + " to " + Factory.Name + " (cached by " + Nodelist + ")"); CollectFromNodeList(); } else { FLogger.Log(LogType.Debug, "adding " + Dir + " to " + Factory.Name); Factory.AddDir(Dir, Recursive); } State = SearchPathState.Added; return(true); } return(false); }
protected override async Task ParseFile() { FLogger.Log(LogType.Message, "ChunkImporter: Analyzing Data"); IOMessages.CurrentState = "Analyzing Data"; try { using (var stream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultBufferSize, DefaultFileOptions)) using (var reader = new StreamReader(stream)) { string line; bool firstLine = true; Vector3D boundsMin = new Vector3D(); Vector3D boundsMax = new Vector3D(); Lines = 0; // needed to calculate progress Char delimiter = ' '; while ((line = await reader.ReadLineAsync()) != null) { if (line.Length > 0 && Lines >= skipLines) { String[] lineStrings = line.Split(delimiter); if (lineStrings[0] == "v") { double x = double.Parse(lineStrings[DataStructure["x"] + 1], CultureInfo.InvariantCulture); double y = double.Parse(lineStrings[DataStructure["y"] + 1], CultureInfo.InvariantCulture); double z = double.Parse(lineStrings[DataStructure["z"] + 1], CultureInfo.InvariantCulture); if (firstLine) { boundsMin = new Vector3D(x, y, z); boundsMax = new Vector3D(x, y, z); } else { Vector3D newMinVec = boundsMin; if (newMinVec.x > x) { newMinVec.x = x; } if (newMinVec.y > y) { newMinVec.y = y; } if (newMinVec.z > z) { newMinVec.z = z; } boundsMin = newMinVec; Vector3D newMaxVec = boundsMax; if (newMaxVec.x < x) { newMaxVec.x = x; } if (newMaxVec.y < y) { newMaxVec.y = y; } if (newMaxVec.z < z) { newMaxVec.z = z; } boundsMax = newMaxVec; } firstLine = false; Lines++; // update linecount } } } BoundsMax = boundsMax; BoundsMin = boundsMin; } } catch (Exception e) { FLogger.Log(LogType.Error, e.ToString()); IOMessages.CurrentState = e.ToString(); } }
protected override async Task ParseFile() { FLogger.Log(LogType.Message, "ChunkImporter: Analyzing Data"); IOMessages.CurrentState = "Analyzing Data"; try { using (var stream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultBufferSize, DefaultFileOptions)) using (var reader = new StreamReader(stream)) { string line; Vector3D boundsMin = new Vector3D(); Vector3D boundsMax = new Vector3D(); bool firstLine = true; bool header = true; string dataStructureString = ""; int lineCounter = 0; Char delimiter = ' '; while ((line = await reader.ReadLineAsync()) != null) { String[] lineStrings = line.Split(delimiter); if (header) { if (lineStrings[0] == "format") { if (lineStrings[1] == "ascii") { format = PLY_FORMAT_ASCII; } if (lineStrings[1] == "binary_little_endian") { format = PLY_FORMAT_LE; } if (lineStrings[1] == "binary_big_endian ") { format = PLY_FORMAT_BE; } } if (lineStrings[0] == "element" && lineStrings[1] == "vertex") { Lines = int.Parse(lineStrings[2]); } if (lineStrings[0] == "property") { if (lineStrings[2] == "x") { dataStructureString += "x"; } else if (lineStrings[2] == "y") { dataStructureString += "y"; } else if (lineStrings[2] == "z") { dataStructureString += "z"; } else if (lineStrings[2] == "red") { dataStructureString += "r"; } else if (lineStrings[2] == "green") { dataStructureString += "g"; } else if (lineStrings[2] == "blue") { dataStructureString += "b"; } else { dataStructureString += "_"; } } if (lineStrings[0] == "end_header") { header = false; SetDataStructure(dataStructureString); } } else { if (format != PLY_FORMAT_ASCII) { throw new FormatException("PLY files in binary format are not supported."); } double x = double.Parse(lineStrings[DataStructure["x"]], CultureInfo.InvariantCulture); double y = double.Parse(lineStrings[DataStructure["y"]], CultureInfo.InvariantCulture); double z = double.Parse(lineStrings[DataStructure["z"]], CultureInfo.InvariantCulture); if (firstLine) { boundsMin = new Vector3D(x, y, z); boundsMax = new Vector3D(x, y, z); } else { Vector3D newMinVec = boundsMin; if (newMinVec.x > x) { newMinVec.x = x; } if (newMinVec.y > y) { newMinVec.y = y; } if (newMinVec.z > z) { newMinVec.z = z; } boundsMin = newMinVec; Vector3D newMaxVec = boundsMax; if (newMaxVec.x < x) { newMaxVec.x = x; } if (newMaxVec.y < y) { newMaxVec.y = y; } if (newMaxVec.z < z) { newMaxVec.z = z; } boundsMax = newMaxVec; } firstLine = false; lineCounter++; if (lineCounter == Lines) { break; // all vertices are parsed now -> break } } } BoundsMax = boundsMax; BoundsMin = boundsMin; } } catch (Exception e) { FLogger.Log(LogType.Error, e.ToString()); IOMessages.CurrentState = e.ToString(); } }
private bool IsAssemblyUpToDate(CSProject project) { var assemblyLocation = project.AssemblyLocation; if (assemblyLocation == null) { return(false); } if (!File.Exists(assemblyLocation)) { return(false); } var now = DateTime.Now; var projectTime = new [] { File.GetLastWriteTime(project.LocalPath) } .Concat(project.Documents.Select(d => File.GetLastWriteTime(d.LocalPath))) .Max(); var assemblyTime = File.GetLastWriteTime(assemblyLocation); // This can happen in case the computer time is wrong or // in a different time zone than the project was created in. if (now < projectTime) { projectTime = now - TimeSpan.FromSeconds(10.0); } if (projectTime <= assemblyTime) { // We also need to check if the version info of the referenced assemblies // is the same as the one referenced by the project file. // We only check the PluginInterfaces assembly here to save performance. try { var assembly = Assembly.ReflectionOnlyLoadFrom(assemblyLocation); var piAssembly = assembly.GetReferencedAssemblies().Where(assemblyName => assemblyName.Name == typeof(IPluginBase).Assembly.GetName().Name).FirstOrDefault(); if (piAssembly != null && piAssembly.Version != FPluginInterfacesVersion) { return(false); } switch (project.BuildConfiguration) { case BuildConfiguration.Release: return(!IsAssemblyDebugBuild(assembly)); case BuildConfiguration.Debug: return(IsAssemblyDebugBuild(assembly)); default: return(true); } } catch (Exception e) { // Log the exception and return true FLogger.Log(e); return(true); } } return(false); }
public override void Evaluate(int spreadMax) { base.Evaluate(spreadMax); if ((FClient != null) && FClient.IsConnected) { HashSet <Tuple <string, QOS> > currentSubscriptions = new HashSet <Tuple <string, QOS> >(); List <Tuple <string, QOS> > newSubscriptions = new List <Tuple <string, QOS> >(); for (int i = 0; i < spreadMax; i++) { #region sending if (FInSend[i]) { if (FInTopic[i].Contains("/#") || FInTopic[i].Contains("/*")) { FMessageStatusQueue.Enqueue("Topic at slice " + i.ToString() + " contains illegal characters for publishing"); } else { var packetId = FClient.Publish(FInTopic[i], UTF8Enc.GetBytes(FInMessage[i]), (byte)FInQoS[i], FInRetained[i]); FPublishStatus.Add(packetId); } } if (FInRemoveRetained[i]) { FClient.Publish(FInTopic[i], new byte[] { }, (byte)0, true); } #endregion sending //subscription and unsubscription has to be handled outside this loop //unsubscription has to be triggered first (matters in the case of same topic with different qos) #region receiving if (FInReceive[i]) { var tup = new Tuple <string, QOS>(FInTopic[i], FInQoS[i]); currentSubscriptions.Add(tup); if (!FSubscriptions.Remove(tup)) { newSubscriptions.Add(tup); } } #endregion receiving } #region unsubscribe try { if (FSubscriptions.Count > 0) { foreach (var tuple in FSubscriptions) { var unsubscribeId = FClient.Unsubscribe(new string[] { tuple.Item1 }); FUnsubscribeStatus.Add(unsubscribeId, tuple); } } FSubscriptions = new HashSet <Tuple <string, QOS> >(currentSubscriptions); } catch (Exception e) { FLogger.Log(e); foreach (var s in currentSubscriptions) { FSubscriptions.Add(s); } } #endregion unsubscribe #region subscribe if (FNewSession) { newSubscriptions.AddRange(FSubscriptions); FNewSession = false; } foreach (var subs in newSubscriptions) { try { var subscribeId = FClient.Subscribe(new string[] { subs.Item1 }, new byte[] { (byte)subs.Item2 }); FSubscribeStatus.Add(subscribeId, subs); } catch { FLogger.Log(LogType.Warning, string.Format("couldn't subscribe to {0} with qos {1}", subs.Item1, subs.Item2)); } } #endregion subscribe } if (FMessageStatusQueue.Count > 0) { FOutMessageStatus.AssignFrom(FMessageStatusQueue.ToArray()); FMessageStatusQueue.Clear(); } FOutTopic.AssignFrom(FPacketQueue.Select(x => x.Topic).ToArray()); FOutMessage.AssignFrom(FPacketQueue.Select(x => UTF8Enc.GetString(x.Message))); FOutQoS.AssignFrom(FPacketQueue.Select(x => (QOS)x.QosLevel)); FOutIsRetained.AssignFrom(FPacketQueue.Select(x => x.Retain)); FOutOnData[0] = FPacketQueue.Count > 0; FPacketQueue.Clear(); FOutboundCount[0] = FPublishStatus.Count; }
void LogIDFix(SvgElement elem, string oldID, string newID) { var msg = "ID of " + elem + " was changed from " + oldID + " to " + newID; FLogger.Log(LogType.Warning, msg); }
private void UpdateHandFrame() { if (this.handData == null) { return; } this.handData.Update(); //ピクセルデータを初期化する Array.Clear(this.imageBuffer, 0, this.imageBuffer.Length); // 検出した手の数を取得する var numOfHands = this.handData.QueryNumberOfHands(); FOutHandID.SliceCount = 0; for (int i = 0; i < numOfHands; i++) { int handID = -1; pxcmStatus sts = this.handData.QueryHandId(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, i, out handID); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { FLogger.Log(LogType.Debug, "手のIDの取得に失敗しました"); continue; } FOutHandID.SliceCount = 1 + i; FOutHandID[i] = handID; // 手を取得する PXCMHandData.IHand hand; sts = this.handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_ID, i, out hand); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { FLogger.Log(LogType.Debug, "手のデータの取得に失敗しました"); continue; } PXCMImage.ImageData data; if (FInMode[0] == Mode.Mask) { // 手の画像を取得する sts = hand.QuerySegmentationImage(out this.image); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { FLogger.Log(LogType.Debug, "手の画像の取得に失敗しました"); continue; } if (this.image != null) { this.invalidate = true; } // マスク画像を取得する sts = this.image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_Y8, out data); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { FLogger.Log(LogType.Debug, "マスク画像の取得に失敗しました"); continue; } // マスク画像のサイズはDepthに依存 // 手は2つまで var info = this.image.QueryInfo(); // マスク画像をバイト列に変換する var buffer = data.ToByteArray(0, data.pitches[0] * info.height); for (int j = 0; j < info.height * info.width; ++j) { if (buffer[j] != 0) { var index = j * BYTE_PER_PIXEL; // 手のインデックスで色を決める // ID = 0 : 127 // ID = 1 : 254 var value = (byte)((i + 1) * 127); imageBuffer[index + 0] = value; imageBuffer[index + 1] = value; imageBuffer[index + 2] = value; imageBuffer[index + 3] = 255; } } this.image.ReleaseAccess(data); } // 指の関節を列挙する int jointCount = PXCMHandData.NUMBER_OF_JOINTS; FOutJointPositionWorld.SliceCount = jointCount * (1 + i); FOutJointPositionImage.SliceCount = jointCount * (1 + i); for (int j = 0; j < jointCount; j++) { int sliceIndex = i * jointCount + j; PXCMHandData.JointData jointData; sts = hand.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { FOutJointPositionWorld[sliceIndex] = new Vector3D(0.0f, 0.0f, 0.0f); FOutJointPositionImage[sliceIndex] = new Vector3D(0.0f, 0.0f, 0.0f); continue; } if (FInMode[0] == Mode.Color) { // Depth座標系をカラー座標系に変換する var depthPoint = new PXCMPoint3DF32[1]; var colorPoint = new PXCMPointF32[1]; depthPoint[0].x = jointData.positionImage.x; depthPoint[0].y = jointData.positionImage.y; depthPoint[0].z = jointData.positionWorld.z * 1000; projection.MapDepthToColor(depthPoint, colorPoint); Vector3D posWorld = new Vector3D(colorPoint[0].x, jointData.positionWorld.y, jointData.positionWorld.z); Vector3D posImage = new Vector3D(colorPoint[0].x, colorPoint[0].y, 0.0f); FOutJointPositionWorld[sliceIndex] = posWorld; FOutJointPositionImage[sliceIndex] = posImage; } else { Vector3D posWorld = new Vector3D(jointData.positionWorld.x, jointData.positionWorld.y, jointData.positionWorld.z); Vector3D posImage = new Vector3D(jointData.positionImage.x, jointData.positionImage.y, jointData.positionImage.z); FOutJointPositionWorld[sliceIndex] = posWorld; FOutJointPositionImage[sliceIndex] = posImage; } } // 手の重心を表示する var center = hand.QueryMassCenterWorld(); Vector3D centerPosition = new Vector3D(center.x, center.y, center.z); FOutMassCenter[0] = centerPosition; } }
public override void Evaluate(int SpreadMax) { // quit early. this will keep the last valid output until situation is resolved if (RemovePinsFirst) { if (!RetryConfig()) { throw new PinConnectionException("Manually remove unneeded links first! [Split]. ID = [" + PluginHost.GetNodePath(false) + "]"); } else { LayoutChanged = true; } } if (!FInput.IsChanged && !LayoutChanged) { return; } SpreadMax = FInput.IsAnyInvalid() ? 0 : FInput.SliceCount; if (SpreadMax <= 0) { foreach (string name in FPins.Keys) { FPins[name].ToISpread().FlushNil(); } FTopic.FlushNil(); FTimeStamp.FlushNil(); return; } FTimeStamp.SliceCount = SpreadMax; FTopic.SliceCount = SpreadMax; foreach (string name in FPins.Keys) { FPins[name].ToISpread().SliceCount = SpreadMax; } for (int i = 0; i < SpreadMax; i++) { Message message = FInput[i]; FTopic[i] = message.Topic; FTimeStamp[i] = message.TimeStamp; foreach (string name in FPins.Keys) { var targetPin = FPins[name].ToISpread(); var targetBin = targetPin[i] as ISpread; Bin sourceBin = message[name]; int count = 0; if (sourceBin as object == null) { if (FVerbose[0]) { FLogger.Log(LogType.Warning, "\"" + Formular[name].Type + " " + name + "\" is not defined in Message [" + message.Topic + "], so skipped its bin at \"" + PluginHost.GetNodePath(false) + "\"."); } } else { count = sourceBin.Count; } targetBin.SliceCount = count; for (int j = 0; j < count; j++) { targetBin[j] = sourceBin[j]; } } } FTimeStamp.Flush(); FTopic.Flush(); foreach (string name in FPins.Keys) { FPins[name].ToISpread().Flush(); } // no need to worry next frame. all's well, because node did not fail early LayoutChanged = false; }
public override void Evaluate(int SpreadMax) { TypeUpdate(); SpreadMax = (FSelect[0] != SelectEnum.First) ? FInput.SliceCount : 1; if (!FInput.IsChanged) { // FLogger.Log(LogType.Debug, "skip split"); return; } bool empty = (FInput.SliceCount == 0) || (FInput[0] == null); if (empty && (FHold[0] == HoldEnum.Off)) { foreach (string name in FPins.Keys) { var pin = ToISpread(FPins[name]); pin.SliceCount = 0; pin.Flush(); } FAddress.SliceCount = 0; FTimeStamp.SliceCount = 0; FAddress.Flush(); FTimeStamp.Flush(); return; } if (!empty) { foreach (string pinName in FPins.Keys) { if (FSelect[0] == SelectEnum.All) { ToISpread(FPins[pinName]).SliceCount = SpreadMax; FTimeStamp.SliceCount = SpreadMax; FAddress.SliceCount = SpreadMax; } else { ToISpread(FPins[pinName]).SliceCount = 1; FTimeStamp.SliceCount = 1; FAddress.SliceCount = 1; } } for (int i = (FSelect[0] == SelectEnum.Last) ? SpreadMax - 1 : 0; i < SpreadMax; i++) { Message message = FInput[i]; FAddress[i] = message.Address; FTimeStamp[i] = message.TimeStamp.ToString(); FAddress.Flush(); FTimeStamp.Flush(); foreach (string name in FPins.Keys) { var bin = (VVVV.PluginInterfaces.V2.NonGeneric.ISpread)ToISpread(FPins[name])[i]; SpreadList attrib = message[name]; int count = 0; if (attrib == null) { if (FVerbose[0]) { FLogger.Log(LogType.Debug, "\"" + FTypes[name] + " " + name + "\" is not defined in Message."); } } else { count = attrib.Count; } if ((count > 0) || (FHold[0] != HoldEnum.Pin)) { bin.SliceCount = count; for (int j = 0; j < count; j++) { bin[j] = attrib[j]; } ToISpread(FPins[name]).Flush(); } else { // keep old values in pin. do not flush } } } } }
public override void Evaluate(int SpreadMax) { if (RemovePinsFirst) { RetryConfig(); } if (!FInput.IsChanged) { return; } SpreadMax = FInput.IsAnyInvalid() ? 0 : FInput.SliceCount; if (SpreadMax <= 0) { foreach (string name in FPins.Keys) { var pin = FPins[name].ToISpread(); pin.SliceCount = 0; pin.Flush(); } FTopic.SliceCount = 0; FTimeStamp.SliceCount = 0; FTopic.Flush(); FTimeStamp.Flush(); return; } FTimeStamp.SliceCount = SpreadMax; FTopic.SliceCount = SpreadMax; foreach (string name in FPins.Keys) { FPins[name].ToISpread().SliceCount = SpreadMax; } for (int i = 0; i < SpreadMax; i++) { Message message = FInput[i]; FTopic[i] = message.Topic; FTimeStamp[i] = message.TimeStamp; foreach (string name in FPins.Keys) { var targetPin = FPins[name].ToISpread(); var targetBin = targetPin[i] as ISpread; Bin sourceBin = message[name]; int count = 0; if (sourceBin as object == null) { FLogger.Log(LogType.Warning, "\"" + Formular[name].Type + " " + name + "\" is not defined in Input Message."); } else { count = sourceBin.Count; } targetBin.SliceCount = count; for (int j = 0; j < count; j++) { targetBin[j] = sourceBin[j]; } } } FTimeStamp.Flush(); FTopic.Flush(); foreach (string name in FPins.Keys) { FPins[name].ToISpread().Flush(); } }
private void CollectFromNodeList() { var baseDir = Path.GetDirectoryName(Nodelist); using (var streamReader = new StreamReader(Nodelist)) { var settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Ignore; using (var xmlReader = XmlReader.Create(streamReader, settings)) { while (xmlReader.ReadToFollowing("NODE")) { var factory = xmlReader.GetAttribute("factory"); if (factory != Factory.Name) { continue; } var name = xmlReader.GetAttribute("name"); var category = xmlReader.GetAttribute("category"); var version = xmlReader.GetAttribute("version"); var filename = Path.Combine(baseDir, xmlReader.GetAttribute("filename")); var nodeInfo = FNodeInfoFactory.CreateNodeInfo(name, category, version, filename, true); nodeInfo.Factory = Factory; nodeInfo.Ignore = int.Parse(xmlReader.GetAttribute("ignore")) == 0 ? false : true; nodeInfo.AutoEvaluate = int.Parse(xmlReader.GetAttribute("autoevaluate")) == 0 ? false : true; nodeInfo.Type = (NodeType)NodeType.Parse(typeof(NodeType), xmlReader.GetAttribute("type")); nodeInfo.Arguments = xmlReader.GetAttribute("arguments"); var ibs = xmlReader.GetAttribute("ibs"); nodeInfo.InitialBoxSize = new System.Drawing.Size(int.Parse(ibs.Split(',')[0]), int.Parse(ibs.Split(',')[1])); var iws = xmlReader.GetAttribute("iws"); nodeInfo.InitialWindowSize = new System.Drawing.Size(int.Parse(iws.Split(',')[0]), int.Parse(iws.Split(',')[1])); nodeInfo.InitialComponentMode = (TComponentMode)NodeType.Parse(typeof(TComponentMode), xmlReader.GetAttribute("icm")); try { Factory.ParseNodeEntry(xmlReader, nodeInfo); } catch (Exception e) { FLogger.Log(e); } using (var nodeReader = xmlReader.ReadSubtree()) { while (nodeReader.Read()) { switch (nodeReader.Name) { case "TAGS": nodeInfo.Tags = nodeReader.ReadString().TrimEnd(); break; case "SHORTCUT": nodeInfo.Shortcut = nodeReader.ReadString().TrimEnd(); break; case "HELP": nodeInfo.Help = nodeReader.ReadString().TrimEnd(); break; case "WARNINGS": nodeInfo.Warnings = nodeReader.ReadString().TrimEnd(); break; case "BUGS": nodeInfo.Bugs = nodeReader.ReadString().TrimEnd(); break; case "AUTHOR": nodeInfo.Author = nodeReader.ReadString().TrimEnd(); break; case "CREDITS": nodeInfo.Credits = nodeReader.ReadString().TrimEnd(); break; } } } nodeInfo.CommitUpdate(); } } } }
public IPluginBase CreatePlugin(INodeInfo nodeInfo, IPluginHost2 pluginHost) { IPluginBase plugin = null; string assemblyLocation = string.Empty; var isUpToDate = GetAssemblyLocation(nodeInfo, out assemblyLocation); // HACK: pluginHost is null in case of WindowSwitcher/NodeBrowser/etc. Fix this. if (pluginHost != null) { // Mark the node if old assembly was loaded and log warning. if (!isUpToDate) { pluginHost.Status |= StatusCode.HasInvalidData; FLogger.Log(LogType.Warning, string.Format("Plugin of node '{0}' (ID: {1}) is out of date and couldn't be recompiled. Check its source code for errors.", nodeInfo.Username, pluginHost.GetID())); } else { pluginHost.Status &= ~StatusCode.HasInvalidData; } } var assembly = Assembly.LoadFrom(assemblyLocation); //Check if need to start anything before rest is loaded FStartableRegistry.ProcessAssembly(assembly); var type = assembly.GetType(nodeInfo.Arguments); // type can be null if assembly is corrupt or doesn't contain cached node info anymore if (type != null) { var attribute = GetPluginInfoAttributeData(type); if (attribute != null) { var pluginContainer = new PluginContainer( pluginHost as IInternalPluginHost, FIORegistry, FParentContainer, FNodeInfoFactory, this, type, nodeInfo); // We intercept the plugin to manage IOHandlers. plugin = pluginContainer; FPluginContainers[pluginContainer.PluginBase] = pluginContainer; // HACK: FPluginHost is null in case of WindowSwitcher and friends if (pluginHost != null) { AssignOptionalPluginInterfaces(pluginHost as IInternalPluginHost, pluginContainer.PluginBase); } // Send event, clients are not interested in wrapping plugin, so send original here. if (this.PluginCreated != null) { this.PluginCreated(pluginContainer.PluginBase, pluginHost); } } else { var v1Plugin = (IPlugin)assembly.CreateInstance(nodeInfo.Arguments); v1Plugin.SetPluginHost(pluginHost); plugin = v1Plugin; // HACK: FPluginHost is null in case of WindowSwitcher and friends if (pluginHost != null) { AssignOptionalPluginInterfaces(pluginHost as IInternalPluginHost, plugin); } // Send event if (this.PluginCreated != null) { this.PluginCreated(plugin, pluginHost); } } } else { pluginHost.Status |= StatusCode.HasInvalidData; FLogger.Log(LogType.Warning, string.Format("Type '{0}' not found in assembly '{1}'. Failed to create plugin node {2} (ID: {3}).", nodeInfo.Arguments, assembly.FullName, nodeInfo.Username, pluginHost.GetID())); } return(plugin); }
protected override async Task ImportData() { FLogger.Log(LogType.Message, "ChunkImporter: Importing Data"); IOMessages.CurrentState = "Importing Data"; try { using (var stream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultBufferSize, DefaultFileOptions)) using (var reader = new StreamReader(stream)) { string line; Char delimiter = ' '; while ((line = await reader.ReadLineAsync()) != null) { if (line.Length > 0 && LinesProcessed >= skipLines) { String[] lineStrings = line.Split(delimiter); if (lineStrings[0] == "v") { ParticleData particleData = new ParticleData(); Triple <int, int, int> chunkId = new Triple <int, int, int>(); chunkId.x = 0; chunkId.y = 0; chunkId.z = 0; if (DataStructure.ContainsKey("x")) { Single x = Single.Parse(lineStrings[DataStructure["x"] + 1], CultureInfo.InvariantCulture); x += (Single)Offsets.x; x *= (Single)ScaleValue; particleData.x = x; chunkId.x = Convert.ToInt32(Math.Floor((x - BoundsMin.x) / ChunkSize.x)); if (chunkId.x < 0) { chunkId.x = 0; } if (chunkId.x >= ChunkCount.x) { chunkId.x = ChunkCount.x - 1; } } if (DataStructure.ContainsKey("y")) { Single y = Single.Parse(lineStrings[DataStructure["y"] + 1], CultureInfo.InvariantCulture); y += (Single)Offsets.y; y *= (Single)ScaleValue; particleData.y = y; chunkId.y = Convert.ToInt32(Math.Floor((y - BoundsMin.y) / ChunkSize.y)); if (chunkId.y < 0) { chunkId.y = 0; } if (chunkId.y >= ChunkCount.y) { chunkId.y = ChunkCount.y - 1; } } if (DataStructure.ContainsKey("z")) { Single z = Single.Parse(lineStrings[DataStructure["z"] + 1], CultureInfo.InvariantCulture); z += (Single)Offsets.z; z *= (Single)ScaleValue; particleData.z = z; chunkId.z = Convert.ToInt32(Math.Floor((z - BoundsMin.z) / ChunkSize.z)); if (chunkId.z < 0) { chunkId.z = 0; } if (chunkId.z >= ChunkCount.z) { chunkId.z = ChunkCount.z - 1; } } int chunkIndex = chunkId.x + chunkId.y * ChunkCount.x + chunkId.z * ChunkCount.x * ChunkCount.y; if (chunkIndex > 0 && chunkIndex < _chunkManager.ChunkList.Count) { Chunk chunk = _chunkManager.ChunkList[chunkIndex]; chunk.BinaryWriter.Write(particleData.GetByteArray()); chunk.UpdateElementCount(); } LinesProcessed++; // update count of processed lines -> needed to calculate progress if (LinesProcessed == Lines) { break; // all vertices are parsed now -> break } } } } _chunkManager.UpdateElementCount(); IOMessages.CurrentState = "Finished"; } } catch (Exception e) { FLogger.Log(LogType.Error, e.ToString()); IOMessages.CurrentState = e.ToString(); } }