private static bool ProcessFile(string fileName) { Connection c = null; if (_auth != null) { c = new Connection(token: _auth.AccessToken); } else { c = new Connection(token: _token); } if (c != null) { Media m = c.UploadMedia(forceSet: _forceSet, fileName: fileName, forceOverwrite: _forceOverwrite, metaTags: _metaTags.ToArray(), isPublic: _isPublic, license: _license, authorProfileUrl: _authorProfileUrl, localGatewayUrl: _localGatewayUrl); if (m != null) { Console.WriteLine($"'{fileName}' uploaded."); Console.WriteLine($"MediaId: '{m.MediaId}'"); Console.WriteLine($"Associating media to subject: '{_subjectUid}'"); CaptureId ci = _con.AssociateMediaToSubject(m.MediaId, _subjectUid, _forceFeedback); if (ci != null) { Console.WriteLine($"Association successful. CaptureId: '{ci.Id}'"); } return(true); } } return(false); }
/// <summary> /// Get Z height for moving to target. /// </summary> /// <param name="id"></param> /// <returns></returns> public double GetZHeight(CaptureId id) { switch (id) { case CaptureId.VTrayPickTop: return(LoadTrayHeight); case CaptureId.VLoadCompensationBottom: return(GetCapturePosition(CaptureId.VLoadCompensationBottom).ZPosition); case CaptureId.VLoadHolderTop: return(FixtureHeight); case CaptureId.VUnloadHolderTop: return(FixtureHeight); case CaptureId.VUnloadCompensationBottom: return(GetCapturePosition(CaptureId.VUnloadCompensationBottom).ZPosition); case CaptureId.VTrayPlaceTop: return(UnloadTrayHeight); default: throw new NotImplementedException("No such Z height in V station:" + id); } }
public override int GetHashCode() { int hashCode = -1919740922; hashCode = hashCode * -1521134295 + CaptureId.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name); return(hashCode); }
public static AnalysisEntity Create( CaptureId captureId, ITypeSymbol type, ControlFlowGraph controlFlowGraph, bool isLValueFlowCapture) { var interproceduralCaptureId = new InterproceduralCaptureId(captureId, controlFlowGraph, isLValueFlowCapture); return(new AnalysisEntity(interproceduralCaptureId, type)); }
internal CaptureContext( PageContext pageContext, CaptureJson json, Translation translation, CaptureId captureId) { this.pageContext = pageContext; this.json = json; this.captureId = captureId; this.Translation = translation; }
protected override void ComputeHashCodeParts(Action <int> addPart) { addPart(Creation.GetHashCodeOrDefault()); addPart(HashUtilities.Combine(CreationCallStack)); addPart(Symbol.GetHashCodeOrDefault()); addPart(CaptureId.GetHashCodeOrDefault()); addPart(AnalysisEntity.GetHashCodeOrDefault()); addPart(LocationType.GetHashCodeOrDefault()); addPart(_isSpecialSingleton.GetHashCode()); addPart(IsNull.GetHashCode()); }
public CapturePosition GetCapturePositionOffset(CaptureId id) { try { return(Helper.GetCapturePosition(_capturePositionsOffsets, id)); } catch (Exception) { return(new CapturePosition()); } }
public CapturePosition GetCapturePositionWithUserOffset(CaptureId id) { var capPos = GetCapturePosition(id); var userOffset = GetCapturePositionOffset(id); return(new CapturePosition() { CaptureId = id, XPosition = capPos.XPosition + userOffset.XPosition, YPosition = capPos.YPosition + userOffset.YPosition, ZPosition = capPos.ZPosition + userOffset.ZPosition, Angle = capPos.Angle + userOffset.Angle, }); }
private void ReportAxisPosition(CaptureId id) { Task.Run(() => { try { AxisPosition pose = new AxisPosition(); switch (id) { case CaptureId.LTrayPickTop: //break; case CaptureId.LLoadCompensationBottom: //break; case CaptureId.LLoadHolderTop: pose.CaptureId = id; //pose.X = _mc.GetPosition(_mc.MotorLX); //pose.Y = _mc.GetPosition(_mc.MotorLY); //pose.Z = _mc.GetPosition(_mc.MotorLZ); //Todo //log.Info("X:" + pose.X + "Y: " + pose.Y + "Z: " + pose.Z); break; case CaptureId.VTrayPickTop: //break; case CaptureId.VLoadCompensationBottom: //break; case CaptureId.VLoadHolderTop: //break; case CaptureId.VUnloadHolderTop: //break; case CaptureId.VUnloadCompensationBottom: //break; case CaptureId.VTrayPlaceTop: //pose.CaptureId = id; //pose.X = _mc.GetPosition(_mc.MotorVX); //pose.Y = _mc.GetPosition(_mc.MotorVY); break; default: break; } ResponseToVision(pose); } catch (Exception) { //Todo exception. //throw; } }); }
public double GetZHeight(CaptureId id) { switch (id) { case CaptureId.GluePointBeforeGlue: return(LaserAboveFixtureHeight); case CaptureId.GluePointAfterGlue: return(CameraAboveFixtureHeight); case CaptureId.GluePointChina: return(CameraAboveChinaHeight); default: throw new NotImplementedException("No such Z height in Glue staion:" + id); } }
private bool ResultFound(CaptureId captureId, out AxisOffset offset) { lock (_captureResultLocker) { foreach (var result in CaptureResult) { if (result.CaptureId == captureId) { offset = result; CaptureResult.Remove(result); return(true); } } offset = null; return(false); } }
/// <summary> /// Get Z height for move to target method. /// </summary> /// <param name="id"></param> /// <returns></returns> public double GetZHeight(CaptureId id) { switch (id) { case CaptureId.LTrayPickTop: return(LoadTrayHeight); case CaptureId.LLoadCompensationBottom: var capturePos = GetCapturePosition(CaptureId.LLoadCompensationBottom); return(capturePos.ZPosition); case CaptureId.LLoadHolderTop: return(FixtureHeight); default: throw new NotImplementedException("No such Z height in L staion:" + id); } }
/// <summary> /// Match with id and tag. /// </summary> /// <param name="positions"></param> /// <param name="id"></param> /// <param name="tag"></param> /// <returns></returns> public static CapturePosition GetCapturePosition(List <CapturePosition> positions, CaptureId id, string tag) { foreach (var pos in positions) { if (pos.CaptureId == id && pos.Tag == tag) { return(pos); } } throw new Exception("FindCapturePosition fail: " + id); }
public abstract bool IsRValueFlowCapture(CaptureId captureId);
private void OnLValueDereferenceFound(CaptureId captureId) => _currentAnalysisData.OnLValueDereferenceFound(captureId);
private void OnLValueCaptureFound(ISymbol symbol, IOperation operation, CaptureId captureId) => _currentAnalysisData.OnLValueCaptureFound(symbol, operation, captureId);
internal InterproceduralCaptureId(CaptureId captureId, ControlFlowGraph controlFlowGraph, bool isLValueFlowCapture) { Id = captureId; ControlFlowGraph = controlFlowGraph; IsLValueFlowCapture = isLValueFlowCapture; }
public abstract void OnLValueCaptureFound(ISymbol symbol, IOperation operation, CaptureId captureId);
bool IsLValueFlowCapture(CaptureId captureId) => lValueFlowCaptures.ContainsKey(captureId);
public abstract void OnLValueDereferenceFound(CaptureId captureId);
public override void OnLValueCaptureFound(ISymbol symbol, IOperation operation, CaptureId captureId) => throw ExceptionUtilities.Unreachable;
public CapturePosition GetCapturePosition(CaptureId id) { return(Helper.GetCapturePosition(_capturePositions, id)); }
static void Main(string[] args) { string fileName = ""; string dirName = ""; string userName = ""; string password = ""; string tenantId = ""; long mediaTimestamp = 0; string externalMediaId = ""; string originalUrl = ""; string originalLandingUrl = ""; string title = ""; string sourceUrl = ""; string previewUrl = ""; for (int index = 0; index < args.Length; index++) { switch (args[index].ToLower()) { case "-fs": case "-forceset": _forceSet = args.ElementAtOrDefault(++index); if (!_forceSet.Equals("training") && !_forceSet.Equals("validation")) { _forceSet = null; } CheckParam(userName, nameof(userName)); break; case "-f": case "-filename": fileName = args.ElementAtOrDefault(++index).Replace('+', ' '); if (!File.Exists(fileName)) { Kill($"FileName: '{fileName}' does not exist.", -1); } break; case "-d": case "-dirname": dirName = args.ElementAtOrDefault(++index).Replace('+', ' '); if (!Directory.Exists(dirName)) { Kill($"DirName: '{dirName}' does not exist.", -1); } break; case "-u": case "-username": userName = args.ElementAtOrDefault(++index); CheckParam(userName, nameof(userName)); break; case "-p": case "-password": password = args.ElementAtOrDefault(++index); CheckParam(password, nameof(password)); break; case "-tid": case "-tenantid": tenantId = args.ElementAtOrDefault(++index); CheckParam(tenantId, nameof(tenantId)); break; case "-tk": case "-token": _token = args.ElementAtOrDefault(++index); CheckParam(_token, nameof(_token)); break; case "-up": case "-urlprefix": _urlPrefix = args.ElementAtOrDefault(++index); CheckParam(_urlPrefix, nameof(_urlPrefix)); break; case "-lgu": case "-localgatewayurl": _localGatewayUrl = args.ElementAtOrDefault(++index); CheckParam(_localGatewayUrl, nameof(_localGatewayUrl)); break; case "-mt": case "-mediatimestamp": try { mediaTimestamp = Convert.ToInt64(args.ElementAtOrDefault(++index)); } catch (Exception ex) { Kill($"'MediaTimestamp' is invalid: {ex.Message}", -1); } break; case "-fow": case "-forceoverwrite": try { _forceOverwrite = Convert.ToBoolean(args.ElementAtOrDefault(++index)); } catch (Exception ex) { Kill($"'ForceOverwrite' is invalid: {ex.Message}", -1); } break; case "-ff": case "-forcefeedback": try { _forceOverwrite = Convert.ToBoolean(args.ElementAtOrDefault(++index)); } catch (Exception ex) { Kill($"'ForceFeedback' is invalid: {ex.Message}", -1); } break; case "-mtg": case "-metatags": try { index++; while (index < args.Length - 1) { if (args[index].StartsWith("-")) { index--; break; } else { _metaTags.Add(args[index].Replace('+', ' ')); } index++; } if (_metaTags.Count == 0) { Kill($"'MetaTags' is invalid: {args[index]}", -1); } } catch (Exception ex) { Kill($"'MetaTags' is invalid: {ex.Message}", -1); } break; case "-isp": case "-ispublic": try { _isPublic = Convert.ToBoolean(args.ElementAtOrDefault(++index)); } catch (Exception ex) { Kill($"'IsPublic' is invalid: {ex.Message}", -1); } break; case "-emid": case "-externalmediaid": externalMediaId = args.ElementAtOrDefault(++index); CheckParam(externalMediaId, nameof(externalMediaId)); break; case "-ou": case "-originalurl": originalUrl = args.ElementAtOrDefault(++index); CheckParam(originalUrl, nameof(originalUrl)); break; case "-olu": case "-originallandingurl": originalLandingUrl = args.ElementAtOrDefault(++index); CheckParam(originalLandingUrl, nameof(originalLandingUrl)); break; case "-l": case "-license": _license = args.ElementAtOrDefault(++index).Replace('+', ' '); CheckParam(_license, nameof(_license)); break; case "-apu": case "-authorprofileurl": _authorProfileUrl = args.ElementAtOrDefault(++index); CheckParam(_authorProfileUrl, nameof(_authorProfileUrl)); break; case "-t": case "-title": title = args.ElementAtOrDefault(++index).Replace('+', ' '); CheckParam(title, nameof(title)); break; case "-su": case "-sourceurl": sourceUrl = args.ElementAtOrDefault(++index); CheckParam(sourceUrl, nameof(sourceUrl)); break; case "-pu": case "-previewurl": previewUrl = args.ElementAtOrDefault(++index); CheckParam(previewUrl, nameof(previewUrl)); break; case "-suid": case "-subjectuid": _subjectUid = args.ElementAtOrDefault(++index); CheckParam(_subjectUid, nameof(_subjectUid)); break; case "-r": case "-recursive": try { _recursive = Convert.ToBoolean(args.ElementAtOrDefault(++index)); } catch (Exception ex) { Kill($"'Recursive' is invalid: {ex.Message}", -1); } break; case "-h": case "-help": DisplayUsage(); Kill(null, 0); break; default: Kill($"Error parsing argument: '{args[index]}'. Terminating...\r\nUse option '-h' or '-help' for the correct syntax.", -1); break; } } // Input parsed, do the uploading. Stopwatch sw = new Stopwatch(); sw.Start(); try { // Some validation if (string.IsNullOrEmpty(fileName) && string.IsNullOrEmpty(dirName)) { Kill($"'FileName' or 'DirName' not provided. Terminating...", -1); } if (string.IsNullOrEmpty(_subjectUid)) { Kill($"'SubjectUid' is not provided. Terminating...", -1); } if (!string.IsNullOrEmpty(_token)) { Console.WriteLine($"Connecting to the Cogniac public API with provided token..."); _con = new Connection(token: _token, urlPrefix: _urlPrefix); } else { Console.WriteLine($"Connecting to the Cogniac public API as: '{userName}'..."); _con = new Connection(userName, password, tenantId, urlPrefix: _urlPrefix); } if (_con != null) { Console.WriteLine("Connected to Cogniac."); Console.WriteLine($"Current tenant ID: '{tenantId}'"); _auth = _con.GetAuthObject(); if (!string.IsNullOrEmpty(fileName)) { Media m = _con.UploadMedia(_forceSet, fileName, mediaTimestamp, _forceOverwrite, _metaTags.ToArray(), _isPublic, externalMediaId, originalUrl, originalLandingUrl, _license, _authorProfileUrl, title, sourceUrl, previewUrl, _localGatewayUrl); if (m != null) { Console.WriteLine($"'{fileName}' uploaded."); Console.WriteLine($"MediaId: '{m.MediaId}'"); Console.WriteLine($"Associating media to subject: '{_subjectUid}'"); CaptureId ci = _con.AssociateMediaToSubject(m.MediaId, _subjectUid, _forceFeedback); if (ci != null) { Console.WriteLine($"Association successful. CaptureId: '{ci.Id}'"); } } } if (!string.IsNullOrEmpty(dirName)) { DirectoryInfo di = new DirectoryInfo(dirName); WalkDirectoryTree(di); if (_isRecursiveError) { Console.WriteLine($"Processed: '{dirName}' but with errors, please see above log."); } else { Console.WriteLine($"Processed: '{dirName}' fully."); } if (_recursive) { Console.WriteLine("Processing was done recursively to all sub-directories."); } } } sw.Stop(); Console.WriteLine($"Execution time: '{sw.Elapsed}'"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public override bool IsRValueFlowCapture(CaptureId captureId) => throw ExceptionUtilities.Unreachable;
bool IsRValueFlowCapture(CaptureId captureId) => !lValueFlowCaptures.TryGetValue(captureId, out var captureKind) || captureKind != FlowCaptureKind.LValueCapture;
public override void OnLValueDereferenceFound(CaptureId captureId) => throw ExceptionUtilities.Unreachable;
/// <summary> /// For unload tray locating. /// </summary> /// <param name="id"></param> /// <param name="tag"></param> /// <returns></returns> public CapturePosition GetCapturePosition(CaptureId id, string tag = "1") { return(Helper.GetCapturePosition(_capturePositions, id, tag)); }