public ServerSterling(TLServer tls, int sleepOnNodata, int sleepAfterOrder, DebugDelegate deb) { SendDebug = deb; tl = tls; _SLEEP = 50; _ORDERSLEEP = sleepAfterOrder; }
/// <summary> /// takes all or part of quandl object and converts it into GT /// </summary> /// <param name="ro"></param> /// <param name="datecol"></param> /// <param name="valcol"></param> /// <param name="startrow"></param> /// <param name="endrow"></param> /// <returns></returns> public static GenericTracker<decimal> Qdl2GT(RootObject ro, string datecol, string valcol, int startrow, int endrow, DebugDelegate d) { // get columns var datecolidx = GetQdlColidx(ro,datecol); var valcolidx = GetQdlColidx(ro,valcol); // slice out the data var subset = GetAllRows(ro, startrow, endrow, d); // get date column var dates = QdlCol2Dates( GetColumn(subset, datecolidx)); var vals =QdlCol2Vals( GetColumn(subset, valcolidx)); // populate GT GenericTracker<decimal> gt = new GenericTracker<decimal>(dates.Count); for (int i = 0; i < dates.Count; i++) { var val = vals[i]; var dt = dates[i]; if (val == qh.ERROR_VALUE) continue; if (dt == qh.ERROR_DATE) continue; var tldate = Util.ToTLDate(dt); gt.addindex(tldate.ToString("F0"), val); } return gt; }
public static void Send(string gmailuser, string password, string to, string subject, string message, TradeLink.API.DebugDelegate deb) { d = deb; try { MailMessage mail = new MailMessage(); System.Net.NetworkCredential cred = new System.Net.NetworkCredential (gmailuser, password); mail.To.Add(to); mail.Subject = subject; mail.From = new MailAddress(gmailuser); mail.IsBodyHtml = true; mail.Body = message; SmtpClient smtp = new SmtpClient("smtp.gmail.com"); smtp.UseDefaultCredentials = false; smtp.EnableSsl = true; smtp.Credentials = cred; smtp.Port = 587; smtp.SendCompleted += new SendCompletedEventHandler(s_SendCompleted); smtp.Send(mail); } catch (Exception ex) { debug("Error sending email from: " + gmailuser + " to: " + to + " subject: " + subject + " err: " + ex.Message + ex.StackTrace); } }
public ConvertMap(List<int> importmap, List<string> custval, ConvertMapType t, bool ignoreinvalid, DebugDelegate deb, DebugDelegate stat) { cust = custval; ignoreinvalidtick = ignoreinvalid; inp = importmap; type = t; SendDebugEvent = deb; SendStatusEvent = stat; }
public static bool hasMaxFails(string task, int maxfail, DebugDelegate deb) { var t = GetTask(task); bool max = t.isValid && (t.Successes == 0) && (t.Failures > maxfail); if (max && (deb != null)) deb(task + " hit maximum failures " + t.Failures + " with no success."); return max; }
public RunHelper(VoidDelegate start, VoidDelegate end, DebugDelegate deb, string name) { OnStart = start; OnEnd = end; Name = name; OnDebug = deb; bw.DoWork += new System.ComponentModel.DoWorkEventHandler(bw_DoWork); bw.WorkerReportsProgress = false; }
public SkinImpl(object response, string responsename, string dll, DebugDelegate deb) { // save class name _class = responsename; // save dll if (havedll(dll)) _dll = dll; // serialize props and save _props = serializeprops(GetType(_class, _dll), response,deb); }
public AsyncTextureReader(RenderTexture texture) { Status = ReadStatus.Idle; Texture = texture; var sync = System.Environment.GetEnvironmentVariable("FORCE_SYNC_GPU_READBACK"); if (sync != null) { if (SystemInfo.supportsAsyncGPUReadback) { Type = ReadType.Native; ReadFormat = TextureFormat.RGB24; BytesPerPixel = 3; return; } if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLCore && SystemInfo.operatingSystemFamily == OperatingSystemFamily.Linux) { var version = SystemInfo.graphicsDeviceVersion; version = version.Split(new char[] { ' ' }, 3)[1]; var parts = version.Split(new char[] { '.' }); int major = int.Parse(parts[0]); int minor = int.Parse(parts[1]); Debug.Log($"OpenGL version = {major}.{minor}"); if (major > 3 || major == 3 && minor >= 2) // GL_ARB_sync { debug = new DebugDelegate(DebugCallback); AsyncTextureReaderSetDebug(Marshal.GetFunctionPointerForDelegate(debug)); Debug.Assert(texture.dimension == TextureDimension.Tex2D); Debug.Assert(texture.format == RenderTextureFormat.ARGB32); LinuxId = AsyncTextureReaderCreate(texture.GetNativeTexturePtr(), texture.width, texture.height); if (LinuxId >= 0) { LinuxUpdate = AsyncTextureReaderGetUpdate(); GL.IssuePluginEvent(LinuxUpdate, LinuxId); Type = ReadType.LinuxOpenGL; ReadFormat = TextureFormat.RGBA32; BytesPerPixel = 4; return; } } } } Type = ReadType.Sync; ReadFormat = TextureFormat.RGB24; BytesPerPixel = 3; ReadTexture = new Texture2D(texture.width, texture.height, ReadFormat, false); }
public static List <ChannelMessage> FromFile(DebugDelegate d, string path, int defaultkey = 5, int defaultnote_ms = Adiago.NOTE_DEFAULT_DUR_MS) { setd(d); var data = getfile(path, d); if (string.IsNullOrWhiteSpace(data)) { debug("No song data obtained at: " + path); return(new List <ChannelMessage>()); } return(Quick(d, data, defaultkey, defaultnote_ms)); }
public static bool hasMaxFails(string task, int maxfail, DebugDelegate deb) { var t = GetTask(task); bool max = t.isValid && (t.Successes == 0) && (t.Failures > maxfail); if (max && (deb != null)) { deb(task + " hit maximum failures " + t.Failures + " with no success."); } return(max); }
public SkinImpl(object response, string responsename, string dll, DebugDelegate deb) { // save class name _class = responsename; // save dll if (havedll(dll)) { _dll = dll; } // serialize props and save _props = serializeprops(GetType(_class, _dll), response, deb); }
public ServerNxCore(TLServer tls, string filename, int SaveStateInterval, bool Verbose, DebugDelegate debugs) { _fn = filename; _islive = _fn == LIVEFEED; _nxsyms.NewTxt += new TextIdxDelegate(_syms_NewTxt); SendDebugEvent = debugs; SaveStateIntervalSec = SaveStateInterval; VerboseDebugging = Verbose; d = debugs; debug(Util.TLSIdentity()); _proc = new System.Threading.Thread(proc); tl = tls; tl.newProviderName = Providers.Nanex; tl.newFeatureRequest += new MessageArrayDelegate(ServerNxCore_newFeatureRequest); tl.newRegisterSymbols += new SymbolRegisterDel(tl_newRegisterSymbols); savestateint = (uint)(SaveStateIntervalSec * 1000); debug((tl.VerboseDebugging ? "Verbose is on" : "Verbose is off")); if (isLive) { debug("Running in live mode."); DOLIVESKIPTEST = true; // if live and no previous state, remove old state files if (!hasstate) { debug("No state file found for today, removing previous states..."); System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Util.ProgramData(PROGRAM)); System.IO.FileInfo[] fis = di.GetFiles("nxstate.*.tmp"); foreach (System.IO.FileInfo fi in fis) { try { System.IO.File.Delete(fi.FullName); debug("removed: " + fi.FullName); } catch { } } } else { debug("Will use saved state to advance tape position at startup: " + statefilepath); _fn = statefilepath; } DOSAVESTATE = SaveStateIntervalSec != 0; if (DOSAVESTATE) { debug("Will save tape position every: " + SaveStateIntervalSec + " seconds."); } else { debug("State saving disabled because SaveStateInterval is 0"); } } }
public ServerNxCore(TLServer tls, string filename, int SaveStateInterval, bool Verbose, DebugDelegate debugs) { _fn = filename; _islive = _fn == LIVEFEED; _nxsyms.NewTxt += new TextIdxDelegate(_syms_NewTxt); SendDebugEvent = debugs; SaveStateIntervalSec = SaveStateInterval; VerboseDebugging = Verbose; d = debugs; debug(Util.TLSIdentity()); _proc = new System.Threading.Thread(proc); tl = tls; tl.newProviderName = Providers.Nanex; tl.newFeatureRequest += new MessageArrayDelegate(ServerNxCore_newFeatureRequest); tl.newRegisterSymbols += new SymbolRegisterDel(tl_newRegisterSymbols); savestateint = (uint)(SaveStateIntervalSec * 1000); debug((tl.VerboseDebugging ? "Verbose is on" : "Verbose is off")); if (isLive) { debug("Running in live mode."); DOLIVESKIPTEST = true; // if live and no previous state, remove old state files if (!hasstate) { debug("No state file found for today, removing previous states..."); System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Util.ProgramData(PROGRAM)); System.IO.FileInfo[] fis = di.GetFiles("nxstate.*.tmp"); foreach (System.IO.FileInfo fi in fis) { try { System.IO.File.Delete(fi.FullName); debug("removed: " + fi.FullName); } catch { } } } else { debug("Will use saved state to advance tape position at startup: " + statefilepath); _fn = statefilepath; } DOSAVESTATE = SaveStateIntervalSec != 0; if (DOSAVESTATE) debug("Will save tape position every: " + SaveStateIntervalSec + " seconds."); else debug("State saving disabled because SaveStateInterval is 0"); } }
public static void TestParse(DebugDelegate d, OutputDevice dev) { setd(d); debug("Note parse test..."); dev.PlayParse(d, "//hello world", "c,d,e,f,g,a,b,6c"); debug("Chord parse test..."); dev.stop(); //dev.PlayChord<c5>(c5.c, c5.e, c5.g); dev.PlayParse(d, "bpm30", " c+e+g"); debug("All simple parse tests ok."); //Console.ReadLine(); }
public HistSimIndexPlay(HistSimIndex hsi, DebugDelegate deb) { _folder = hsi.Folder; if (deb != null) { GotDebug += deb; } _reader.DoWork += new DoWorkEventHandler(_reader_DoWork); _reader.WorkerSupportsCancellation = true; myhsi = hsi; hsip_avail = hsi.Playindex.Length; checkindex(); }
public static void Prompt(string program, string basepath, AuthInfo ai, bool pause, string promptmsg, DebugDelegate deb) { PROGRAM = program; BASEPATH = basepath+"\\"; aip = new AuthInfoPrompt(ai); aip.status(promptmsg); aip.NewAuthInfo += new AuthInfoDelegate(aip_NewAuthInfo); d = deb; if (pause) aip.ShowDialog(); else aip.Show(); }
public ServerRithmic(TLServer tls, DebugDelegate dd) { debs = dd; tl = tls; // set defaults PRI_bLoggedIntoMd = false; PRI_bGotPriceIncrInfo = false; PRI_oAccount = null; PRI_bGotAccounts = false; PRI_bLoggedIntoTs = false; PRI_bOrderComplete = false; }
/// <summary> /// get quandl data given row and column information /// </summary> /// <param name="ro"></param> /// <param name="datacolname"></param> /// <param name="dataidx"></param> /// <param name="d"></param> /// <returns></returns> public static object GetQdlData(RootObject ro, string datacolname, int dataidx, DebugDelegate d) { _d = d; // check column name var colidx = ro.column_names.IndexOf(datacolname); if (colidx < 0) { debug(ro.id + " can't get data because non existant colname: " + datacolname + " on set: " + ro.code); return(null); } return(GetQdlData(ro, colidx, dataidx, d)); }
public static ResponseModelView LoadResponseView(string name, string dll, DebugDelegate d) { _d = d; var rmv = new ResponseModelView(); // verify file exists if (string.IsNullOrWhiteSpace(dll)) { sdebug("No dll provided, user can specifiy new dll in response view."); return(rmv); } if (string.IsNullOrWhiteSpace(name)) { sdebug("Responses not being used."); return(rmv); } if (!System.IO.File.Exists(dll)) { sdebug("Dll no longer exists at: " + dll + ", user can specifiy new dll in response view."); return(rmv); } // load response var r = ResponseLoader.FromDLL(name, dll, d); if ((r == null) || !r.isValid) { sdebug("Unable to load response: " + name + " from: " + dll); return(rmv); } var inds = ResponseLoader.GetIndicators(dll, name, d); rmv = new ResponseModelView(inds); rmv.response = r; // update it rmv._rdll = dll; // bind it rmv.bind(inds); // get any user settable values rmv.settablenames = ResponseLoader.GetSettableList(dll, name, d); if (rmv.isValid) { sdebug("Loaded response: " + name + " from: " + dll); } else { sdebug("Response missing sym/symbol indicator: " + name + " in: " + dll); rmv = new ResponseModelView(); } return(rmv); }
/// <summary> /// upload todays tickdata to a portal /// </summary> /// <param name="space"></param> /// <param name="un"></param> /// <param name="pw"></param> /// <param name="ticket"></param> /// <param name="workpath"></param> /// <param name="debug"></param> /// <returns></returns> public static bool UploadTodaysTicks(string space, string un, string pw, int ticket, string workpath, DebugDelegate debug) { bool r = true; try { List<string> files = TikUtil.GetFilesFromDate(); string fn = workpath + "\\TickData." + Util.ToTLDate() + ".zip"; r &= ZipFile(fn, files, string.Empty, debug); if (TradeLink.AppKit.AssemblaDocument.Create(space, un, pw, fn, ticket, false)) { if (debug != null) { debug("tick data upload succeeded for: " + fn); } } else { if (debug != null) { r &= false; debug("tick data upload failed for: " + fn); } } if (System.IO.File.Exists(fn)) { try { System.IO.File.Delete(fn); } catch (Exception ex) { r &= false; if (debug != null) { debug("unable to delete local copy: " + fn); debug(ex.Message + ex.StackTrace); } } } } catch (Exception ex) { r &= false; if (debug != null) { debug("unknown error uploading ticks. "); debug(ex.Message + ex.StackTrace); } } return r; }
public static List <ChannelMessage> Quick(DebugDelegate d, string data, int defaultkey = 5, int defaultms_note = Adiago.NOTE_DEFAULT_DUR_MS) { setd(d); debug("Parsing song: " + data); var lines = data.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); List <ChannelMessage> song = new List <ChannelMessage>(); int n = 0, c = 0; foreach (var line in lines) { var tonegroups = line.Split(','); foreach (var tonegroup in tonegroups) { if (tonegroup.Contains("+")) { c++; var chordtones = tonegroup.Split('+'); v("Chord#" + c + ": " + tonegroup + " starting chord..."); for (int i = 0; i < chordtones.Length; i++) { var ct = chordtones[i]; n++; // start chord (add any beat/delay after fully defined) if (i == chordtones.Length) { song.AddRange(GetNote(ct, defaultkey, defaultms_note, true, false)); } else { song.AddRange(GetNote(ct, defaultkey, 0, true, false)); } } v("Chord#" + c + ": " + tonegroup + " ending chord..."); foreach (var ct in chordtones) { // end chord song.AddRange(GetNote(ct, defaultkey, 0, false, true)); } } else { n++; song.AddRange(GetNote(tonegroup, defaultkey, defaultms_note)); } } } debug("From " + data.Length.ToString("n0") + "bytes of short notes, obtained chords: " + c.ToString("n0") + " w/notes: " + n.ToString("n0")); return(song); }
public static List <ChannelMessage> FromFile(DebugDelegate d, string path) { setd(d); var data = getfile(path, d); if (string.IsNullOrWhiteSpace(data)) { debug("No song data obtained at: " + path); return(new List <ChannelMessage>()); } var name = System.IO.Path.GetFileNameWithoutExtension(path) + "-" + Util.ToPCDate().ToString(); return(Quick(d, data, name)); }
public static void GetHelp(DebugDelegate d, string helparg, bool showgeneral = false) { HelpType ht; if (!isHelp(helparg, out ht)) { if (showgeneral) { GetHelp(d, HelpType.General); } return; } GetHelp(d, ht); }
public SkinImpl(object response, string dll,DebugDelegate deb) { // cast to a response Response r = (Response)response; // get name _class = r.FullName; // make sure name exists if (r.FullName == string.Empty) throw new Exception("cant import response with empty fullname. use ResponseLoader or call a Skin method with full classname. "); // get dll if (havedll(dll)) _dll = dll; // get properties _props = serializeprops(GetType(_class, _dll), response,deb); }
/// <summary> /// Create a single Response from a DLL containing many Responses. /// </summary> /// <param name="fullname"></param> /// <param name="dllname"></param> /// <param name="deb"></param> /// <returns></returns> public static Response FromDLL(string fullname, string dllname, DebugDelegate deb) { try { return(FromDLL(fullname, dllname)); } catch (Exception ex) { if (deb != null) { deb(ex.Message + ex.StackTrace); } } return(null); }
/// <summary> /// gets decimal qdl value /// </summary> /// <param name="ro"></param> /// <param name="colname"></param> /// <param name="dataidx"></param> /// <param name="d"></param> /// <returns></returns> public static decimal GetQdlValue(RootObject ro, string colname, int dataidx, DebugDelegate d) { if (_d == null) { _d = d; } var obj = GetQdlData(ro, colname, dataidx, d); decimal v = ERROR_VALUE; if ((obj != null) && decimal.TryParse(obj.ToString(), out v)) { return(v); } return(ERROR_VALUE); }
public static GenericTracker <Screener> fetchscreen(string url, DebugDelegate deb) { // get raw list string[][] raw = fetchrawlist(url, deb); debug("beginning screen indexing of " + raw.GetLength(0) + " screens."); GenericTracker <Screener> ss = new GenericTracker <Screener>(raw.GetLength(0), "SCREENS"); foreach (string[] r in raw) { Screener s = getscreen(r); ss.addindex(s.symbol, s); } debug("completed index of " + ss.Count + " screens."); return(ss); }
/// <summary> /// Create a single Response from an Assembly containing many Responses. /// </summary> /// <param name="a"></param> /// <param name="fullname"></param> /// <param name="deb"></param> /// <returns></returns> public static Response FromAssembly(System.Reflection.Assembly a, string fullname, DebugDelegate deb) { try { return FromAssembly(a, fullname); } catch (Exception ex) { if (deb != null) { deb(ex.Message + ex.StackTrace); } } return null; }
public TLServer_IP(string ipaddr, int port, int wait, int TickBufferSize, DebugDelegate deb) { SendDebugEvent = deb; if (TickBufferSize == 0) _queueb4send = false; else tickq = new RingBuffer<Tick>(TickBufferSize); MinorVer = Util.ProgramBuild(Util.PROGRAM,debug); _wait = wait; if (!IPUtil.isValidAddress(ipaddr)) debug("Not valid ip address: " + ipaddr + ", using localhost."); _addr = IPUtil.isValidAddress(ipaddr) ? IPAddress.Parse(ipaddr) : IPAddress.Loopback; _port = port; v("tlserver_ip wait: " + _wait); Start(); }
public static string[] GetIndicators(string dll, string responsename, DebugDelegate d) { var r = ResponseLoader.FromDLL(responsename, dll, d); if ((r == null) || !r.isValid) { return(new string[0]); } bindtmp(r); try { r.Reset(); } catch { } return(r.Indicators); }
public static Results GetResults(string name, List <Trade> trades, DebugDelegate gotDebug, decimal riskFreeRate = .01m, decimal commissionPerShare = .01m) { name = Path.GetFileNameWithoutExtension(name); List <TradeResult> newResults; if (trades.Count == 0) { gotDebug("No results found for: " + name); newResults = new List <TradeResult>(); } else { newResults = TradeResult.ResultsFromTradeList(trades); } return(FetchResults(newResults, riskFreeRate, commissionPerShare, gotDebug)); }
/// <summary> /// Create a single Response from a DLL containing many Responses. /// </summary> /// <param name="fullname"></param> /// <param name="dllname"></param> /// <param name="deb"></param> /// <returns></returns> public static Response FromDLL(string fullname, string dllname, DebugDelegate deb) { try { return FromDLL(fullname, dllname); } catch (Exception ex) { if (deb != null) { deb(ex.Message + ex.StackTrace); } } return null; }
public static void Chopsticks(DebugDelegate d, OutputDevice dev) { setd(d); dev.SetInstrument <InstrumentGuide>(InstrumentGuide.HonkyTonkPiano); dev.PlayNotes <c4>(300, c4.c, c4.c); dev.PlayNotes <c4>(1000, c4.c); dev.PlayNotes <c4>(300, c4.c); dev.PlayNotes <c3>(300, c3.b, c3.A, c3.b); dev.PlayNotes <c4>(300, c4.c, c4.d, c4.e, c4.e); dev.PlayNotes <c4>(1000, c4.e); dev.PlayNotes <c4>(300, c4.d, c4.c, c4.d, c4.e, c4.f); dev.PlayNotes <c4>(1000, c4.g); dev.PlayNotes <c4>(1000, c4.c); dev.stop(); }
/// <summary> /// gets a quandl data object directly from url /// </summary> /// <param name="qurl"></param> /// <param name="TryCache"></param> /// <param name="d"></param> /// <returns></returns> public static RootObject Get(string qurl, bool TryCache, DebugDelegate d) { if (_d == null) { _d = d; } var path = BarListImpl.GetDBLoc(PROGRAM, qurl.GetHashCode().ToString(), 7, DateTime.Now, getformatext(DefaultQuadlFormat)); if (TryCache) { if (System.IO.File.Exists(path)) { try { var raw = Util.getfile(path, d); var dataok = !string.IsNullOrWhiteSpace(raw) && (raw.Length > 0); if (dataok) { var data = isCacheCompressed ? GZip.Uncompress(raw) : raw; return(json.Deserialize2Root(data, false, d)); } } catch (Exception ex) { debug("Will ignore cache and repull as error reading cache for: " + qurl + " , err: " + ex.Message + ex.StackTrace); } } } // pull data var urldata = Util.geturl(qurl, d); var isurldataok = !string.IsNullOrWhiteSpace(urldata) && (urldata.Length > 0); if (isurldataok) { var compdata = isCacheCompressed ? GZip.Compress(urldata) : urldata; if (Util.setfile(path, compdata)) { v("Cached " + urldata.Length.ToString("N0") + " bytes of qurl: " + qurl); } else { v("Error caching: " + qurl + ", will repull next time."); } } return(json.Deserialize2Root(urldata, false, d)); }
public static List <string> GetResponseList(string dllfilepath, DebugDelegate d) { List <string> reslist = new List <string>(); if (!File.Exists(dllfilepath)) { return(reslist); } Assembly a; try { a = Assembly.LoadFile(dllfilepath); } catch (Exception ex) { reslist.Add(ex.Message); return(reslist); } return(GetResponseList(a, d)); }
public static void Prompt(string program, string basepath, AuthInfo ai, bool pause, string promptmsg, DebugDelegate deb) { PROGRAM = program; BASEPATH = basepath + "\\"; aip = new AuthInfoPrompt(ai); aip.status(promptmsg); aip.NewAuthInfo += new AuthInfoDelegate(aip_NewAuthInfo); d = deb; if (pause) { aip.ShowDialog(); } else { aip.Show(); } }
/// <summary> /// Renders the bloom-effect pipe. /// </summary> /// <param name="gd">The <see cref="GraphicsDevice" />.</param> /// <param name="sb">The <see cref="SpriteBatch" />.</param> /// <param name="name">The name of the render-run for better identification later on or when debugging.</param> /// <param name="irt">The input-<see cref="RenderTarget2D" />.</param> /// <param name="ort">The output-<see cref="RenderTarget2D" />.</param> /// <param name="s">The bloom-<see cref="Setting" />.</param> /// <param name="debugDelegate"> /// The debug delegate to use (gets called on every individual <see cref="RenderPhase" /> to /// enable debug-output outside of this class). /// </param> public void Render(GraphicsDevice gd, SpriteBatch sb, string name, Texture2D irt, RenderTarget2D ort, Setting s, DebugDelegate debugDelegate = null) { Clear(gd); // Pass 1: draw the scene into render-target 1, using a // shader that extracts only the brightest parts of the image. ExtractEffect.Parameters["BloomThreshold"].SetValue((float)s.BloomThreshold.Value); sb.DrawFullscreenQuad(irt, BloomRenderTarget1, ExtractEffect); debugDelegate?.Invoke(name, BloomRenderTarget1, RenderPhase.EXTRACT); // Pass 2: draw from render-target 1 into render-target 2, // using a shader to apply a horizontal Gaussian blur filter. SetBlurEffectParameters(1.0f / BloomRenderTarget1.Width, 0, s); // The Sampler has to be on anisotropic lookup to smooth the pixels for the blur correctly. sb.DrawFullscreenQuad(BloomRenderTarget1, BloomRenderTarget2, GaussianBlurEffect, null, SamplerState.AnisotropicClamp); debugDelegate?.Invoke(name, BloomRenderTarget2, RenderPhase.BLUR_HORIZONTAL); // Pass 3: draw from render-target 2 back into render-target 1, // using a shader to apply a vertical Gaussian blur filter. SetBlurEffectParameters(0, 1.0f / BloomRenderTarget2.Height, s); // The Sampler has to be on anisotropic lookup to smooth the pixels for the blur correctly. sb.DrawFullscreenQuad(BloomRenderTarget2, BloomRenderTarget1, GaussianBlurEffect, null, SamplerState.AnisotropicClamp); debugDelegate?.Invoke(name, BloomRenderTarget1, RenderPhase.BLUR_VERTICAL); // Pass 4: draw both render-target 1 and the original scene // image back into the main back-Buffer, using a shader that // combines them to produce the final bloomed result. var parameters = CombineEffect.Parameters; parameters["BloomIntensity"].SetValue((float)s.BloomIntensity.Value); parameters["BaseIntensity"].SetValue((float)s.BaseIntensity.Value); parameters["BloomSaturation"].SetValue((float)s.BloomSaturation.Value); parameters["BaseSaturation"].SetValue((float)s.BaseSaturation.Value); parameters[5].SetValue(irt); sb.DrawFullscreenQuad(BloomRenderTarget1, ort, CombineEffect); debugDelegate?.Invoke(name, ort, RenderPhase.COMBINE); }
public HistSimIndexPlay(string folder, TickFileFilter tff, int interval, DebugDelegate deb) { if (deb != null) { GotDebug += deb; } _folder = folder + "\\"; // see if we have index string fn; HistSimIndex hsi; debug("getting tickfiles, please wait..."); string[,] total = tff.bUseCSV ? ChimeraDataUtils.TickFileIndex(folder, "*_trades.csv", true) : Util.TickFileIndex(folder, TikConst.WILDCARD_EXT, false); debug("found " + total.GetLength(0).ToString("N0") + " tickfiles"); string[,] filtered = tff.AllowsIndexAndSize(total); debug("post-filter: " + filtered.GetLength(0).ToString("N0") + ", checking for index..."); if (HistSimIndex.HaveIndex(folder, filtered, out fn, deb, tff.bUseCSV)) { debug("index found, starting load: " + fn); hsi = HistSimIndex.FromFile(fn, debug); if (hsi == null) { debug("unable to load index."); return; } hsi.GotDebug += new DebugDelegate(debug); } else if (HistSimIndex.BuildIndex(folder, filtered, out hsi, true, true, interval, debug, tff.bUseCSV)) { debug("Index built successfully, ready to play."); } else { debug("Error building index..."); return; } _reader.DoWork += new DoWorkEventHandler(_reader_DoWork); _reader.WorkerSupportsCancellation = true; myhsi = hsi; hsip_avail = hsi.Playindex.Length; checkindex(); }
public static RunHelper run(VoidDelegate start, VoidDelegate complete, DebugDelegate deb, string name) { debs = deb; RunHelper rh = new RunHelper(); if (rh.isBusy) { debug("must wait until previous job completed. " + name); return rh; } if (start == null) throw new Exception("cannot pass a null start delegate to run helper!"); rh = new RunHelper(start, complete, deb, name); rh.bw.RunWorkerAsync(rh); return rh; }
/// <summary> /// gets quandl data given row and column information /// </summary> /// <param name="ro"></param> /// <param name="datacolname"></param> /// <param name="dataidx"></param> /// <param name="d"></param> /// <returns></returns> public static object GetQdlData(RootObject ro, int colidx, int dataidx, DebugDelegate d) { if (_d == null) { _d = d; } // check data index if ((dataidx < 0) || (dataidx >= ro.data.Count)) { debug(ro.id + " can't get data because invalid data index: " + dataidx + " on set: " + ro.code); return(null); } // get object return(ro.data[dataidx][colidx]); }
//-----------------------------// //- Functions -// //-----------------------------// public void Initialize() { if (isInitialized && meshReader != null) { return; } if (debugInfo) { DebugDelegate callback_delegate = new DebugDelegate(CallbackDebug); System.IntPtr intptr_delegate = Marshal.GetFunctionPointerForDelegate(callback_delegate); ReaderAPIPRM.SetDebugFunction(intptr_delegate); } //initial mesh reader if (meshReader == null) { meshReader = MeshReaderPRM.CreateMeshReader(ref apiKey); if (meshReader == null) { Debug.Log("[MeshPlayerPlugin][WARNING] Create Reader Instance Failed"); return; } } //initial audio reader if (audioReader == null) { audioReader = AudioReader.CreateAudioReader(meshReader.GetMeshApiKey()); if (audioReader == null) { Debug.Log("[MeshPlayerPlugin][WARNING] Create Reader Instance Failed"); return; } } meshComponent = GetComponent <MeshFilter>(); rendererComponent = GetComponent <Renderer>(); isFirstMeshDataArrived = false; isFirstAudioDataArrived = false; isFirstAudioPtsRecord = false; isInitialized = true; }
public static string Serialize(HistSimIndex hsi, DebugDelegate debug) { try { hsi.packTOC(); XmlSerializer xs = new XmlSerializer(typeof(HistSimIndex)); StringWriter fs = new StringWriter(); xs.Serialize(fs, hsi); fs.Close(); string msg = fs.GetStringBuilder().ToString(); return GZip.Compress(msg); } catch (Exception ex) { if (debug != null) debug(ex.Message + ex.StackTrace); } return string.Empty; }
public RoslynCodeBase([CanBeNull] DebugDelegate debugOut = null) { #if DEBUG _debugFn = debugOut ?? DebugFn0; #else _debugFn = debugOut ?? ((s, i) => { }); #endif TextDestination = new DrawingGroup(); DrawingBrush = new DrawingBrush(); UpdateChannel = Channel.CreateUnbounded <UpdateInfo>(new UnboundedChannelOptions() { SingleReader = true, SingleWriter = true }); PixelsPerDip = 1.0; OutputWidth = 6.5 * 96; LineSpacing = FontFamily.LineSpacing; LineHeight = LineSpacing * FontSize; }
public static bool SetAuthInfo(string file, AuthInfo ai, DebugDelegate deb) { try { System.IO.StreamWriter sw = new System.IO.StreamWriter(file, false); sw.WriteLine(ai.Username); sw.WriteLine(ai.Password); sw.Close(); return true; } catch (Exception ex) { if (deb != null) { deb("error saving file: " + file + " with: " + ex.Message + ex.StackTrace); } } return false; }
public static bool SetAuthInfo(string file, AuthInfo ai, DebugDelegate deb) { try { System.IO.StreamWriter sw = new System.IO.StreamWriter(file, false); sw.WriteLine(ai.Username); sw.WriteLine(ai.Password); sw.Close(); return(true); } catch (Exception ex) { if (deb != null) { deb("error saving file: " + file + " with: " + ex.Message + ex.StackTrace); } } return(false); }
public static bool ToFile(HistSimIndex hsi, string path, DebugDelegate debug) { try { // get checksum of data string md5 = MD5(indextoc(hsi)); // see if it's complete if (!hsi.isComplete) { if (debug != null) { debug("Index not completed " + md5); } return(false); } // get index directory string dir = Path.GetDirectoryName(path); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } // get filepath string filepath = dir + "\\" + md5 + ".txt"; // pack contents so serializable hsi.packTOC(); XmlSerializer xs = new XmlSerializer(typeof(HistSimIndex)); Stream fs = new FileStream(filepath, FileMode.Create); System.IO.Compression.GZipStream gs = new System.IO.Compression.GZipStream(fs, System.IO.Compression.CompressionMode.Compress); xs.Serialize(gs, hsi); gs.Close(); fs.Close(); } catch (Exception ex) { if (debug != null) { debug(ex.Message + ex.StackTrace); } return(false); } return(true); }
public static void HelloMix(DebugDelegate d, OutputDevice dev) { // play every mix PremixDel[] hello_mixes = new PremixDel[] { TestParse, TriadChord, Chopsticks, TestChord, TestDurations, TestTracks, TrackDur, TestKey, }; foreach (var mix in hello_mixes) { PlayMix(d, dev, mix); } }
public static string GetUserResponseName(string dll, DebugDelegate debs) { rname = string.Empty; // get all responses var all = TradeLink.Common.ResponseLoader.GetResponseList(dll,debs); // prompt user ResponseList rl = new ResponseList(all); rl.ResponseSelected += new DebugDelegate(rl_ResponseSelected); if (rl.ShowDialog() != DialogResult.OK) { rname = string.Empty; if (debs != null) debs("User canceled response name selection."); } rl = null; // return result return rname; }
public static AuthInfo GetAuthInfo(string filepath,DebugDelegate deb) { AuthInfo ai = new AuthInfo(); try { System.IO.StreamReader sr = new System.IO.StreamReader(filepath); // skip user ai.Username = sr.ReadLine(); // get password ai.Password = sr.ReadLine(); sr.Close(); return ai; } catch (Exception ex) { if (deb != null) { deb("exception opening: "+filepath+" "+ex.Message + ex.StackTrace); } } return ai; }
/// <summary> /// Create a single Response from an Assembly containing many Responses. /// </summary> /// <param name="a">the assembly object</param> /// <param name="boxname">The fully-qualified Response Name (as in Response.FullName).</param> /// <returns></returns> public static Response FromAssembly(System.Reflection.Assembly a, string fullname, DebugDelegate deb) { Response b = null; try { Type type; object[] args; // get class from assembly type = a.GetType(fullname, true, true); args = new object[] { }; // create an instance of type and cast to response b = (Response)Activator.CreateInstance(type, args); // if it doesn't have a name, add one if (b.Name == string.Empty) { b.Name = type.Name; } if (b.FullName == string.Empty) { b.FullName = type.FullName; } return b; } catch (Exception ex) { if (deb != null) { deb(ex.Message + ex.StackTrace); } b = new InvalidResponse(); b.Name = ex.Message + ex.StackTrace; return b; } }
public HistSimIndexPlay(string folder, TickFileFilter tff,int interval,DebugDelegate deb) { if (deb!=null) GotDebug+=deb; _folder = folder + "\\"; // see if we have index string fn; HistSimIndex hsi; debug("getting tickfiles, please wait..."); string[,] total = Util.TickFileIndex(folder, TikConst.WILDCARD_EXT,false); debug("found " + total.GetLength(0).ToString("N0") + " tickfiles"); string[,] filtered = tff.AllowsIndexAndSize(total); debug("post-filter: " + filtered.GetLength(0).ToString("N0")+", checking for index..."); if (HistSimIndex.HaveIndex(folder, filtered, out fn,deb)) { debug("index found, starting load: "+fn); hsi = HistSimIndex.FromFile(fn,debug); if (hsi == null) { debug("unable to load index."); return; } hsi.GotDebug+=new DebugDelegate(debug); } else if (HistSimIndex.BuildIndex(folder, filtered, out hsi, true,true,interval,debug)) { debug("Index built successfully, ready to play."); } else { debug("Error building index..."); return; } _reader.DoWork += new DoWorkEventHandler(_reader_DoWork); _reader.WorkerSupportsCancellation = true; myhsi = hsi; hsip_avail = hsi.Playindex.Length; checkindex(); }
public HistSimIndexPlay(string[] dataset,string folder, int interval, DebugDelegate deb) { if (deb != null) GotDebug += deb; if (dataset.Length < 1) { debug("Empty data set, quitting..."); return; } _folder = folder; // get index of set string[,] tfi = GetTickIndex(dataset,false,folder); _extdebug = tfi.GetLength(0) > 500; // see if we have index string fn; HistSimIndex hsi; edebug("checking for index"); if (HistSimIndex.HaveIndex(folder, tfi,interval, out fn)) { edebug("index found."); hsi = HistSimIndex.FromFile(fn); hsi.GotDebug += new DebugDelegate(debug); } else if (HistSimIndex.BuildIndex(folder, tfi, out hsi, true, true,interval, debug)) { edebug("Index built successfully"); } else { debug("Error building index..."); return; } myhsi = hsi; _reader.DoWork += new DoWorkEventHandler(_reader_DoWork); _reader.WorkerSupportsCancellation = true; hsip_avail = hsi.Playindex.Length; checkindex(); }
static string[][] fetchrawlist(string url, DebugDelegate deb) { d = deb; debug("grabbing screen data from: "+url); string content = string.Empty; try { System.Net.WebClient wc = new System.Net.WebClient(); content = wc.DownloadString(url); debug("obtained " + content.Length + " bytes of screen data."); } catch (Exception ex) { debug("error obtaining data from: " + url + " err: " + ex.Message + ex.StackTrace); return new string[0][]; } string[] lines = content.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); string[][] final = new string[lines.Length - 1][]; int err = 0; for (int i = 1; i < lines.Length; i++) { // get line string line = lines[i]; try { // get records string[] rec = getrec(line); final[i - 1] = rec; } catch (Exception ex) { err++; debug("error parsing line: " + line+" err: "+ex.Message+ex.StackTrace); } } debug("retrieved " + final.GetLength(0) + " screen records with " + err + " errors."); return final; }
public HistSimIndexPlay(HistSimIndex hsi, DebugDelegate deb) { _folder = hsi.Folder; if (deb != null) GotDebug += deb; _reader.DoWork += new DoWorkEventHandler(_reader_DoWork); _reader.WorkerSupportsCancellation = true; myhsi = hsi; hsip_avail = hsi.Playindex.Length; checkindex(); }
public static GenericTracker<Screener> fetchscreen(string url, DebugDelegate deb) { // get raw list string[][] raw = fetchrawlist(url,deb); debug("beginning screen indexing of "+raw.GetLength(0)+" screens."); GenericTracker<Screener> ss = new GenericTracker<Screener>(raw.GetLength(0), "SCREENS", new Screener()); foreach (string[] r in raw) { Screener s = getscreen(r); ss.addindex(s.symbol, s); } debug("completed index of "+ss.Count+" screens."); return ss; }
public static GenericTracker<Screener> fetchscreen(DebugDelegate deb) { return fetchscreen(finzurl, deb); }
public static bool TicksToFile(Tick[] ticks, DebugDelegate debs) { try { TikWriter tw = new TikWriter(); foreach (Tick k in ticks) tw.newTick(k); tw.Close(); if (debs != null) debs(tw.RealSymbol + " saved " + tw.Count + " ticks to: " + tw.Filepath); } catch (Exception ex) { if (debs != null) debs(ex.Message + ex.StackTrace); return false; } return true; }
/// <summary> /// get list of tickets on space (limited to first 1000) /// </summary> /// <param name="space"></param> /// <param name="user"></param> /// <param name="pw"></param> /// <returns></returns> public static List<AssemblaTicket> GetTickets(string space, string user, string pw, DebugDelegate deb) { List<AssemblaTicket> docs = new List<AssemblaTicket>(); try { string url = AssemblaTicket.GetTicketsUrl(space); string result; if (!qc.goget(url, user, pw, string.Empty, SendDebug, out result)) return docs; XmlDocument xd = new XmlDocument(); xd.LoadXml(result); XmlNodeList xnl = xd.GetElementsByTagName("ticket"); foreach (XmlNode xn in xnl) { AssemblaTicket doc = new AssemblaTicket(); doc.Space = space; foreach (XmlNode dc in xn.ChildNodes) { try { string m = dc.InnerText; if (dc.Name == "summary") doc.Summary = m; else if (dc.Name == "status") doc.Status = (TradeLink.API.TicketStatus)Convert.ToInt32(m); else if (dc.Name == "description") doc.Description = m; else if (dc.Name == "priority") doc.Priority = (TradeLink.API.Priority)Convert.ToInt32(m); else if (dc.Name == "number") doc.Number = Convert.ToInt32(m); else if (dc.Name == "assign-to-id") doc.Owner = Convert.ToInt32(m); else if (dc.Name == "milestone-id") doc.Milestone = Convert.ToInt32(m); else if (dc.Name == "updated-at") doc.UpdatedAt = m; else if (dc.Name == "id") doc.TicketDocumentId = Convert.ToInt32(m); else if (dc.Name == "reporter-id") doc.Reporter = m; else if (dc.Name == "created-on") doc.CreatedAt = m; } catch (Exception ex) { } } if (doc.isValid) docs.Add(doc); } } catch (Exception ex) { if (deb != null) { deb("error getting tickets for space: " + space + " error: " + ex.Message + ex.StackTrace); } } return docs; }
public static AssemblaTicket GetTicket(string space, string user, string password, int ticketnum, DebugDelegate debs) { string url = GetTicketUrl(space)+"/"+ticketnum; string r= string.Empty; if (qc.goget(url, user, password, string.Empty, debs, out r)) { XmlDocument xd = new XmlDocument(); xd.LoadXml(r); XmlNodeList xnl = xd.GetElementsByTagName("ticket"); foreach (XmlNode xn in xnl) { AssemblaTicket doc = new AssemblaTicket(); doc.Space = space; foreach (XmlNode dc in xn.ChildNodes) { try { string m = dc.InnerText; if (dc.Name == "summary") doc.Summary = m; else if (dc.Name == "status") doc.Status = (TradeLink.API.TicketStatus)Convert.ToInt32(m); else if (dc.Name == "description") doc.Description = m; else if (dc.Name == "priority") doc.Priority = (TradeLink.API.Priority)Convert.ToInt32(m); else if (dc.Name == "number") doc.Number = Convert.ToInt32(m); else if (dc.Name == "assign-to-id") doc.Owner = Convert.ToInt32(m); else if (dc.Name == "milestone-id") doc.Milestone = Convert.ToInt32(m); else if (dc.Name == "updated-at") doc.UpdatedAt = m; else if (dc.Name == "id") doc.TicketDocumentId = Convert.ToInt32(m); else if (dc.Name == "reporter-id") doc.Reporter = m; else if (dc.Name == "created-on") doc.CreatedAt = m; } catch (Exception ex) { } } if (doc.isValid) return doc; } } return new AssemblaTicket(); }