public byte[] SwitchSet(EObject eo, bool sw) { byte[] sendFrame = CreateSwitchFrame(eo, sw); //スイッチ用のフレームを取得します byte[] recvBytes = null; IPEndPoint remoteEP = null; using (UdpClient udp = new UdpClient(Port)) { udp.Client.ReceiveTimeout = 5000; //5secでタイムアウト try { udp.Send(sendFrame, sendFrame.Length, eo.IPAddress, Port); recvBytes = udp.Receive(ref remoteEP); } catch (Exception ee) { Debug.WriteLine(ee.StackTrace); Debug.WriteLine(ee.Message); } } //udp.Close(); //受信したデータと送信者の情報を表示する Debug.WriteLine("送信元アドレス:{0}/ポート番号:{1}", remoteEP.Address, remoteEP.Port); for (int j = 0; j < recvBytes.Length; j++) { Debug.Write(recvBytes[j].ToString("X2") + " "); } Debug.WriteLine(""); return(recvBytes); }
public bool validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Dictionary <object, object> context) { Object eValidator = null; EClass eType = eClass; //while ((eValidator = eValidatorRegistry.get(eType.eContainer())) == null) while (!eValidatorRegistry.ContainsKey(eType.eContainer() as EPackage)) { eValidator = eValidatorRegistry[eType.eContainer() as EPackage]; List <EClass> eSuperTypes = eType.eSuperTypes; if (eSuperTypes.Count == 0) { //TODO return a defaultCase eValidator = null;// eValidatorRegistry.get(null); break; } else { eType = eSuperTypes.ElementAt(0); } } //bool circular = context.get(EObjectValidator.ROOT_OBJECT) == eObject; //TODO containskey check bool circular = context[EObjectValidator.ROOT_OBJECT] == eObject; bool result = doValidate((EValidator)eValidator, eClass, eObject, diagnostics, context); if ((result || diagnostics != null) && !circular) { result &= doValidateContents(eObject, diagnostics, context); } return(result); }
private String value(EObject eobject, EAttribute attribute) { var classifier = attribute.eType; if (classifier.Equals(EcorePackageImpl.Literals.EBOOLEAN)) { return($"{eobject.eGet(attribute)}"); } else if (classifier.Equals(EcorePackageImpl.Literals.EINT)) { return($"{eobject.eGet(attribute)}"); } else if (classifier.Equals(EcorePackageImpl.Literals.EDOUBLE)) { return($"{eobject.eGet(attribute)}"); } else if (classifier.Equals(EcorePackageImpl.Literals.EFLOAT)) { return($"{eobject.eGet(attribute)}"); } else if (classifier.Equals(EcorePackageImpl.Literals.ESTRING)) { return($"\"{eobject.eGet(attribute)}\""); } else if (classifier.Equals(EcorePackageImpl.Literals.ECHAR)) { return($"\"{eobject.eGet(attribute)}\""); } else { throw new ArgumentException(); } }
public bool validate_NoCircularContainment(EObject eObject, DiagnosticChain diagnostics, Dictionary <object, object> context) { if (context != null) { Object root = context[ROOT_OBJECT]; if (root == null) { context.Add(ROOT_OBJECT, eObject); } else if (root == eObject) { if (diagnostics != null) { diagnostics.add (createDiagnostic (BasicDiagnostic.ERROR, DIAGNOSTIC_SOURCE, EOBJECT__NO_CIRCULAR_CONTAINMENT, "_UI_CircularContainment_diagnostic", new Object[] { getObjectLabel(eObject, context), }, new Object[] { eObject }, context)); } return(false); } } return(true); }
public void castSpellSleepPosCon(Agent target, EObject potion) { target.setUnconscious(); backpack.Remove(potion); castSpellEffect(); target.spelledEffect(); }
/// <summary> /// スイッチ用のフレームを生成します /// </summary> /// <returns></returns> private byte[] CreateSwitchFrame(EObject eo, bool sw) { byte[] frame = new byte[15]; frame[0] = (byte)(Header >> 8); //EHD1 ECHONETLiteヘッダ 1Byte 0x10固定 frame[1] = (byte)(Header & 0xFF); //EHD2 ECHONETLiteヘッダ 1Byte 0x81固定 frame[2] = (byte)(TransactionID >> 8); //TID トランザクションID 2Byte 0~65535 frame[3] = (byte)(TransactionID & 0xFF); //TID トランザクションID 2Byte 0~65535 frame[4] = ControllerGrpCd; //SEOJ 送信元オブジェクト コントローラークラスグループコード frame[5] = ControllerClsCd; //SEOJ 送信元オブジェクト コントローラークラスコード frame[6] = ControllerInsCd; //SEOJ 送信元オブジェクト インスタンスコード frame[7] = eo.GroupCd; //DEOJ 送信先オブジェクト グループコード frame[8] = eo.ClassCd; //DEOJ 送信先オブジェクト ラスコード frame[9] = eo.InstanceCd; //DEOJ 送信先オブジェクト インスタンスコード frame[10] = (byte)enmESV.SETC; //ESV サービスコード SETC frame[11] = (byte)0x01; //OPC プロパティ数 frame[12] = (byte)0x80; //EPC プロパティ番号 スイッチのオンオフ frame[13] = (byte)0x01; //PDC EDTのバイト数 frame[14] = sw ? (byte)0x30 : (byte)0x31; //0x30がスイッチオン 0x31がスイッチオフ return(frame); }
public void put(EObject obj) { SimulationState.getInstance().stdout.Send("entro put"); obj.gameObject.SetActive(false); obj.transform.position = this.transform.position; content.Add(obj); SimulationState.getInstance().stdout.Send("salio put"); }
public void drop(EObject obj) { obj.gameObject.SetActive(true); Vector3 newPosition = this.transform.position; newPosition.y += 2.5f; obj.transform.position = newPosition; obj.rigidbody.AddForce(new Vector3(20,20,20)); }
public void drop(EObject obj) { obj.gameObject.SetActive(true); Vector3 newPosition = this.transform.position; newPosition.y += 2.5f; obj.transform.position = newPosition; obj.rigidbody.AddForce(new Vector3(20, 20, 20)); }
public static string getID(EObject eObject) { EClass eClass = eObject.eClass(); EAttribute eIDAttribute = eClass.eIDAttribute; return(eIDAttribute == null || !eObject.eIsSet(eIDAttribute) ? null : convertToString( eIDAttribute.eAttributeType, eObject.eGet(eIDAttribute))); }
public bool castSpellSleepPreCon(Agent target, EObject potion) { SimulationState.getInstance().stdout.Send(target._name); SimulationState.getInstance().stdout.Send(potion.ToString()); Vector3 distance = this.transform.position - this.position; return(target != null && target.isConscious() && potion != null && backpack.Contains(potion) && distance.magnitude < 11f); }
public void dropPosCon(EObject obj) { Vector3 newPosition = this.transform.position; this.backpack.Remove(obj); obj.gameObject.SetActive(true); newPosition.y += 2.5f; obj.setPosition(newPosition); obj.rigidbody.AddForce(new Vector3(20, 20, 20)); //TODO: cambiar esta fruta }
protected void reportConstraintDelegateViolation(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Dictionary <object, object> context, string constraint, int severity, string source, int code) { diagnostics.add (new BasicDiagnostic (severity, source, code, getString("_UI_GenericConstraint_diagnostic", new Object[] { constraint, getObjectLabel(eObject, context) }), new Object[] { eObject })); }
protected T doSwitch(EClass eClass, EObject eObject) { if (isSwitchFor(eClass.ePackage)) { return(doSwitch(eClass.getClassifierID(), eObject)); } else { OrderedSet <EClass> eSuperTypes = eClass.eSuperTypes; return(eSuperTypes.isEmpty() ? defaultCase(eObject) : doSwitch(eSuperTypes.at(0), eObject)); } }
//DEPRECATED public void pickup(EObject obj) { if (isReachableObject(obj)) { obj.gameObject.SetActive(false); this.backpack.Add(obj); } else { // TODO: excepcion? devolver falso? guardarlo en algun lado? } }
/* * public bool validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Dictionary<object, object> context, string validationDelegate, string constraint, string expression, int severity, string source, int code) * { * ValidationDelegate delegate = getValidationDelegateRegistry(context).getValidationDelegate(validationDelegate); * if (delegate != null) * { * try * { * if (!delegate.validate(eClass, eObject, context, constraint, expression)) * { * if (diagnostics != null) * reportConstraintDelegateViolation(eClass, eObject, diagnostics, context, constraint, severity, source, code); * return false; * } * } * catch (Throwable throwable) * { * if (diagnostics != null) * reportConstraintDelegateException(eClass, eObject, diagnostics, context, constraint, severity, source, code, throwable); * } * } * else * { * if (diagnostics != null) * reportConstraintDelegateNotFound(eClass, eObject, diagnostics, context, constraint, severity, source, code, validationDelegate); * } * return true; * } */ public bool validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Dictionary <object, object> context, string validationDelegate, string constraint, bool expression, int severity, string source, int code) { if (!expression) { reportConstraintDelegateViolation(eClass, eObject, diagnostics, context, constraint, severity, source, code); return(false); } else { return(true); } }
/** * @since 2.1.0 */ public static string getObjectLabel(EObject eObject, Dictionary <object, object> context) { /* * if (context != null) * { * SubstitutionLabelProvider substitutionlabelProvider = (SubstitutionLabelProvider)context[typeof(SubstitutionLabelProvider)]; * if (substitutionlabelProvider != null) * { * return substitutionlabelProvider.getObjectLabel(eObject); * } * } */ return(EcoreUtil.getIdentification(eObject)); }
public bool validate_EveryDataValueConforms(EObject eObject, DiagnosticChain diagnostics, Dictionary <object, object> context) { bool result = true; foreach (EAttribute eAttribute in eObject.eClass().eAllAttributes) { result &= validate_DataValueConforms(eObject, eAttribute, diagnostics, context); if (!result && diagnostics == null) { return(false); } } return(result); }
public bool validate_EveryMultiplicityConforms(EObject eObject, DiagnosticChain diagnostics, Dictionary <object, object> context) { bool result = true; EClass eClass = eObject.eClass(); for (int i = 0, size = eClass.getFeatureCount(); i < size; ++i) { result &= validate_MultiplicityConforms(eObject, eClass.getEStructuralFeature(i), diagnostics, context); if (!result && diagnostics == null) { return(false); } } return(result); }
public virtual bool validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Dictionary <object, object> context) { if (eObject.eIsProxy()) { if (context != null && context.ContainsKey(ROOT_OBJECT) && context[ROOT_OBJECT] != null) { if (diagnostics != null) { diagnostics.add (createDiagnostic (BasicDiagnostic.ERROR, DIAGNOSTIC_SOURCE, EOBJECT__EVERY_PROXY_RESOLVES, "_UI_UnresolvedProxy_diagnostic", new Object[] { getFeatureLabel(eObject.eContainmentFeature(), context), getObjectLabel(eObject.eContainer(), context), getObjectLabel(eObject, context) }, new Object[] { eObject.eContainer(), eObject.eContainmentFeature(), eObject }, context)); } return(false); } else { return(true); } } else if (eClass.eContainer() == getEPackage()) { return(validate(eClass.getClassifierID(), eObject, diagnostics, context)); } else { return(true); /* * return * new DynamicEClassValidator() * { * // Ensure that the class loader for this class will be used downstream. * // * }.validate(eClass, eObject, diagnostics, context); */ } }
private EObject resolveRecurr(Queue <String> path, EObject current) { if (path.Count == 0) { return(current); } String segment = path.Dequeue(); foreach (EStructuralFeature feature in current.eClass().eAllContainments) { if (segment.StartsWith("@")) { var startIndex = 1; var endIndex = segment.LastIndexOf("."); var length = endIndex - startIndex; var featurename = segment.Substring(startIndex, length); if (feature.name == featurename) { var length2 = segment.Length - endIndex - 1; var array_index = Int32.Parse(segment.Substring(endIndex + 1, length2)); var enumerable = current.eGet(feature) as IEnumerable <EObject>; var list = enumerable.ToList(); //TODO list of primitives/objects? var item = list[array_index]; return(resolveRecurr(path, item)); } } else if (feature.name == segment) { return(resolveRecurr(path, current.eGet(feature) as EObject)); } } return(null); }
protected override T doSwitch(int classifierID, EObject theEObject) { switch (classifierID) { case OcltestmodelPackageImpl.MYCLASS: { var myclass = (MyClass)theEObject; var result = caseMyClass(myclass); if (result == null) { result = defaultCase(theEObject); } return(result); } default: return(defaultCase(theEObject)); } }
//DEPRECATED public void drop(EObject obj) { if (backpack.Contains(obj)) { Vector3 newPosition = this.transform.position; this.backpack.Remove(obj); obj.gameObject.SetActive(true); newPosition.y += 2.5f; obj.transform.position = newPosition; if (!obj._type.Equals("potion")) { obj.rigidbody.AddForce(new Vector3(20, 20, 20)); //TODO: cambiar esta fruta } } else { //TODO: excepcion? devolver falso? guardarlo en algun lado? } }
protected override T doSwitch(int classifierID, EObject theEObject) { switch (classifierID) { case SerializationPackageImpl.MYCLASS: { var theMyClass = (MyClass)theEObject; var result = caseMyClass(theMyClass); if (result == null) { result = defaultCase(theEObject); } return(result); } case SerializationPackageImpl.OTHERCLASS: { var theOtherClass = (OtherClass)theEObject; var result = caseOtherClass(theOtherClass); if (result == null) { result = defaultCase(theEObject); } return(result); } case SerializationPackageImpl.YETANOTHERCLASS: { var theYetAnotherClass = (YetAnotherClass)theEObject; var result = caseYetAnotherClass(theYetAnotherClass); if (result == null) { result = defaultCase(theEObject); } return(result); } default: return(defaultCase(theEObject)); } }
protected DiagnosticChain createBadDataValueDiagnostic (EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Dictionary <object, object> context) { BasicDiagnostic diagnostic = createDiagnostic (BasicDiagnostic.ERROR, DIAGNOSTIC_SOURCE, EOBJECT__EVERY_DATA_VALUE_CONFORMS, "_UI_BadDataValue_diagnostic", new Object[] { getFeatureLabel(eAttribute, context), getObjectLabel(eObject, context) }, new Object[] { eObject, eAttribute }, context); diagnostics.add(diagnostic); return(diagnostic); }
protected bool doValidateContents(EObject eObject, DiagnosticChain diagnostics, Dictionary <Object, Object> context) { List <EObject> eContents = eObject.eContents(); if (eContents.Count > 0) { bool result = true; foreach (EObject child in eContents) { result &= validate(child, diagnostics, context); } return(result); } else { return(true); } }
public bool validate_EveryBidirectionalReferenceIsPaired(EObject eObject, DiagnosticChain diagnostics, Dictionary <object, object> context) { bool result = true; foreach (EReference eReference in eObject.eClass().eAllReferences) { if (eReference.resolveProxies) { EReference eOpposite = eReference.eOpposite; if (eOpposite != null) { result &= validate_BidirectionalReferenceIsPaired(eObject, eReference, eOpposite, diagnostics, context); if (!result && diagnostics == null) { return(false); } } } } return(result); }
public static string getIdentification(EObject eObject) { StringBuilder result = new StringBuilder(eObject.eClass().name); EClass eClass = eObject.eClass(); if (eClass.instanceClassName == null) { result.Append('/'); result.Append(eClass.ePackage.nsURI); result.Append('#'); result.Append(eClass.name); } result.Append('@'); result.Append(eObject.GetHashCode().ToString("X")); result.Append('{'); //TODO result.Append(getURI(eObject)); result.Append('}'); return(result.ToString()); }
public bool validate_EveryMapEntryUnique(EObject eObject, DiagnosticChain diagnostics, Dictionary <object, object> context) { bool result = true; /* * EClass eClass = eObject.eClass(); * for (int i = 0, size = eClass.getFeatureCount(); i < size; ++i) * { * EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); * if (eStructuralFeature.getEType().getInstanceClassName() == "java.util.Map$Entry" && eStructuralFeature instanceof EReference) * { * EReference eReference = (EReference)eStructuralFeature; * result &= validate_MapEntryUnique(eObject, eReference, diagnostics, context); * if (!result && diagnostics == null) * { * return false; * } * } * } */ return(result); }
private EObject resolveRecurr(Queue <String> path, EObject current) { if (path.Count == 0) { return(current); } String segment = path.Dequeue(); foreach (EObject content in current.eContents()) { if (content is ENamedElement) { if ((content as ENamedElement).name == segment) { return(resolveRecurr(path, content)); } } } return(null); }
public bool validate_EveryDefaultConstraint(EObject obj, DiagnosticChain theDiagnostics, Dictionary <object, object> context) { if (!validate_NoCircularContainment(obj, theDiagnostics, context)) { return(false); } bool result = validate_EveryMultiplicityConforms(obj, theDiagnostics, context); if (result || theDiagnostics != null) { result &= validate_EveryProxyResolves(obj, theDiagnostics, context); } if (result || theDiagnostics != null) { result &= validate_EveryReferenceIsContained(obj, theDiagnostics, context); } if (result || theDiagnostics != null) { result &= validate_EveryBidirectionalReferenceIsPaired(obj, theDiagnostics, context); } if (result || theDiagnostics != null) { result &= validate_EveryDataValueConforms(obj, theDiagnostics, context); } if (result || theDiagnostics != null) { result &= validate_UniqueID(obj, theDiagnostics, context); } if (result || theDiagnostics != null) { result &= validate_EveryKeyUnique(obj, theDiagnostics, context); } if (result || theDiagnostics != null) { result &= validate_EveryMapEntryUnique(obj, theDiagnostics, context); } return(result); }