protected void PushFrame(CodeContext context, FunctionCode code) { if (((PythonContext)SourceUnit.LanguageContext).PythonOptions.Frames) { PythonOps.PushFrame(context, code); } }
public static FunctionServiceResult Process(Sample[] samples) { try { if (samples.Length < 5) { return(new FunctionServiceResult("Packet not long enough.")); } byte rawFunctionCode = samples[1].Value; FunctionCode functionCode = (FunctionCode)(rawFunctionCode & 0x7F); if ((rawFunctionCode & 0x80) > 0) { var exceptionDescription = SlaveExceptionDescriptionFactory.GetExceptionDescription(samples[2].Value); return(new FunctionServiceResult(error: exceptionDescription)); } if (_functionServices.TryGetValue(functionCode, out var service)) { return(service.Process(samples)); } return(new FunctionServiceResult(error: "Unsupported function code.")); } catch (Exception ex) { return(new FunctionServiceResult(ex.Message)); } }
public PointDescription(string path, int index) { this.Index = index; string[] info = path.Split('/'); this.Function = (FunctionCode)int.Parse(info[0]); this.Address = int.Parse(info[1]); }
public void AddReadOrder(FunctionCode functionCode, int quantity, int startingAddress, int cycleTime) { ReadOrder readOrder = new ReadOrder(); readOrder.CylceTime = cycleTime; readOrder.FunctionCode = functionCode; readOrder.Quantity = quantity; readOrder.StartingAddress = startingAddress; readOrder.Topic = new string[quantity]; readOrder.Retain = new bool[quantity]; readOrder.oldvalue = new object[quantity]; int index = 0; while (index < quantity) { if (functionCode == FunctionCode.ReadCoils) { readOrder.Topic[index] = this.mqttRootTopic + "/coils/" + checked (index + readOrder.StartingAddress).ToString(); } if (functionCode == FunctionCode.ReadDiscreteInputs) { readOrder.Topic[index] = this.mqttRootTopic + "/discreteinputs/" + checked (index + readOrder.StartingAddress).ToString(); } if (functionCode == FunctionCode.ReadHoldingRegisters) { readOrder.Topic[index] = this.mqttRootTopic + "/holdingregisters/" + checked (index + readOrder.StartingAddress).ToString(); } if (functionCode == FunctionCode.ReadInputRegisters) { readOrder.Topic[index] = this.mqttRootTopic + "/inputregisters/" + checked (index + readOrder.StartingAddress).ToString(); } checked { ++index; } } this.readOrders.Add(readOrder); }
public byte[] Do(byte[] frame) { DataWriter dw = new DataWriter(); DataReader dr = new DataReader(frame); FunctionCode funcCode = dr.GetFuncCode(); byte dispLine = dr.GetByte(); if (dispLine >= _lcdDispLineArr.Length) { ResultFunction rf = new ResultFunction(1); return(rf.Do(null)); } if (funcCode == FunctionCode.LCDRead) { dw.Add(funcCode); dw.Add(_lcdDispLineArr[dispLine]); return(dw.GetBuffer()); } else if (funcCode == FunctionCode.LCDWrite) { _lcdDispLineArr[dispLine] = dr.GetString(); ResultFunction rf = new ResultFunction(0); return(rf.Do(null)); } else { ResultFunction rf = new ResultFunction(1); return(rf.Do(null)); } }
internal ModbusException(int DeviceAddress, FunctionCode FunctionCode, ExceptionType Type, string Comment = null) { this.Type = Type; this.DeviceAddress = DeviceAddress; this.Code = FunctionCode; this.Comment = Comment; }
public void TracebackEvent(object sender, IPYTracebackEventArgs e) { FunctionCode code = e.frame.f_code; string filename = code.co_filename; try { switch (e.result) { case "call": TracebackCall(e); break; case "line": TracebackLine(e); break; case "return": TracebackReturn(e); break; default: break; } } catch (Exception ex) { Invoke((Action)(() => { ExceptionViewer ev = new ExceptionViewer("TracebackEvent", ex); ev.ShowDialog(); })); } }
internal TraceBackFrame(CodeContext /*!*/ context, PythonDictionary globals, object locals, FunctionCode code) { _globals = globals; _locals = locals; _code = code; _context = context; }
internal static string getMatchFunction(FunctionCode func) { string ret = null; funcMatch.TryGetValue(func, out ret); return(ret); }
public SendFrameFormat(byte id, FunctionCode functionCode, byte[] startingAddress, byte[] dateNumbre) { this.Id = id; this.FunctionCode = functionCode; //0x03 this.StartingAddress = startingAddress; this.Quantity = dateNumbre; }
internal TraceBackFrame(CodeContext context, TotemDictionary globals, object locals, FunctionCode code) { _globals = globals; _locals = locals; _code = code; _context = context; }
private void setupContractStateWithValues(ContractState cs, out FunctionCode code, out bool hasStorage, out string name, out string codeVersion, out string author, out string email, out string description) { code = new FunctionCode(); code.Script = TestUtils.GetByteArray(32, 0x42); code.ParameterList = new[] { new ContractParameterType() }; cs.Code = code; hasStorage = true; cs.HasStorage = hasStorage; name = "nameStr"; cs.Name = name; codeVersion = "codeVersionStr"; cs.CodeVersion = codeVersion; author = "authorStr"; cs.Author = author; email = "emailStr"; cs.Email = email; description = "descriptionStr"; cs.Description = description; }
public void FunctionCode_Set() { FunctionCode val = new FunctionCode(); uut.Code = val; uut.Code.Should().Be(val); }
public void ClassRequest(APDUWrapper request, FunctionCode fc, ClassField classes, byte seq) { request.SetControl(new AppControlField(true, true, false, false, seq)); request.SetFunction(fc); //auto writer = request.GetWriter(); //WriteClassHeaders(writer, classes); }
/// <summary> /// Called in form of event by the Master form when user desires to send data to slave. /// </summary> /// <param name="slaveAddress">Destination address for the data to be delivered to. If equal to 0 - sent to everyone.</param> /// <param name="functionCode">Determines whether user wants to send data to slave or retrieve data from slave. Note that retrieval of data in broadcast is a big no-no.</param> /// <param name="dataToSend">Data to send to slave.</param> public void HandleSendToSlaveEvent(int slaveAddress, FunctionCode functionCode, string dataToSend) { if (functionCode == FunctionCode.RetrieveTextFromSlave && slaveAddress == 0) { MessageBox.Show( "Cannot retrieve data from any slave in broadcast mode. Imagine that avalanche of zeros and ones trying to get through...", "Wrong operation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } var messageFrame = new MessageFrame { TargetSlaveAddress = slaveAddress, FunctionCode = functionCode, Data = dataToSend }; switch (functionCode) { case FunctionCode.SendTextFromMaster: SendRequestToSlave(messageFrame); break; case FunctionCode.RetrieveTextFromSlave: MessageFrame responseFrame = _masterService.SendRequest(messageFrame); masterForm.ShowSlaveData(responseFrame.Data); break; } }
public byte[] Do(byte[] frame) { DataWriter dw = new DataWriter(); DataReader dr = new DataReader(frame); FunctionCode funcCode = dr.GetFuncCode(); byte regAddr = dr.GetByte(); if (regAddr >= _regiestArr.Length) { ResultFunction rf = new ResultFunction(1); return(rf.Do(null)); } if (funcCode == FunctionCode.RegiestReadShort) { dw.Add(funcCode); dw.Add(_regiestArr[regAddr]); return(dw.GetBuffer()); } else if (funcCode == FunctionCode.RegiestWriteShort) { _regiestArr[regAddr] = dr.GetShort(); ResultFunction rf = new ResultFunction(0); return(rf.Do(null)); } else { ResultFunction rf = new ResultFunction(1); return(rf.Do(null)); } }
protected override void OnInit(EventArgs e) { Key = Convert.ToInt32(Request["id"]); H5Div container = new H5Div(); container.CssClass = "container"; container.Attributes.Add("value", FunctionCode.ToString()); Gcontainer = container; Form.Controls.Add(container); RenderTitle(); H5Div work_follow_content = new H5Div(); work_follow_content.CssClass = "work_follow_content"; Gwork_follow_content = work_follow_content; Gcontainer.Controls.Add(work_follow_content); RenderRequestPerson(); RenderReasonBox(); RenderWorkFollow(); RenderFunction(); ComfirmReasonBox(); }
public static void AddFunction(string name, FunctionCode function) { Function.FunctionList.Add(new Function() { Name = name, Code = function }); }
public void AddReadOrder(FunctionCode functionCode, int quantity, int startingAddress, int cycleTime) { ReadOrder readOrder = new ReadOrder(); readOrder.CylceTime = cycleTime; readOrder.FunctionCode = functionCode; readOrder.Quantity = quantity; readOrder.StartingAddress = startingAddress; readOrder.Topic = new string[quantity]; readOrder.oldvalue = new object[quantity]; for (int i = 0; i < quantity; i++) { if (functionCode == FunctionCode.ReadCoils) { readOrder.Topic[i] = mqttRootTopic + "/coils/" + (i + readOrder.StartingAddress).ToString(); } if (functionCode == FunctionCode.ReadDiscreteInputs) { readOrder.Topic[i] = mqttRootTopic + "/discreteinputs/" + (i + readOrder.StartingAddress).ToString(); } if (functionCode == FunctionCode.ReadHoldingRegisters) { readOrder.Topic[i] = mqttRootTopic + "/holdingregisters/" + (i + readOrder.StartingAddress).ToString(); } if (functionCode == FunctionCode.ReadInputRegisters) { readOrder.Topic[i] = mqttRootTopic + "/inputregisters/" + (i + readOrder.StartingAddress).ToString(); } } readOrders.Add(readOrder); }
public static string getAddress(FunctionCode functionCode, int startingAddress, int quantity, int elementCount) { string returnValue = null; if ((startingAddress + elementCount) <= (startingAddress + quantity)) { switch (functionCode) { case FunctionCode.ReadCoils: returnValue = "0x" + (startingAddress + elementCount + 1).ToString(); break; case FunctionCode.ReadDiscreteInputs: returnValue = "1x" + (startingAddress + elementCount + 1).ToString(); break; case FunctionCode.ReadHoldingRegisters: returnValue = "4x" + (startingAddress + elementCount + 1).ToString(); break; case FunctionCode.ReadInputRegisters: returnValue = "3x" + (startingAddress + elementCount + 1).ToString(); break; default: break; } } return(returnValue); }
public InstructionDefinition(string name, InstructionArgumentType[] args, FunctionCode functionCode) { Name = name; Arguments = args; OpCode = OpCode.Register; FunctionCode = functionCode; }
internal TraceBackFrame(TotemTracebackListener traceAdapter, FunctionCode code, TraceBackFrame back, FunctionCode.TotemDebuggingPayload debugProperties, Func<IDictionary<object, object>> scopeCallback) { _traceAdapter = traceAdapter; _code = code; _back = back; _debugProperties = debugProperties; _scopeCallback = scopeCallback; }
/// <summary> /// error rely buffer /// Function:0x80+function /// </summary> /// <param name="func">function code</param> /// <param name="errorCode">error code</param> /// <returns></returns> private byte[] errorRely(FunctionCode func, ErrorCode errorCode) { byte[] data = new byte[3]; data[0] = (byte)_salveId; data[1] = (byte)(0x80 + func); data[2] = (byte)errorCode; return(data); }
//public TraceBackFrame Frame; internal FunctionStack(CodeContext/*!*/ context, FunctionCode/*!*/ code) { Assert.NotNull(context, code); Context = context; Code = code; //Frame = null; }
/// <summary> /// Gets or creates the FunctionCode object for this FunctionDefinition. /// </summary> internal FunctionCode GetOrMakeFunctionCode() { if (_funcCode == null) { _funcCode = new FunctionCode(GlobalParent.PyContext, OriginalDelegate, this, ScopeDocumentation); } return(_funcCode); }
private static void AssertWriteValidFunction(FunctionCode functionCode, byte controlByteValue, byte uppperThreeBit) { var controlByte = new ControlByte(uppperThreeBit); controlByte.FunctionCode = functionCode; Assert.AreEqual(controlByteValue, controlByte.Byte); }
internal TraceBackFrame(PythonTracebackListener traceAdapter, FunctionCode code, TraceBackFrame back, PythonDebuggingPayload debugProperties, Func <IDictionary <object, object> > scopeCallback) { _traceAdapter = traceAdapter; _code = code; _back = back; _debugProperties = debugProperties; _scopeCallback = scopeCallback; }
public void Init(BigEndianShort maxAmqCaller, BigEndianShort maxAmqCallee, BigEndianShort pduSize) { FunctionCode = FunctionCode.CommunicationSetup; Reserved = 0; MaxAmqCaller = maxAmqCaller; MaxAmqCallee = maxAmqCallee; PduSize = pduSize; }
/// <summary> /// Creates an abstract Modbus PDU for the given function code. /// </summary> /// <param name="myModbusDevice">The Modbus device.</param> /// <param name="myFunctionCode">The function code.</param> protected AModbusPDU(IModbusDevice myModbusDevice, FunctionCode myFunctionCode) { ModbusDevice = myModbusDevice; FunctionCode = myFunctionCode; InvocationId = this.ModbusDevice.NextInvocationId; }
private object OptimizedEvalWrapper(FunctionCode funcCode) { try { return(_optimizedTarget(funcCode)); } catch (Exception e) { PythonOps.UpdateStackTrace(e, _optimizedContext, Code, 0); throw; } }
private IModbusFunctionHandler GetFunctionHandler(FunctionCode functionCode) { IModbusFunctionHandler functionHandler; if (_functionhandlers.TryGetValue(functionCode, out functionHandler)) return functionHandler; return null; }
private MessageFrame ReadInputFromForm(FunctionCode functionCode) { string inputText = slaveForm.ReadInputText(); var messageFrame = new MessageFrame { Data = inputText }; return(messageFrame); }
public static bool IsExpectedSize(FunctionCode sentCode, int dataReceived) { if (!ExpectedResponseSize(sentCode).HasValue) { return(true); } return(ExpectedResponseSize(sentCode).Value == dataReceived); }
private FunctionIdentifier(string name, FunctionCode code, ArgumentBuilder arg, int flag) { Code = code; ArgBuilder = arg; this.flag = flag; Method = null; Name = name; Instruction = null; }
private FunctionIdentifier(string name, FunctionCode code, AbstractInstruction instruction, int additionalFlag) { Code = code; ArgBuilder = instruction.ArgBuilder; flag = instruction.Flag | additionalFlag; Method = null; Name = name; Instruction = instruction; }
public static MemoryStream CreateGenericHeader(UInt16 myInvocationId, UInt16 myMessageSize, FunctionCode myFunctionCode) { var _MemoryStream = new MemoryStream(20); _MemoryStream.WriteWord(myInvocationId); // Invocation/Transaction Identifier _MemoryStream.WriteWord(0); // Protocol Identifier (Zero for Modbus/TCP) _MemoryStream.WriteWord(myMessageSize, ByteOrder.HostToNetwork); // Length Field/Message size _MemoryStream.WriteByte(0); // Unit Identifier/Slave address (255 if not used) _MemoryStream.WriteByte(myFunctionCode.Value); // Function code return _MemoryStream; }
private static int _CurrentId = 1; // The current ID for functions which are called in complex ways. public TotemFunction(CodeContext context, FunctionCode funcInfo, object moduleName, object[] defaults, MutableTuple closure) { Assert.NotNull(context, funcInfo); _context = context; _defaults = defaults ?? ArrayUtils.EmptyObjects; _code = funcInfo; _name = funcInfo.Name; Debug.Assert(_defaults.Length <= _code.ArgCount); if (moduleName != Uninitialized.Instance) { _module = moduleName; } Closure = closure; _compat = CalculatedCachedCompat(); }
/// <summary> /// Create modbus header for reading. /// </summary> /// <param name="myInvocationId"></param> /// <param name="myStartAddress"></param> /// <param name="myLength"></param> /// <param name="myFunctionCode"></param> /// <returns></returns> public static MemoryStream CreateReadHeader(UInt16 myInvocationId, UInt16 myStartAddress, UInt16 myLength, FunctionCode myFunctionCode) { var _Header = CreateGenericHeader(myInvocationId, 6, myFunctionCode); // Start address var _adr = BitConverter.GetBytes((Int16) IPAddress.HostToNetworkOrder((Int16) myStartAddress)); _Header.WriteByte(_adr[0]); // high byte _Header.WriteByte(_adr[1]); // low byte // Number of data to read var _length = BitConverter.GetBytes((Int16) IPAddress.HostToNetworkOrder((Int16) myLength)); _Header.WriteByte(_length[0]); // high byte _Header.WriteByte(_length[1]); // low byte return _Header; }
public static byte[] Create(byte slaveId, FunctionCode functionCode, ModbusExceptionCodes exceptionCode) { var buffer = new byte[5]; //Set the slave id buffer[0] = slaveId; //The function code with the highest bit set buffer[1] = (byte)((byte)(functionCode) | (1 << 7)); //Set the exception code buffer[2] = (byte) exceptionCode; //Set the crc buffer.SetCrc(); return buffer; }
protected FunctionServiceBase(FunctionCode functionCode) { _functionCode = functionCode; }
/// <summary> /// Creates a new bvlc message based on a function code /// </summary> /// <param name="function">The function code of the message type to create</param> /// <returns>The newly created message instance</returns> private IBvlcMessage _createMessage(FunctionCode function) { switch(function) { case FunctionCode.Result: return new ResultMessage(); case FunctionCode.RegisterForeignDevice: return new RegisterForeignDeviceMessage(); case FunctionCode.ForwardedNpdu: return new ForwardedNpduMessage(); case FunctionCode.OriginalUnicastNpdu: return new OriginalUnicastNpduMessage(); case FunctionCode.OriginalBroadcastNpdu: return new OriginalBroadcastNpduMessage(); } throw new Exception("Could not create message with function " + function.ToString()); }
private static void addPrintFunction(FunctionCode code) { addFunction(code, new PRINT_Instruction(code.ToString())); }
private FunctionIdentifier(string methodName, FunctionMethod method, AbstractInstruction instruction) { this.code = FunctionCode.__NULL__; this.arg = instruction.ArgBuilder; this.flag = instruction.Flag; this.method = method; Name = methodName; Instruction = instruction; }
/// <summary> /// Initializes a new instance of the ChassisMessageAttribute class. /// </summary> /// <param name="command">OMC message command.</param> /// <param name="dataLength">OMC message data length.</param> protected ChassisMessageAttribute(FunctionCode command, Int32 dataLength) { this._command = command; }
private FunctionIdentifier(string name, FunctionCode code, AbstractInstruction instruction) : this(name, code, instruction, 0) { }
private FunctionIdentifier(string name, FunctionCode code, AbstractInstruction instruction, int additionalFlag) { this.code = code; this.arg = instruction.ArgBuilder; this.flag = instruction.Flag | additionalFlag; this.method = null; Name = name; Instruction = instruction; }
private static void addFunction(FunctionCode code, AbstractInstruction inst, int additionalFlag) { string key = code.ToString(); if (Config.ICFunction) key = key.ToUpper(); funcDic.Add(key, new FunctionIdentifier(key, code, inst, additionalFlag)); }
private static void addFunction(FunctionCode code, AbstractInstruction inst) { addFunction(code, inst, 0); }
internal static FunctionCode getParentFunc(FunctionCode func) { //1755 どうもenum.ToString()が遅いようなので先に逆引き辞書を作ることに FunctionCode ret = FunctionCode.__NULL__; funcParent.TryGetValue(func, out ret); return ret; //if (funcMatch.ContainsValue(func.ToString())) //{ // foreach (FunctionCode pFunc in funcMatch.Keys) // { // if (funcMatch[pFunc] == func.ToString()) // return pFunc; // } //} //return FunctionCode.__NULL__; }
internal static string getMatchFunction(FunctionCode func) { string ret = null; funcMatch.TryGetValue(func, out ret); return ret; }
internal TraceBackFrame(CodeContext/*!*/ context, PythonDictionary globals, object locals, FunctionCode code, TraceBackFrame back) { _globals = globals; _locals = locals; _code = code; _context = context; _back = back; }
/// <summary> /// Initializes a new instance of the ChassisMessageAttribute class. /// </summary> /// <param name="command">OMC message command.</param> protected ChassisMessageAttribute(FunctionCode command) { this._command = command; }
//画像表示 private static void addPictureFunction(FunctionCode code) { addFunction(code, new PICTURE_Instruction(code.ToString())); }
private static void addFunction(FunctionCode code, ArgumentBuilder arg) { addFunction(code, arg, 0); }
private FunctionIdentifier(string name, FunctionCode code, ArgumentBuilder arg, int flag) { this.code = code; this.arg = arg; this.flag = flag; this.method = null; Name = name; Instruction = null; }
protected RegistersFunctionService(FunctionCode functionCode) : base(functionCode) { }
private static void addFunction(FunctionCode code, ArgumentBuilder arg, int flag) { string key = code.ToString(); if (Config.ICFunction) key = key.ToUpper(); funcDic.Add(key, new FunctionIdentifier(key, code, arg, flag)); }
//音楽再生 private static void addMusicFunction(FunctionCode code) { addFunction(code, new MUSIC_Instruction(code.ToString())); }
internal TraceBackFrame(PythonTracebackListener traceAdapter, FunctionCode code, TraceBackFrame back, PythonDebuggingPayload debugProperties, Func<IAttributesCollection> scopeCallback) { _traceAdapter = traceAdapter; _code = code; _back = back; _debugProperties = debugProperties; _scopeCallback = scopeCallback; }