public PineCog(PineDevice device, CogBytecode bytecode, int period) : base(device) { this.code = bytecode; _scriptName = "userscript"; Init(device, period, code); }
private void Init(PineDevice device, int period, CogBytecode code) { if (period <= 0) { period = 1; } _period = period; _output = 0; _registers = new double[20]; _timers = new CogTimer[NumTimers]; msCode = new MemoryStream(code.CompiledCode); codeReader = new BinaryReader(msCode); }
/// <summary> /// Reassigns the associated bytecode. Use for dev purposes only. /// </summary> /// <param name="bytecode">The new bytecode to assign to the cog.</param> public void Reassign(CogBytecode bytecode) { codeReader.Dispose(); msCode.Dispose(); code = bytecode; msCode = new MemoryStream(code.CompiledCode); codeReader = new BinaryReader(msCode); }