public override string QueryResult() { JsonModel jsonModel = new JsonModel(); jsonModel.result = 1; jsonModel.resultStr = "数据提交失败:未找到指定的机组信息"; TF.Api.Utilities.Validation validater = new TF.Api.Utilities.Validation(); try { InputParam paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <InputParam>(this.Data); //验证数据正确性,非空字段不能为空 if (validater.IsNotNullPropertiesValidated(paramModel.data)) { TF.RunSafty.BLL.LCNameGroup bllNameGroup = new RunSafty.BLL.LCNameGroup(); if (bllNameGroup.ChangeGroupPlace(paramModel.data.groupID, paramModel.data.sourcePlaceID, paramModel.data.destPlaceID)) { jsonModel.result = 0; jsonModel.resultStr = "提交成功"; } } } catch (Exception ex) { TF.CommonUtility.LogClass.logex(ex, ""); jsonModel.result = 1; jsonModel.resultStr = "提交失败" + ex.Message; } string result = Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel); return(result); }
public override string QueryResult() { JsonModel jsonModel = new JsonModel(); jsonModel.result = 1; jsonModel.resultStr = "数据提交失败:未找到指定的机组信息"; TF.Api.Utilities.Validation validater = new TF.Api.Utilities.Validation(); try { InputParam paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <InputParam>(this.Data); //验证数据正确性,非空字段不能为空 if (validater.IsNotNullPropertiesValidated(paramModel.data)) { TF.RunSafty.BLL.RCEndWork rcEndWork = new RunSafty.BLL.RCEndWork(); if (rcEndWork.Endwork(paramModel.data.siteID, paramModel.data.endwork, paramModel.data.drink, paramModel.data.dutyUser)) { jsonModel.result = 0; jsonModel.resultStr = "提交成功"; } else { jsonModel.result = 1; } } } catch (Exception ex) { TF.CommonUtility.LogClass.logex(ex, ""); jsonModel.result = 1; jsonModel.resultStr = "提交失败" + ex.Message; } string result = Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel); return(result); }
protected override NodeState DoTick(InputParam input, OutputParam output) { NodeState ret = NodeState.Finish; if (m_behaviorState == BehaviorState.Ready) { DoEnter(input); m_behaviorState = BehaviorState.Running; } if (m_behaviorState == BehaviorState.Running) { ret = DoExecute(input, output); SetActiveNode(this); if (ret == NodeState.Finish) m_behaviorState = BehaviorState.Finish; } if (m_behaviorState == BehaviorState.Finish) { DoExit(input); m_behaviorState = BehaviorState.Ready; SetActiveNode(null); } return ret; }
public Param(InputParam <T> inputParam, T defaultValue, bool optional, IInput input) { this.inputParam = inputParam; this.defaultValue = defaultValue; this.optional = optional; this.input = input; }
private void simpleButton5_Click(object sender, EventArgs e) { try { roiList.Clear(); ArrayList tempRoi = roiController.ROIList; for (int i = 0; i < tempRoi.Count; i++) { ROI roi = (ROI)tempRoi[i]; if (roi.Type == "ROIRectangle1") { roi.Msize = new Size(4, 4); roiList.Add(roi); } } StaticOperate.WriteXML(inParam, settingPath); CircleLine.hWindow_Final1.viewWindow.saveROI(roiList, roiPath); inParam = LoadXml(station); MessageBox.Show("保存成功!"); } catch (Exception) { throw; } }
public FindMax(int Station = 1) { InitializeComponent(); station = Station; Path = AppDomain.CurrentDomain.BaseDirectory + "Setting" + Station.ToString() + "\\"; if (!Directory.Exists(Path)) { Directory.CreateDirectory(Path); } if (Station == 1) { this.Text = "工位一感光片设置"; } else { this.Text = "工位二感光片设置"; } CircleLine = new LookForCircleLine.mainUtl(Path); panelControl1.Controls.Add(CircleLine); Size sz = CircleLine.Size; panelControl1.Size = sz; CircleLine.Dock = DockStyle.Fill; CircleLine.isFitWindow = false; int height = panelControl1.Size.Height; int width = (int)(height * (0.006 / 0.05) * 5); CircleLine.splitContainer1.SplitterDistance = width; //splitContainerControl1.SplitterPosition = sz.Width; roiController = CircleLine.hWindow_Final1.viewWindow._roiController; roiController.NotifyRCObserver = new IconicDelegate(ROiMove); UpDownBase upDown = (UpDownBase)numericUpDown1; upDown.TextChanged += new EventHandler(numericUpDown1_ValueChanged); UpDownBase upDown2 = (UpDownBase)numericUpDown2; upDown2.TextChanged += new EventHandler(numericUpDown2_ValueChanged); UpDownBase upDown3 = (UpDownBase)numericUpDown3; upDown3.TextChanged += new EventHandler(numericUpDown3_ValueChanged); UpDownBase upDown4 = (UpDownBase)numericUpDown4; upDown4.TextChanged += new EventHandler(numericUpDown4_ValueChanged); //settingPath = Path + "MaxSetting.xml"; roiPath = Path + "Roi.roi"; //if (File.Exists(settingPath)) //{ // inParam = (InputParam)StaticOperate.ReadXML(settingPath, inParam.GetType()); //} inParam = LoadXml(Station); ShowToUI(); CircleLine.load = new LookForCircleLine.mainUtl.LoadImage(LoadImage); }
public override bool Check(InputParam input) { foreach (ICondition condition in m_conditions) { if (condition.Check(input)) return true; } return false; }
private static void TryParseStringParam(string paramString, InputParam <string> param) { if (string.IsNullOrEmpty(paramString)) { return; } param.Value = paramString; }
private static void Main(string[] args) { if (args.Length < 2 || args.Length > 5) { Console.WriteLine( "Usage: dxf_regional_book_sample <host:port> <symbol> [-T <token>] [-p]\n" + "where\n" + " host:port - The address of dxfeed server (demo.dxfeed.com:7300)\n" + " symbol - IBM\n" + " -T <token> - The authorization token\n" + " -p - Enables the data transfer logging\n\n" + "example: dxf_regional_book_sample demo.dxfeed.com:7300 MSFT\n" ); return; } var address = args[HOST_INDEX]; var symbol = args[SYMBOL_INDEX]; var token = new InputParam <string>(null); var logDataTransferFlag = false; for (var i = SYMBOL_INDEX + 1; i < args.Length; i++) { if (!token.IsSet && i < args.Length - 1 && TryParseTaggedStringParam("-T", args[i], args[i + 1], token)) { i++; continue; } if (logDataTransferFlag == false && args[i].Equals("-p")) { logDataTransferFlag = true; i++; } } Console.WriteLine("Connecting to {0} on {1}...", address, symbol); try { NativeTools.InitializeLogging("dxf_regional_book_sample.log", true, true, logDataTransferFlag); using (var con = token.IsSet ? new NativeConnection(address, token.Value, DisconnectHandler) : new NativeConnection(address, DisconnectHandler)) { using (con.CreateRegionalBook(symbol, new RegionalBookListener(), new QuoteListener())) { Console.WriteLine("Press enter to stop"); Console.ReadLine(); } } } catch (DxException dxException) { Console.WriteLine("Native exception occured: " + dxException.Message); } catch (Exception exc) { Console.WriteLine("Exception occured: " + exc.Message); } }
/// <summary> /// Kiểm tra 1 textbox truyền vào có hợp lệ không /// </summary> /// <param name="txtname">truyền vào 1 textbox</param> /// <param name="input">truyền vào kiểu kiểm tra</param> /// <returns></returns> public InputParam CheckTextbox(TextBox txtname, InputType input) { var inputparam = new InputParam { Input = txtname.Text, InputType = input }; var validate = new ValidateData(); return(ValidateData.ValDataOne(inputparam)); }
protected override bool DoEvaluate(InputParam input) { IterateChildren((i, node) => { if (node.Evaluate(input)) { m_currentSelectIdx = i; return false; } return true; }); return m_currentSelectIdx != -1; }
private static bool TryParseTaggedStringParam(string tag, string paramTagString, string paramString, InputParam <string> param) { if (!paramTagString.Equals(tag)) { return(false); } param.Value = paramString; return(true); }
private static void Main(string[] args) { if (args.Length < 1 || args.Length > 5) { PrintUsage(); return; } var address = args[HOST_INDEX]; var recordsPrintLimit = new InputParam <int>(DEFAULT_RECORDS_PRINT_LIMIT); var token = new InputParam <string>(null); for (var i = HOST_INDEX + 1; i < args.Length; i++) { if (!recordsPrintLimit.IsSet && i < args.Length - 1 && TryParseRecordsPrintLimitParam(args[i], args[i + 1], recordsPrintLimit)) { i++; continue; } if (!token.IsSet && i < args.Length - 1 && TryParseTaggedStringParam("-T", args[i], args[i + 1], token)) { i++; } } Console.WriteLine($"Connecting to {address} for Order View"); try { NativeTools.InitializeLogging("dxf_order_view_sample.log", true, true); using (var con = token.IsSet ? new NativeConnection(address, token.Value, DisconnectHandler) : new NativeConnection(address, DisconnectHandler)) { using (var sub = con.CreateOrderViewSubscription(new OrderViewEventListener(recordsPrintLimit.Value))) { sub.SetSource("NTV", "DEA", "DEX"); sub.SetSymbols("AAPL", "GOOG", "IBM", "F"); Console.WriteLine("Press enter to stop"); Console.ReadLine(); } } } catch (DxException dxException) { Console.WriteLine($"Native exception occured: {dxException.Message}"); } catch (Exception exc) { Console.WriteLine($"Exception occured: {exc.Message}"); } }
private static bool TryParseDateTimeParam(string stringParam, InputParam <DateTime?> param) { DateTime dateTimeValue; if (!DateTime.TryParse(stringParam, out dateTimeValue)) { return(false); } param.Value = dateTimeValue; return(true); }
public InputParam LoadXml(int Station) { InputParam inParam = new InputParam(); string Path = AppDomain.CurrentDomain.BaseDirectory + "Setting" + Station.ToString() + "\\"; if (!Directory.Exists(Path)) { Directory.CreateDirectory(Path); } settingPath = Path + "MaxSetting.xml"; if (File.Exists(settingPath)) { inParam = (InputParam)StaticOperate.ReadXML(settingPath, inParam.GetType()); } return(inParam); }
public OutputParam CalcWorkTime(string data) { InputParam inputParam = Newtonsoft.Json.JsonConvert.DeserializeObject <InputParam>(data); OutputParam result = new OutputParam(); try { DBWorkTime dbWorkTime = new DBWorkTime(); dbWorkTime.CalcWorkTime(inputParam.TrainPlanGUID); } catch (Exception ex) { result.result = "1"; result.resultStr = ex.Message.ToString(); } return(result); }
private static bool TryParseRecordsPrintLimitParam(string paramTagString, string paramString, InputParam <int> param) { if (!paramTagString.Equals("-l")) { return(false); } int newRecordsPrintLimit; if (!int.TryParse(paramString, out newRecordsPrintLimit)) { return(false); } param.Value = newRecordsPrintLimit; return(true); }
public OutputParam GetWorkTime(string data) { InputParam inputParam = Newtonsoft.Json.JsonConvert.DeserializeObject <InputParam>(data); OutputParam result = new OutputParam(); OutputWorkTime outputWorkTime = new OutputWorkTime(); try { result.data = outputWorkTime; DBWorkTime dbWorkTime = new DBWorkTime(); outputWorkTime.workTime = dbWorkTime.GetWorkTime(inputParam.TrainPlanGUID); outputWorkTime.bExist = outputWorkTime.workTime != null; } catch (Exception ex) { result.result = "1"; result.resultStr = ex.Message.ToString(); } return(result); }
protected override NodeState DoTick(InputParam input, OutputParam output) { NodeState ret = NodeState.Finish; if (IsValidIdx(m_currentSelectIdx)) { if (m_currentSelectIdx != m_lastSelectIdx && IsValidIdx(m_lastSelectIdx)) { BTNode child = GetChildByIdx(m_lastSelectIdx); child.Reset(input); } m_lastSelectIdx = m_currentSelectIdx; } BTNode curNode = GetChildByIdx(m_currentSelectIdx); if (null != curNode) { ret = curNode.Tick(input, output); if (ret == NodeState.Finish) m_lastSelectIdx = -1; } return ret; }
private Delegate CompileInternal(Type modelType, String template, OutputFormat outputFormat) { if (modelType == null) { throw new ArgumentNullException("modelType"); } DynamicMethod genMethod = new DynamicMethod("Build", typeof(String), new[] { modelType, typeof(IFormatProvider) }, true); genMethod.InitLocals = true; #if !NETCOREAPP genMethod.DefineParameter(1, ParameterAttributes.In, "model"); genMethod.DefineParameter(2, ParameterAttributes.In, "formatProvider"); #endif ILGenerator il = genMethod.GetILGenerator(); InputParam modelParam = new InputParam(genMethod.GetParameters()[0]); InputParam formatProviderParam = new InputParam(genMethod.GetParameters()[1]); Generator generator = new Generator(il, outputFormat, modelParam, formatProviderParam); Compile(template, generator); Delegate buildFunc = genMethod.CreateDelegate(typeof(Func <, ,>).MakeGenericType(modelType, typeof(IFormatProvider), typeof(String))); return(buildFunc); }
public JsonModel ExecuteEndWork(string input) { JsonModel jsonModel = new JsonModel(); jsonModel.result = 1; jsonModel.resultStr = "数据提交失败:未找到指定的机组信息"; TF.Api.Utilities.Validation validater = new TF.Api.Utilities.Validation(); try { InputParam paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <InputParam>(input); DB_Plan_EndWork rcEndWork = new DB_Plan_EndWork(); DateTime ArrvieTime = DateTime.Now; bool isArrvieTime = getGetLastArrvieTime(paramModel.planID, ref ArrvieTime); if (isArrvieTime) { ArrvieTime = Convert.ToDateTime("1899-01-01"); } if (rcEndWork.Endwork(paramModel.drinkdata, paramModel.dutyUser, paramModel.planID, paramModel.siteID, paramModel.VerifyID, paramModel.remark, ArrvieTime)) { jsonModel.result = 0; jsonModel.resultStr = "提交成功"; } else { jsonModel.result = 1; } } catch (Exception ex) { TF.CommonUtility.LogClass.logex(ex, ""); jsonModel.result = 1; jsonModel.resultStr = "提交失败" + ex.Message; } return(jsonModel); }
public void Reset(InputParam input) { DoReset(input); }
public bool Evaluate(InputParam input) { return (m_condtion != null && m_condtion.Check(input)) && DoEvaluate(input); }
bool Evaluate(InputParam input) { return DoEvaluate(input); }
/// <summary> /// Adds an InputParam instance to a given list, with Class type set to String and mandatory flag set to true /// </summary> /// <param name="list">Parameter list to validate</param> /// <param name="key">Parameter Name</param> public void CreateMandatoryParam(List <InputParam> list, String key) { list.Add(InputParam.CreateMandatoryParam(key)); }
protected NodeState DoExecute(InputParam input, OutputParam output) { return NodeState.Finish; }
public override bool Check(InputParam input) { bool ret = true; foreach (ICondition condition in m_conditions) ret ^= condition.Check(input); return ret; }
public bool Check(InputParam input) { return !m_innerCondition.Check(input); }
protected override NodeState DoTick(InputParam input, OutputParam output) { int finishCount = 0; NodeState ret = NodeState.Executing; IterateChildren((i, child) => { if (m_childrenState.ContainsKey(i)) { if(m_childrenState[i] == NodeState.Executing) m_childrenState[i] = child.Tick(input, output); } else m_childrenState[i] = child.Tick(input, output); if (m_childrenState[i] == NodeState.Finish) finishCount++; if (m_finishCondition == FinishOP.OR && finishCount > 0) { ret = NodeState.Finish; return false; } if (m_finishCondition == FinishOP.AND && finishCount == GetChildrenCount()) { ret = NodeState.Finish; return false; } return true; }); return ret; }
protected override void DoReset(InputParam input) { m_childrenState.Clear(); IterateChildren((i, child) => { child.Reset(input); return true; }); }
protected override bool DoEvaluate(InputParam input) { bool ret = true; IterateChildren((i, child) => { if (!child.Evaluate(input)) { ret = false; return false; } return true; }); return ret; }
protected override NodeState DoTick(InputParam input, OutputParam output) { NodeState ret = NodeState.Finish; if (IsValidIdx(m_currentSelectIdx)) { ret = GetChildByIdx(m_currentSelectIdx).Tick(input, output); if (ret == NodeState.Finish) { m_currentSelectIdx++; //if idx is invalid, means all node finish execution, then this node is finish if (!IsValidIdx(m_currentSelectIdx)) return NodeState.Finish; else return NodeState.Executing; } } return ret; }
/// <summary> /// Adds an InputParam instance to a given list, with Class type set to String and mandatory flag set to false /// </summary> /// <param name="list">Parameter list to validate</param> /// <param name="key">Parameter Name</param> public void CreateOptionalParam(List <InputParam> list, String key) { list.Add(InputParam.CreateOptionalParam(key)); }
protected virtual NodeState DoTick(InputParam input, OutputParam output) { return NodeState.Finish; }
protected override bool DoEvaluate(InputParam input) { if (!(m_loopCount > 0 && m_curLoop >= 0 && m_curLoop < m_loopCount)) return false; if (IsValidIdx(0)) return GetChildByIdx(0).Evaluate(input); return false; }
private static void LoadScript(Project P, XmlLoad X) { Script S = new Script(); P.Scripts.Add(S); while (X.Read()) { switch (X.ElementName) { case "cathegory": S.Cathegory = X.GetAttribute("value"); break; case "name": S.Name = X.GetAttribute("value"); break; case "photo": /* TODO */ break; case "options": LoadOptions(S, X.GetSubtree()); break; case "input": { var In = new InputParam(); if (X.HasAttribute("name")) { In.Name = X.GetAttribute("name"); } if (X.HasAttribute("value")) { In.Type = X.GetAttribute("value"); } if (X.HasAttribute("comment")) { In.Comment = X.GetAttribute("comment"); } if (X.HasAttribute("default")) { In.Default = X.GetAttribute("default"); } if (X.HasAttribute("id")) { In.ID = X.GetAttribute("id"); } S.Input.Add(In); } break; case "steps": LoadActions(S, X.GetSubtree()); break; case "type": S.Arch.Add(X.GetAttribute("value")); break; case "readme": if (X.HasAttribute("file")) { var FN = X.GetAttribute("file"); S.Readme = LoadFromFile(P, FN); } else if (X.HasAttribute("value")) { S.Readme = X.GetAttribute("value"); } break; default: S.Arguments.Set(X.ElementName, X.GetAttribute("value")); break; } } }
public virtual bool Check(InputParam input) { return true; }
protected void DoEnter(InputParam input) { }
private static void Main(string[] args) { if (args.Length < 3 || args.Length > 9) { Console.WriteLine( "Usage: dxf_snapshot_sample <host:port> <event> <symbol> [<source>] [-l <records_print_limit>] [-T <token>] [-p]\n" + "where\n" + " host:port - address of dxfeed server (demo.dxfeed.com:7300)\n" + " event - snapshot event Order, Candle, TimeAndSale, SpreadOrder,\n" + " Greeks, Series for MarketMaker see source parameter\n" + " symbol - symbol string, it is allowed to use only one symbol\n" + " a) event symbol: IBM, MSFT, ...\n" + " b) candle symbol attribute: XBT/USD{=d},\n" + " AAPL{=d,price=mark}, ...\n" + " source - used only for Order or MarketMaker subscription,\n" + " also it is allowed to use only one source\n" + " a) source for Order, e.g. NTV, BYX, BZX, DEA, ISE, \n" + " DEX, IST\n" + " b) source for MarketMaker, one of following: AGGREGATE_ASK\n" + " or AGGREGATE_BID (default value for Order snapshots)\n" + " If source is not specified MarketMaker snapshot will be\n" + " subscribed by default.\n\n" + $" -l <records_print_limit> - The number of displayed records (0 - unlimited, default: {DEFAULT_RECORDS_PRINT_LIMIT})\n" + " -T <token> - The authorization token\n" + " -p - Enables the data transfer logging\n\n" + "order example: dxf_snapshot_sample demo.dxfeed.com:7300 Order AAPL NTV\n" + "market maker example:\n" + " dxf_snapshot_sample demo.dxfeed.com:7300 Order AAPL AGGREGATE_BID\n" + "or just:\n" + " dxf_snapshot_sample demo.dxfeed.com:7300 Order AAPL\n" + "candle example: dxf_snapshot_sample demo.dxfeed.com:7300 Candle XBT/USD{=d}" ); return; } var address = args[HOST_INDEX]; var symbol = args[SYMBOL_INDEX]; EventType eventType; if (!Enum.TryParse(args[EVENT_INDEX], true, out eventType) || eventType != EventType.Order && eventType != EventType.Candle && eventType != EventType.TimeAndSale && eventType != EventType.SpreadOrder && eventType != EventType.Greeks && eventType != EventType.Series) { Console.WriteLine($"Unsupported event type: {args[EVENT_INDEX]}"); return; } var source = new InputParam <string>(OrderSource.AGGREGATE_BID); var recordsPrintLimit = new InputParam <int>(DEFAULT_RECORDS_PRINT_LIMIT); var token = new InputParam <string>(null); var logDataTransferFlag = false; for (var i = SYMBOL_INDEX + 1; i < args.Length; i++) { if (!recordsPrintLimit.IsSet && i < args.Length - 1 && TryParseRecordsPrintLimitParam(args[i], args[i + 1], recordsPrintLimit)) { i++; continue; } if (!token.IsSet && i < args.Length - 1 && TryParseTaggedStringParam("-T", args[i], args[i + 1], token)) { i++; continue; } if (logDataTransferFlag == false && args[i].Equals("-p")) { logDataTransferFlag = true; i++; continue; } if (!source.IsSet) { TryParseStringParam(args[i], source); } } if (eventType == EventType.Order) { if (source.Value.Equals(OrderSource.AGGREGATE_BID) || source.Value.Equals(OrderSource.AGGREGATE_ASK)) { Console.WriteLine("Connecting to {0} for MarketMaker snapshot on {1}...", address, symbol); } else { Console.WriteLine("Connecting to {0} for Order#{1} snapshot on {2}...", address, source.Value, symbol); } } else { Console.WriteLine("Connecting to {0} for {1} snapshot on {2}...", address, eventType, symbol); } try { NativeTools.InitializeLogging("dxf_snapshot_sample.log", true, true, logDataTransferFlag); using (var con = token.IsSet ? new NativeConnection(address, token.Value, DisconnectHandler) : new NativeConnection(address, DisconnectHandler)) { using (var s = con.CreateSnapshotSubscription(eventType, DEFAULT_TIME, new SnapshotListener(recordsPrintLimit.Value))) { switch (eventType) { case EventType.Order: s.AddSource(source.Value); s.AddSymbol(symbol); break; case EventType.Candle: s.AddSymbol(CandleSymbol.ValueOf(symbol)); break; default: s.AddSymbol(symbol); break; } Console.WriteLine("Press enter to stop"); Console.ReadLine(); } } } catch (DxException dxException) { Console.WriteLine($"Native exception occured: {dxException.Message}"); } catch (Exception exc) { Console.WriteLine($"Exception occured: {exc.Message}"); } }
protected void DoExit(InputParam input) { }
public Param <T> Optional <T>(InputParam <T> inputParam, T defaultValue) { return(adaptee.Optional(inputParam, defaultValue)); }
private static void Main(string[] args) { if (args.Length < 3 || args.Length > 7) { Console.WriteLine( "Usage: dxf_events_sample <host:port> <event> <symbol> [<date>] [-T <token>] [-p]\n" + "where\n" + " host:port - The address of dxfeed server (demo.dxfeed.com:7300)\n" + " event - Any of the {Profile,Order,Quote,Trade,TimeAndSale,Summary,\n" + " TradeETH,SpreadOrder,Greeks,TheoPrice,Underlying,Series,\n" + " Configuration}\n" + " symbol - IBM, MSFT, ...\n\n" + " date - The date of time series event in the format YYYY-MM-DD (optional)\n" + " -T <token> - The authorization token\n" + " -p - Enables the data transfer logging\n\n" + "example: dxf_events_sample demo.dxfeed.com:7300 quote,trade MSFT.TEST,IBM.TEST\n" + "or: dxf_events_sample demo.dxfeed.com:7300 TimeAndSale MSFT,IBM 2016-10-10\n" ); return; } var address = args[HOST_INDEX]; EventType events; if (!Enum.TryParse(args[EVENT_INDEX], true, out events)) { Console.WriteLine($"Unsupported event type: {args[EVENT_INDEX]}"); return; } var symbols = args[SYMBOL_INDEX].Split(','); var dateTime = new InputParam <DateTime?>(null); var token = new InputParam <string>(null); var logDataTransferFlag = false; for (var i = SYMBOL_INDEX + 1; i < args.Length; i++) { if (!dateTime.IsSet && TryParseDateTimeParam(args[i], dateTime)) { continue; } if (!token.IsSet && i < args.Length - 1 && TryParseTaggedStringParam("-T", args[i], args[i + 1], token)) { i++; continue; } if (logDataTransferFlag == false && args[i].Equals("-p")) { logDataTransferFlag = true; i++; } } Console.WriteLine($"Connecting to {address} for [{events}] on [{string.Join(", ", symbols)}] ..."); try { NativeTools.InitializeLogging("dxf_events_sample.log", true, true, logDataTransferFlag); using (var con = token.IsSet ? new NativeConnection(address, token.Value, DisconnectHandler) : new NativeConnection(address, DisconnectHandler)) { using (var s = con.CreateSubscription(events, dateTime.Value, new EventListener())) { s.AddSymbols(symbols); Console.WriteLine("Press enter to stop"); Console.ReadLine(); } } } catch (DxException dxException) { Console.WriteLine($"Native exception occured: {dxException.Message}"); } catch (Exception exc) { Console.WriteLine($"Exception occured: {exc.Message}"); } }
private static void Main(string[] args) { if (args.Length < 1 || args.Length > 3) { Console.WriteLine( "Usage: dxf_order_view_xcheck <host:port> [-T <token>]\n" + "where\n" + " host:port - The address of dxfeed server (demo.dxfeed.com:7300)\n" + " -T <token> - The authorization token\n\n" + "example: dxf_order_view_xcheck demo.dxfeed.com:7300\n" ); return; } var address = args[HOST_INDEX]; var token = new InputParam <string>(null); for (var i = HOST_INDEX + 1; i < args.Length; i++) { if (!token.IsSet && i < args.Length - 1 && TryParseTaggedStringParam("-T", args[i], args[i + 1], token)) { i++; } } Console.WriteLine("Connecting to {0} for Order View", address); try { NativeTools.InitializeLogging("dxf_order_view_xcheck.log", true, true); using (var con = token.IsSet ? new NativeConnection(address, token.Value, DisconnectHandler) : new NativeConnection(address, DisconnectHandler)) { var l = new OrderViewEventListener(); var subs = new List <IDxSubscription>(); /* * We CAN NOT use one instance OrderViewSubscription here. * If OrderViewSubscription is configured with multiple sources, * it MIXES sources to one "view" and this "view" is NOT * transactional-safe and atomic anymore. * You could see "crosses" between orders with different sources * in the mixed view, it is normal. Atomicity is only guaranteed * for order book from one source! */ foreach (var src in new[] { "NTV" /*, "DEX", "BZX" */ }) { var s = con.CreateOrderViewSubscription(l); s.SetSource(src); s.SetSymbols(/*"AAPL",*/ "FB" /*, "SPY"*/); subs.Add(s); } Console.WriteLine("Press enter to stop"); Console.ReadLine(); foreach (var sub in subs) { sub.Dispose(); } } } catch (DxException dxException) { Console.WriteLine($"Native exception occured: {dxException.Message}"); } catch (Exception exc) { Console.WriteLine($"Exception occured: {exc.Message}"); } }
private void InitFormatProviderField() { FieldBuilder field = _typeBuilder.DefineField("_formatProvider", typeof(IFormatProvider), FieldAttributes.Private | FieldAttributes.InitOnly); _formatProviderParam = new InputParam(field); }
protected override NodeState DoTick(InputParam input, OutputParam output) { NodeState ret = NodeState.Finish; if (IsValidIdx(0)) { NodeState childState = GetChildByIdx(0).Tick(input, output); if (childState == NodeState.Finish) { m_curLoop++; if (m_curLoop != m_loopCount) ret = NodeState.Executing; else m_curLoop = 0; } } return ret; }
private void InitModelField() { FieldBuilder field = _typeBuilder.DefineField("_model", _modelType, FieldAttributes.Private | FieldAttributes.InitOnly); _modelParam = new InputParam(field); }
protected override void DoReset(InputParam input) { if (IsValidIdx(m_currentSelectIdx)) GetChildByIdx(m_currentSelectIdx).Reset(input); m_currentSelectIdx = m_lastSelectIdx = -1; }
public Param <T> Required <T>(InputParam <T> inputParam) { return(adaptee.Required(inputParam)); }
protected override bool DoEvaluate(InputParam input) { return base.DoEvaluate(input); }
bool DoEvaluate(InputParam input) { return true; }
protected override bool DoEvaluate(InputParam input) { if(!IsValidIdx(m_currentSelectIdx)) m_currentSelectIdx = 0; if (IsValidIdx(m_currentSelectIdx)) return GetChildByIdx(m_currentSelectIdx).Evaluate(input); return false; }
public NodeState Tick(InputParam input, OutputParam output) { return DoTick(input, output); }
public void SendProgressNotificationSingleObject(InputParam input) => input.Progress?.Report(6);
protected virtual void DoReset(InputParam input) { }
protected override void DoReset(InputParam input) { DoExit(input); m_behaviorState = BehaviorState.Ready; }
protected virtual bool DoEvaluate(InputParam input) { return true; }
public bool Check(InputParam input) { return false; }
protected override void DoReset(InputParam input) { if (IsValidIdx(0)) GetChildByIdx(0).Reset(input); m_curLoop = 0; }
private static void Main(string[] args) { if (args.Length < 2) { WriteHelp(); return; } try { var address = args[HOST_INDEX]; var baseSymbol = args[SYMBOL_INDEX]; var dateTime = new InputParam <DateTime?>(new DateTime(1970, 1, 1, 0, 0, 0, 0)); var token = new InputParam <string>(null); var exchange = CandleSymbolAttributes.Exchange.DEFAULT; var periodValue = 1.0; var period = CandleSymbolAttributes.Period.DEFAULT; var price = CandleSymbolAttributes.Price.DEFAULT; var session = CandleSymbolAttributes.Session.DEFAULT; var alignment = CandleSymbolAttributes.Alignment.DEFAULT; var priceLevel = CandleSymbolAttributes.PriceLevel.DEFAULT; var logDataTransferFlag = false; var attributesAreSet = false; for (var i = SYMBOL_INDEX + 1; i < args.Length; i++) { if (!dateTime.IsSet && TryParseDateTimeParam(args[i], dateTime)) { continue; } if (!token.IsSet && i < args.Length - 1 && TryParseTaggedStringParam("-T", args[i], args[i + 1], token)) { i++; continue; } if (logDataTransferFlag == false && args[i].Equals("-p")) { logDataTransferFlag = true; i++; continue; } const string KEY_VALUE_REGEX = @"([a-z]+)(=)([a-z]+|\d+\.?\d*)"; var match = Regex.Match(args[i], KEY_VALUE_REGEX, RegexOptions.IgnoreCase); if (match.Groups.Count < 4 || !match.Success) { Console.WriteLine("Invalid Attributes"); WriteHelp(); return; } if (match.Groups[1].Value.Equals("exchange")) { if (match.Groups[3].Length == 1 && char.IsLetter(match.Groups[3].Value[0])) { exchange = CandleSymbolAttributes.Exchange.NewExchange(match.Groups[3].Value[0]); attributesAreSet = true; } } else if (match.Groups[1].Value.Equals("period")) { periodValue = double.Parse(match.Groups[3].Value, new CultureInfo("en-US")); attributesAreSet = true; } else if (match.Groups[1].Value.Equals("type")) { period = CandleSymbolAttributes.Period.NewPeriod(periodValue, CandleType.Parse(match.Groups[3].Value)); attributesAreSet = true; } else if (match.Groups[1].Value.Equals("price")) { price = CandleSymbolAttributes.Price.Parse(match.Groups[3].Value); attributesAreSet = true; } else if (match.Groups[1].Value.Equals("session")) { session = CandleSymbolAttributes.Session.Parse(match.Groups[3].Value); attributesAreSet = true; } else if (match.Groups[1].Value.Equals("alignment")) { alignment = CandleSymbolAttributes.Alignment.Parse(match.Groups[3].Value); attributesAreSet = true; } else if (match.Groups[1].Value.Equals("priceLevel")) { priceLevel = CandleSymbolAttributes.PriceLevel.Parse(match.Groups[3].Value); attributesAreSet = true; } } var symbol = (attributesAreSet) ? CandleSymbol.ValueOf(baseSymbol, exchange, period, price, session, alignment, priceLevel) : CandleSymbol.ValueOf(baseSymbol); Console.WriteLine($"Connecting to {address} for Candle on {symbol} ..."); NativeTools.InitializeLogging("dxf_candle_sample.log", true, true, logDataTransferFlag); using (var con = token.IsSet ? new NativeConnection(address, token.Value, DisconnectHandler) : new NativeConnection(address, DisconnectHandler)) { using (var s = con.CreateSubscription(dateTime.Value, new EventListener())) { s.AddSymbol(symbol); Console.WriteLine("Press enter to stop"); Console.ReadLine(); } } } catch (DxException dxException) { Console.WriteLine($"Native exception occured: {dxException.Message}"); } catch (Exception exc) { Console.WriteLine($"Exception occured: {exc.GetType()}, message: {exc.Message}"); } }