public override void Perform(MHEngine engine) { MHObjectRef target = new MHObjectRef(); m_Target.GetValue(target, engine); // Get the target if (m_fIsIncluded) { // Included content MHOctetString included = new MHOctetString(); m_Included.GetValue(included, engine); engine.FindObject(target).SetData(included, engine); } else { MHContentRef referenced = new MHContentRef(); int size, cc; m_Referenced.GetValue(referenced, engine); if (m_fSizePresent) { size = m_ContentSize.GetValue(engine); } else { size = 0; } if (m_fCCPriorityPresent) { cc = m_CCPriority.GetValue(engine); } else { cc = 0; } engine.FindObject(target).SetData(referenced, m_fSizePresent, size, m_fCCPriorityPresent, cc, engine); } }
public virtual void SearchAndExtractSubString(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 5) { // Find a substring within a string and return an index to the position // and the prefix to the substring. MHOctetString str = new MHOctetString(); MHOctetString searchString = new MHOctetString(); GetString(args.GetAt(0), str, engine); int nStart = GetInt(args.GetAt(1), engine); if (nStart < 1) { nStart = 1; } GetString(args.GetAt(2), searchString, engine); // Strings are indexed from one. int nPos; for (nPos = nStart - 1; nPos <= str.Size - searchString.Size; nPos++) { int i; for (i = 0; i < searchString.Size; i++) { if (searchString.GetAt(i) != str.GetAt(i + nPos)) { break; // Doesn't match } } if (i == searchString.Size) { break; // Found a match. } } // Set the results. MHParameter pResString = args.GetAt(3); MHParameter pResInt = args.GetAt(4); SetSuccessFlag(success, true, engine); // Set this first. if (nPos <= str.Size - searchString.Size) { // Found // Set the index to the position AFTER the string, counting from 1. engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(nPos + 1 + searchString.Size)); // Return the sequence from nStart - 1 of length nPos - nStart + 1 MHOctetString resultString = new MHOctetString(str, nStart - 1, nPos - nStart + 1); engine.FindObject(pResString.GetReference()).SetVariableValue(new MHUnion(resultString)); } else { // Not found. Set the result string to empty and the result index to -1 engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(-1)); engine.FindObject(pResString.GetReference()).SetVariableValue(new MHUnion(new MHOctetString(""))); } } else { SetSuccessFlag(success, false, engine); } }
public virtual void SearchSubString(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 4) { // Find a substring within a string and return an index to the position. MHOctetString str = new MHOctetString(); MHOctetString searchString = new MHOctetString(); GetString(args.GetAt(0), str, engine); int nStart = GetInt(args.GetAt(1), engine); if (nStart < 1) { nStart = 1; } GetString(args.GetAt(2), searchString, engine); // Strings are indexed from one. int nPos; for (nPos = nStart - 1; nPos <= str.Size - searchString.Size; nPos++) { int i; for (i = 0; i < searchString.Size; i++) { if (searchString.GetAt(i) != str.GetAt(i + nPos)) { break; } } if (i == searchString.Size) { break; // Found a match. } } // Set the result. MHParameter pResInt = args.GetAt(3); SetSuccessFlag(success, true, engine); // Set this first. if (nPos <= str.Size - searchString.Size) { // Found // Set the index to the position of the string, counting from 1. engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(nPos + 1)); } else { // Not found. Set the result index to -1 engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(-1)); } } else { SetSuccessFlag(success, false, engine); } }
public override void Perform(MHEngine engine) { // This is a special case. If the object does not exist we set the result to false. MHObjectRef target = new MHObjectRef(); m_Target.GetValue(target, engine); // Get the target MHRoot pObject = engine.FindObject(target, false); bool fResult = false; // Default result. if (pObject == null) { fResult = pObject.AvailabilityStatus; } engine.FindObject(m_ResultVar).SetVariableValue(new MHUnion(fResult)); }
public override void Activation(MHEngine engine) { if (m_fRunning) { return; } base.Activation(engine); // We're supposed to apply Activation to each of the "items" but it isn't clear // exactly what that means. Assume it means each of the visibles. for (int i = 0; i < m_TokenGrpItems.Size; i++) { MHObjectRef pObject = m_TokenGrpItems.GetAt(i).Object; // The object reference may be the null reference. // Worse: it seems that sometimes in BBC's MHEG the reference simply doesn't exist. if (pObject.IsSet()) { try { engine.FindObject(m_TokenGrpItems.GetAt(i).Object).Activation(engine); } catch (MHEGException) {} } } engine.EventTriggered(this, EventTokenMovedTo, new MHUnion(m_nTokenPosition)); m_fRunning = true; engine.EventTriggered(this, EventIsRunning); }
public override void Perform(MHEngine engine) { MHObjectRef item = new MHObjectRef(); m_Item.GetValue(item, engine); Target(engine).AddItem(m_Index.GetValue(engine), engine.FindObject(item), engine); }
public override void Perform(MHEngine engine) { MHObjectRef reference = new MHObjectRef(); m_RefObject.GetValue(reference, engine); CallAction(engine, Target(engine), engine.FindObject(reference)); }
// Look up the target protected MHRoot Target(MHEngine engine) { MHObjectRef target = new MHObjectRef(); m_Target.GetValue(target, engine); return(engine.FindObject(target)); }
public override void Perform(MHEngine engine) { // Ignore the target which isn't used. MHOctetString feature = new MHOctetString(); m_Feature.GetValue(feature, engine); engine.FindObject(m_Answer).SetVariableValue(new MHUnion(engine.GetEngineSupport(feature))); }
public virtual void GetCurrentDate(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 2) { DateTime dt = new DateTime(1858, 11, 17); DateTime now = DateTime.Now; int nModJulianDate = now.Subtract(dt).Days; int nTimeAsSecs = (int)now.TimeOfDay.TotalSeconds; engine.FindObject(args.GetAt(0).GetReference()).SetVariableValue(new MHUnion(nModJulianDate)); engine.FindObject(args.GetAt(1).GetReference()).SetVariableValue(new MHUnion(nTimeAsSecs)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public override void Perform(MHEngine engine) { MHObjectRef target = new MHObjectRef(); m_Target.GetValue(target, engine); // Get the target MHUnion testValue = new MHUnion(); testValue.GetValueFrom(m_Comparison, engine); // Get the actual value to compare. engine.FindObject(target).TestVariable(m_nOperator, testValue, engine); // Do the test. }
public override void Perform(MHEngine engine) { MHObjectRef target = new MHObjectRef(); m_Target.GetValue(target, engine); // Get the target MHUnion newValue = new MHUnion(); newValue.GetValueFrom(m_NewValue, engine); // Get the actual value to set. engine.FindObject(target).SetVariableValue(newValue); // Set the value. }
public override void Perform(MHEngine engine) { // The target is always the current scene so we ignore it here. MHObjectRef target = new MHObjectRef(); MHObjectRef source = new MHObjectRef(); m_Target.GetValue(target, engine); // TODO: Check this is the scene? m_EventSource.GetValue(source, engine); // Generate the event. if (m_EventData.Type == MHParameter.P_Null) { engine.EventTriggered(engine.FindObject(source), m_EventType); } else { MHUnion data = new MHUnion(); data.GetValueFrom(m_EventData, engine); engine.EventTriggered(engine.FindObject(source), m_EventType, data); } }
public override void GetListItem(int nCell, MHObjectRef itemDest, MHEngine engine) { if (m_fWrapAround) { nCell = AdjustIndex(nCell); } if (nCell < 1 || nCell > m_ItemList.Count) { return; // Ignore it if it's out of range and not wrapping } engine.FindObject(itemDest).SetVariableValue(new MHUnion(m_ItemList[nCell - 1].Visible.ObjectIdentifier)); }
public override void Perform(MHEngine engine) { MHObjectRef target = new MHObjectRef(); m_Target.GetValue(target, engine); // Get the target - this should always be the application MHOctetString fileName = new MHOctetString(); m_FileName.GetValue(fileName, engine); bool fResult = engine.LoadStorePersistent(m_bIsLoad, fileName, m_Variables); engine.FindObject(m_Succeeded).SetVariableValue(new MHUnion(fResult)); }
public override void CallAction(MHEngine engine, MHRoot pTarget, MHRoot pObj) { // We need to get the group (scene or application) that contains the target. MHObjectRef groupRef = new MHObjectRef(); groupRef.GroupId.Copy(pTarget.ObjectIdentifier.GroupId); groupRef.ObjectNo = 0; // The group always has object ref zero. MHRoot pGroup = engine.FindObject(groupRef); // Get the group to make the clone and add it to its ingredients. pGroup.MakeClone(pTarget, pObj, engine); }
public override void GetItemStatus(int nCell, MHObjectRef itemDest, MHEngine engine) { if (m_fWrapAround) { nCell = AdjustIndex(nCell); } if (nCell < 1 || nCell > (int)m_ItemList.Count) { return; } engine.FindObject(itemDest).SetVariableValue(new MHUnion(m_ItemList[nCell - 1].Selected)); }
public override void GetCellItem(int nCell, MHObjectRef itemDest, MHEngine engine) { if (nCell < 1) { nCell = 1; // First cell } if (nCell > m_Positions.Size) { nCell = m_Positions.Size; // Last cell. } int nVisIndex = nCell + m_nFirstItem - 2; if (nVisIndex >= 0 && nVisIndex < (int)m_ItemList.Count) { MHRoot pVis = m_ItemList[nVisIndex].Visible; engine.FindObject(itemDest).SetVariableValue(new MHUnion(pVis.ObjectIdentifier)); } else { engine.FindObject(itemDest).SetVariableValue(new MHUnion(MHObjectRef.Null)); } }
public virtual void Random(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 2) { int nLimit = GetInt(args.GetAt(0), engine); MHParameter pResInt = args.GetAt(1); Random randomGenerator = new Random(); engine.FindObject((pResInt.GetReference())).SetVariableValue(new MHUnion(randomGenerator.Next(nLimit) + 1)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void GetStringLength(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 2) { // Find a substring within a string and return an index to the position. MHOctetString str = new MHOctetString(); GetString(args.GetAt(0), str, engine); MHParameter pResInt = args.GetAt(1); SetSuccessFlag(success, true, engine); engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(str.Size)); } else { SetSuccessFlag(success, false, engine); } }
public virtual void CastToObjectRef(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Converts a string and an integer to an ObjectRef. if (args.Size == 3) { MHObjectRef result = new MHObjectRef(); GetString(args.GetAt(0), result.GroupId, engine); result.ObjectNo = GetInt(args.GetAt(1), engine); engine.FindObject(args.GetAt(2).GetReference()).SetVariableValue(new MHUnion(result)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void GetDayOfWeek(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 2) { int date = GetInt(args.GetAt(0), engine); // Date as produced in GCD DateTime dt = new DateTime(1858, 11, 17); int nDayOfWeek = (int)dt.AddDays(date).DayOfWeek; engine.FindObject(args.GetAt(1).GetReference()).SetVariableValue(new MHUnion(nDayOfWeek)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void CastToContentRef(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Converts a string to a ContentRef. if (args.Size == 2) { MHOctetString str = new MHOctetString(); GetString(args.GetAt(0), str, engine); MHContentRef result = new MHContentRef(); result.ContentRef.Copy(str); engine.FindObject(args.GetAt(1).GetReference()).SetVariableValue(new MHUnion(result)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public override void Perform(MHEngine engine) { MHUnion targetVal = new MHUnion(); // Find the target and get its current value. The target can be an indirect reference. MHObjectRef parm = new MHObjectRef(); m_Target.GetValue(parm, engine); MHRoot pTarget = engine.FindObject(parm); pTarget.GetVariableValue(targetVal, engine); targetVal.CheckType(MHUnion.U_Int); // Get the value of the operand. int nOperand = m_Operand.GetValue(engine); // Set the value of targetVal to the new value and store it. targetVal.Int = DoOp(targetVal.Int, nOperand); pTarget.SetVariableValue(targetVal); }
public override void Perform(MHEngine engine) { MHUnion targetVal = new MHUnion(); // Find the target and get its current value. The target can be an indirect reference. MHObjectRef parm = new MHObjectRef(); m_Target.GetValue(parm, engine); MHRoot pTarget = engine.FindObject(parm); pTarget.GetVariableValue(targetVal, engine); targetVal.CheckType(MHUnion.U_String); // Get the string to append. MHOctetString toAppend = new MHOctetString(); m_Operand.GetValue(toAppend, engine); targetVal.String.Append(toAppend); // Add it on the end pTarget.SetVariableValue(targetVal); // Set the target to the result. }
public override void Preparation(MHEngine engine) { base.Preparation(engine); for (int i = 0; i < m_TokenGrpItems.Size; i++) { // Find the item and add it to the list if it isn't already there. MHRoot pItem = engine.FindObject(m_TokenGrpItems.GetAt(i).Object); bool bFound = false; foreach (MHListItem p in m_ItemList) { if (p.Visible == pItem) { bFound = true; } } if (!bFound) { m_ItemList.Add(new MHListItem(pItem)); } } }
public virtual void SI_GetServiceIndex(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Returns an index indicating the service if (args.Size == 2) { MHOctetString str = new MHOctetString(); GetString(args.GetAt(0), str, engine); MHParameter pResInt = args.GetAt(1); // The format of the service is dvb://netID.[transPortID].serviceID // where the IDs are in hex. // or rec://svc/lcn/N where N is the "logical channel number" i.e. the Freeview channel. int nResult = engine.GetContext().GetChannelIndex(str.ToString()); engine.FindObject(pResInt.GetReference()).SetVariableValue(new MHUnion(nResult)); Logging.Log(Logging.MHLogDetail, "Get service index for " + str.Printable() + " - result " + nResult); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void WhoAmI(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { // Return a concatenation of the strings we respond to in // GetEngineSupport(UKEngineProfile(X)) if (args.Size == 1) { MHOctetString result = new MHOctetString(); result.Copy(MHEngine.MHEGEngineProviderIdString); result.Append(" "); result.Append(engine.GetContext().GetReceiverId()); result.Append(" "); result.Append(engine.GetContext().GetDSMCCId()); engine.FindObject((args.GetAt(0).GetReference())).SetVariableValue(new MHUnion(result)); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public virtual void GetSubString(MHObjectRef success, MHSequence <MHParameter> args, MHEngine engine) { if (args.Size == 4) { // Extract a sub-string from a string. MHOctetString str = new MHOctetString(); GetString(args.GetAt(0), str, engine); int nBeginExtract = GetInt(args.GetAt(1), engine); int nEndExtract = GetInt(args.GetAt(2), engine); if (nBeginExtract < 1) { nBeginExtract = 1; } if (nBeginExtract > str.Size) { nBeginExtract = str.Size; } if (nEndExtract < 1) { nEndExtract = 1; } if (nEndExtract > str.Size) { nEndExtract = str.Size; } MHParameter pResString = args.GetAt(3); // Returns beginExtract to endExtract inclusive. engine.FindObject(pResString.GetReference()).SetVariableValue( new MHUnion(new MHOctetString(str, nBeginExtract - 1, nEndExtract - nBeginExtract + 1))); SetSuccessFlag(success, true, engine); } else { SetSuccessFlag(success, false, engine); } }
public override void Perform(MHEngine engine) { CallAction(engine, Target(engine), engine.FindObject(m_ResultVar1), engine.FindObject(m_ResultVar2)); }