public bool GetReading(TriggerTypeEnum TriggerType, SensorClass Sensor, out double Reading) { Reading = 999999; switch (TriggerType) { case TriggerTypeEnum.Hold: return(false); case TriggerTypeEnum.ImmediateSingle: Sensor.Select(); _parentGigatronics854x.Trigger.Send(TriggerType); _parentGigatronics854x.WaitForMeasurementToComplete(_parentGigatronics854x.Timeout); Reading = (double)_parentGigatronics854x.ReadNumber(Ivi.Visa.Interop.IEEEASCIIType.ASCIIType_R8, true); return(true); case TriggerTypeEnum.ImmediateAveraging: Sensor.Select(); _parentGigatronics854x.Trigger.Send(TriggerType); _parentGigatronics854x.WaitForMeasurementToComplete(_parentGigatronics854x.Timeout); Reading = (double)_parentGigatronics854x.ReadNumber(Ivi.Visa.Interop.IEEEASCIIType.ASCIIType_R8, true); return(true); case TriggerTypeEnum.FreeRun: Sensor.Select(); _parentGigatronics854x.Trigger.Send(TriggerType); Reading = (double)_parentGigatronics854x.ReadNumber(Ivi.Visa.Interop.IEEEASCIIType.ASCIIType_R8, true); return(true); } return(false); }
public void UpdateValue(double threshold, double sensitivity, TriggerTypeEnum triggerType, TriggerDirectionEnum?triggerDirection) { Threshold = threshold; Sensitivity = sensitivity; TriggerType = triggerType; TriggerDirection = triggerDirection ?? TriggerDirectionEnum.Both; }
public IActionResult ReplaceColumn(TriggerTypeEnum type) { var entity = new EdieTaskScheduleModel { TriggerType = type, }; var replaceColumn = new ReplaceLargeColumn <EdieTaskScheduleModel, EdieTaskScheduleModel>(entity); var replace = replaceColumn.Render(); return(this.HtmlResult(replace)); }
public bool GetReading(TriggerTypeEnum TriggerType, SensorDesignatorEnum Designator, out double Reading) { Reading = 999999; if (!_sensors.ContainsKey(Designator)) { return(false); } return(GetReading(TriggerType, this[Designator], out Reading)); }
public void UpdateTrigger(double threshold, double sensitivity, TriggerTypeEnum triggerType, TriggerDirectionEnum?triggerDirection) { if (triggerType == TriggerTypeEnum.Buy) { BuyTrigger.UpdateValue(threshold, sensitivity, triggerType, triggerDirection); } else if (triggerType == TriggerTypeEnum.Sell) { SellTrigger.UpdateValue(threshold, sensitivity, triggerType, triggerDirection); } }
/// <summary> /// 把Xml节点转换为ActivityTypeDetail 类(用于会签等复杂类型) /// </summary> /// <param name="typeNode">类型节点</param> /// <returns>活动类型详细</returns> private static ActivityTypeDetail ConvertXmlNodeToActivityTypeDetail(XmlNode typeNode) { ActivityTypeDetail entity = new ActivityTypeDetail(); entity.ActivityType = (ActivityTypeEnum)Enum.Parse(typeof(ActivityTypeEnum), XMLHelper.GetXmlAttribute(typeNode, "type")); if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "trigger"))) { TriggerTypeEnum triggerType = TriggerTypeEnum.None; Enum.TryParse <TriggerTypeEnum>(XMLHelper.GetXmlAttribute(typeNode, "trigger"), out triggerType); entity.TriggerType = triggerType; //获取时间表达式 if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "expression"))) { entity.Expression = XMLHelper.GetXmlAttribute(typeNode, "expression"); } } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "complexType"))) { entity.ComplexType = EnumHelper.ParseEnum <ComplexTypeEnum>(XMLHelper.GetXmlAttribute(typeNode, "complexType")); } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "mergeType"))) { entity.MergeType = EnumHelper.ParseEnum <MergeTypeEnum>(XMLHelper.GetXmlAttribute(typeNode, "mergeType")); } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "compareType"))) { entity.CompareType = EnumHelper.ParseEnum <CompareTypeEnum>(XMLHelper.GetXmlAttribute(typeNode, "compareType")); } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "completeOrder"))) { entity.CompleteOrder = float.Parse(XMLHelper.GetXmlAttribute(typeNode, "completeOrder")); } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "skip"))) { var skip = Boolean.Parse(XMLHelper.GetXmlAttribute(typeNode, "skip")); var skipto = XMLHelper.GetXmlAttribute(typeNode, "to"); if (skip) { entity.SkipInfo = new SkipInfo { IsSkip = skip, Skipto = skipto }; } } return(entity); }
public void InitTrigger(double threshold, double sensitivity, TriggerTypeEnum triggerType, TriggerDirectionEnum?triggerDirection) { Trigger trigger = new Trigger() { Threshold = threshold, Sensitivity = sensitivity, TriggerType = triggerType, TriggerDirection = triggerDirection ?? TriggerDirectionEnum.Both }; if (triggerType == TriggerTypeEnum.Buy) { BuyTrigger = trigger; } else if (triggerType == TriggerTypeEnum.Sell) { SellTrigger = trigger; } }
// Public Methods public void Send(TriggerTypeEnum TriggerType) { switch (TriggerType) { case TriggerTypeEnum.Hold: _parentGigatronics854x.WriteString("TR0"); break; case TriggerTypeEnum.ImmediateSingle: _parentGigatronics854x.WriteString("TR1"); break; case TriggerTypeEnum.ImmediateAveraging: _parentGigatronics854x.WriteString("TR2"); break; case TriggerTypeEnum.FreeRun: _parentGigatronics854x.WriteString("TR3"); break; } }
public Trigger(XmlNode xmlNode) { XmlNodeList levelNodeList = xmlNode.SelectNodes("level"); if (levelNodeList.Count > 1 ) { throw new Exception(); } foreach (XmlNode item in levelNodeList) { if (item.Attributes["href"] != null || item.Attributes["id"] == null) { if (item.Attributes["id"] != null) { levelIDRef = item.Attributes["id"].Name; XsdTypeDecimal ob = XsdTypeDecimal(); IDManager.SetID(levelIDRef, ob); } else if (item.Attributes.ToString() == "href") { levelIDRef = item.Attributes["href"].Name; } else { level = new XsdTypeDecimal(item); } } } XmlNodeList levelPercentageNodeList = xmlNode.SelectNodes("levelPercentage"); if (levelPercentageNodeList.Count > 1 ) { throw new Exception(); } foreach (XmlNode item in levelPercentageNodeList) { if (item.Attributes["href"] != null || item.Attributes["id"] == null) { if (item.Attributes["id"] != null) { levelPercentageIDRef = item.Attributes["id"].Name; XsdTypeDecimal ob = XsdTypeDecimal(); IDManager.SetID(levelPercentageIDRef, ob); } else if (item.Attributes.ToString() == "href") { levelPercentageIDRef = item.Attributes["href"].Name; } else { levelPercentage = new XsdTypeDecimal(item); } } } XmlNodeList creditEventsNodeList = xmlNode.SelectNodes("creditEvents"); if (creditEventsNodeList.Count > 1 ) { throw new Exception(); } foreach (XmlNode item in creditEventsNodeList) { if (item.Attributes["href"] != null || item.Attributes["id"] == null) { if (item.Attributes["id"] != null) { creditEventsIDRef = item.Attributes["id"].Name; CreditEvents ob = CreditEvents(); IDManager.SetID(creditEventsIDRef, ob); } else if (item.Attributes.ToString() == "href") { creditEventsIDRef = item.Attributes["href"].Name; } else { creditEvents = new CreditEvents(item); } } } XmlNodeList creditEventsReferenceNodeList = xmlNode.SelectNodes("creditEventsReference"); if (creditEventsReferenceNodeList.Count > 1 ) { throw new Exception(); } foreach (XmlNode item in creditEventsReferenceNodeList) { if (item.Attributes["href"] != null || item.Attributes["id"] == null) { if (item.Attributes["id"] != null) { creditEventsReferenceIDRef = item.Attributes["id"].Name; CreditEventsReference ob = CreditEventsReference(); IDManager.SetID(creditEventsReferenceIDRef, ob); } else if (item.Attributes.ToString() == "href") { creditEventsReferenceIDRef = item.Attributes["href"].Name; } else { creditEventsReference = new CreditEventsReference(item); } } } XmlNodeList triggerTypeNodeList = xmlNode.SelectNodes("triggerType"); if (triggerTypeNodeList.Count > 1 ) { throw new Exception(); } foreach (XmlNode item in triggerTypeNodeList) { if (item.Attributes["href"] != null || item.Attributes["id"] == null) { if (item.Attributes["id"] != null) { triggerTypeIDRef = item.Attributes["id"].Name; TriggerTypeEnum ob = TriggerTypeEnum(); IDManager.SetID(triggerTypeIDRef, ob); } else if (item.Attributes.ToString() == "href") { triggerTypeIDRef = item.Attributes["href"].Name; } else { triggerType = new TriggerTypeEnum(item); } } } XmlNodeList triggerTimeTypeNodeList = xmlNode.SelectNodes("triggerTimeType"); if (triggerTimeTypeNodeList.Count > 1 ) { throw new Exception(); } foreach (XmlNode item in triggerTimeTypeNodeList) { if (item.Attributes["href"] != null || item.Attributes["id"] == null) { if (item.Attributes["id"] != null) { triggerTimeTypeIDRef = item.Attributes["id"].Name; TriggerTimeTypeEnum ob = TriggerTimeTypeEnum(); IDManager.SetID(triggerTimeTypeIDRef, ob); } else if (item.Attributes.ToString() == "href") { triggerTimeTypeIDRef = item.Attributes["href"].Name; } else { triggerTimeType = new TriggerTimeTypeEnum(item); } } } }
static void Main(string[] args) { bool exit = false; PriceMoniter priceMoniter = new PriceMoniter(); while (!exit) { PrintPrompt(); try { // Assumption: user input all positive numbers switch (Console.ReadKey(true).KeyChar) { case '1': Console.WriteLine("Please set the current price"); double price = Convert.ToDouble(Console.ReadLine()); priceMoniter.SetPrice(price); Console.WriteLine($"The current price is: {price}"); Console.WriteLine(); break; case '2': Console.WriteLine("Please select the trigger type"); Console.WriteLine("1: Buy Trigger"); Console.WriteLine("2: Sell Trigger"); TriggerTypeEnum triggerType = (TriggerTypeEnum)Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Please set the trigger direction"); Console.WriteLine("1: Both"); Console.WriteLine("2: Only send notification when price rises"); Console.WriteLine("3: Only send notification when price drops"); TriggerDirectionEnum triggerDirection = (TriggerDirectionEnum)Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Please set the trigger threshold"); double threshold = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Please set the trigger sensitivity"); double sensitivity = Convert.ToDouble(Console.ReadLine()); if (triggerType == TriggerTypeEnum.Buy) { if (priceMoniter.BuyTrigger == null) { priceMoniter.InitTrigger(threshold, sensitivity, triggerType, triggerDirection); priceMoniter.BuyTrigger.TriggerThresholdReached += BuyTriggerThresholdReachedHandler; } else { priceMoniter.UpdateTrigger(threshold, sensitivity, triggerType, triggerDirection); } } else if (triggerType == TriggerTypeEnum.Sell) { if (priceMoniter.SellTrigger == null) { priceMoniter.InitTrigger(threshold, sensitivity, triggerType, triggerDirection); priceMoniter.SellTrigger.TriggerThresholdReached += SellTriggerThresholdReachedHandler; } else { priceMoniter.UpdateTrigger(threshold, sensitivity, triggerType, triggerDirection); } } Console.WriteLine($"Trigger Type: {triggerType}, Trigger Direction: {triggerDirection}, Trigger Threshold: {threshold}, Trigger Sensitivity: {sensitivity}"); Console.WriteLine(); break; case '3': if (priceMoniter.BuyTrigger == null && priceMoniter.SellTrigger == null) { Console.WriteLine($"There is no trigger available"); } else if (priceMoniter.BuyTrigger == null) { Console.WriteLine($"Trigger Type: {priceMoniter.SellTrigger.TriggerType}, Trigger Direction: {priceMoniter.SellTrigger.TriggerDirection}, Trigger Threshold: {priceMoniter.SellTrigger.Threshold}, Trigger Sensitivity: {priceMoniter.SellTrigger.Sensitivity}"); } else if (priceMoniter.SellTrigger == null) { Console.WriteLine($"Trigger Type: {priceMoniter.BuyTrigger.TriggerType}, Trigger Direction: {priceMoniter.BuyTrigger.TriggerDirection}, Trigger Threshold: {priceMoniter.BuyTrigger.Threshold}, Trigger Sensitivity: {priceMoniter.BuyTrigger.Sensitivity}"); } else { Console.WriteLine($"Trigger Type: {priceMoniter.SellTrigger.TriggerType}, Trigger Direction: {priceMoniter.SellTrigger.TriggerDirection}, Trigger Threshold: {priceMoniter.SellTrigger.Threshold}, Trigger Sensitivity: {priceMoniter.SellTrigger.Sensitivity}"); Console.WriteLine($"Trigger Type: {priceMoniter.BuyTrigger.TriggerType}, Trigger Direction: {priceMoniter.BuyTrigger.TriggerDirection}, Trigger Threshold: {priceMoniter.BuyTrigger.Threshold}, Trigger Sensitivity: {priceMoniter.BuyTrigger.Sensitivity}"); } Console.WriteLine(); break; case '4': exit = true; Environment.Exit(0); break; default: break; } } catch (Exception ex) { // Log Error } } }
public TimerEventArgs(float trigger, TriggerTypeEnum typeOfTrigger) { TriggerValue = trigger; TriggerType = typeOfTrigger; }
public TimerEventArgs(float trigger, TriggerTypeEnum typeOfTrigger) { TriggerValue = trigger; TriggerType = typeOfTrigger; }
/// <summary> /// 把Xml节点转换为ActivityTypeDetail 类(用于会签等复杂类型) /// </summary> /// <param name="typeNode">类型节点</param> /// <returns>活动类型详细</returns> private static ActivityTypeDetail ConvertXmlNodeToActivityTypeDetail(XmlNode typeNode) { ActivityTypeDetail typeDetail = new ActivityTypeDetail(); typeDetail.ActivityType = (ActivityTypeEnum)Enum.Parse(typeof(ActivityTypeEnum), XMLHelper.GetXmlAttribute(typeNode, "type")); if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "trigger"))) { TriggerTypeEnum triggerType = TriggerTypeEnum.None; Enum.TryParse <TriggerTypeEnum>(XMLHelper.GetXmlAttribute(typeNode, "trigger"), out triggerType); typeDetail.TriggerType = triggerType; //获取时间或消息表达式 if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "expression"))) { typeDetail.Expression = XMLHelper.GetXmlAttribute(typeNode, "expression"); } //获取消息捕获或抛出类型 if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "messageDirection"))) { MessageDirectionEnum msgDirection = MessageDirectionEnum.None; Enum.TryParse <MessageDirectionEnum>(XMLHelper.GetXmlAttribute(typeNode, "messageDirection"), out msgDirection); typeDetail.MessageDirection = msgDirection; } } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "complexType"))) { typeDetail.ComplexType = EnumHelper.ParseEnum <ComplexTypeEnum>(XMLHelper.GetXmlAttribute(typeNode, "complexType")); } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "mergeType"))) { typeDetail.MergeType = EnumHelper.ParseEnum <MergeTypeEnum>(XMLHelper.GetXmlAttribute(typeNode, "mergeType")); } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "compareType"))) { typeDetail.CompareType = EnumHelper.ParseEnum <CompareTypeEnum>(XMLHelper.GetXmlAttribute(typeNode, "compareType")); } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "completeOrder"))) { typeDetail.CompleteOrder = float.Parse(XMLHelper.GetXmlAttribute(typeNode, "completeOrder")); } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "subType"))) { typeDetail.SubProcessType = EnumHelper.ParseEnum <SubProcessTypeEnum>(XMLHelper.GetXmlAttribute(typeNode, "subType")); typeDetail.SubProcessGUID = XMLHelper.GetXmlAttribute(typeNode, "subId"); typeDetail.SubVariableName = XMLHelper.GetXmlAttribute(typeNode, "subVar"); } if (!string.IsNullOrEmpty(XMLHelper.GetXmlAttribute(typeNode, "skip"))) { var skip = Boolean.Parse(XMLHelper.GetXmlAttribute(typeNode, "skip")); var skipto = XMLHelper.GetXmlAttribute(typeNode, "to"); if (skip) { typeDetail.SkipInfo = new SkipInfo { IsSkip = skip, Skipto = skipto }; } } return(typeDetail); }
protected SubBase(TriggerTypeEnum type) { Type = type; }