introduction to sioc by manuel vélez (translation by manuel hdez-peña)

67
Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña) www.opencockpits.co m

Upload: yasir-gallagher

Post on 30-Dec-2015

31 views

Category:

Documents


1 download

DESCRIPTION

Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña). www.opencockpits.com. Introduction to SIOC. Designed to control not only the electronic hardware, but the simulation too. Balance between power and programming simplicity. Simulation linking element (control core). - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC

ByManuel Vélez

(Translation by Manuel Hdez-Peña)

www.opencockpits.com

Page 2: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Introduction to SIOC

Designed to control not only the electronic hardware, but the simulation too.

Balance between power and programming simplicity.

Simulation linking element (control core).

Page 3: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC

SIOC structure

IOCPSERVER

IOCP CLIENTEmodule

FSUIPC CLIENTmodule

Link with IOCardsmodule

SIOCLanguageinterface

Page 4: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC <-> IOCP

SIOC is based in IOCP protocol. It’s needed to know how IOCP works

to understand SIOC. SIOC is an IOCP server itself. SIOC is based in EVENTS.

Page 5: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Flight Simulator

The Flight Simulator

Simulation internal variables

Simulationprocess

INPUTS

- Joystick

- Keyboard…

OUTPUTS

- Virtual landscape

- Sound, gauges…

X times per second

Page 6: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Flight Simulator

Linking to flight simulator

Simulation internalvariables

Simulationproccess

INPUTS

- Joystick

- Keyboard…

OUTPUTS

- Virtual landscape

- Sound, gauges…

IOCPServer

IOCPvars

Page 7: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Flight Simulator

Linking to flight simulator

Simulation internalvariables

IOCPServer

IOCPvars

IOCP Client

IOCP Client

IOCP Client

TCP/IP network

Page 8: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

IOCP Client - 1

How IOCP works

IOCPServer

IOCPvars

#0000 = 1#0001 = 0#0002 = 23#0003 = 8#0004 = 0

#9999 = 1

I want to knowabout #2 y #4

Client-1

Var #0002Var #0004

#2=23, #4=0

#0002 = 11

#2=11

#0000 = 9 TCP/IP

connection

Client-1

Var #0002Var #0004

Page 9: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

IOCP vs FSUIPC

IOCP is faster because: The client doesn’t ask for information

constantly. There’s no need of additional software to

connect remotely. IOCP is more efficient because:

Only the required information is sent. If information doesn’t change, nothing is

sent.

Page 10: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

System based on events

SIOC is an IOCP server. SIOC events modify the internal

variables (the ones in the internal IOCP server).

There are 3 types of events: Due to a variable change (internal or

external). Due to a change in the IOCards inputs

(digital or analogic). Due to a Timer action.

Page 11: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Scripts execution due to events

Associatedscript

IOCP variableSIOC

SIOC ModuleIocards, IOCP or FSUIPC

A changehappens

Page 12: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Associatedscript

IOCP variableSIOC

SIOC ModuleIocards, IOCP or FSUIPC

Change

Events triggered from scripts (1)

Page 13: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Associatedscript

IOCP variableSIOC

Events triggered from scripts (2)

Page 14: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Diagram: SIOC and other elements connection

Page 15: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC – The golden rule

SIOC only run a script associated to a variable IF THIS VARIABLE CHANGES ITS VALUE.

The only exception is in the case of special variables named SUBROUTINES, that run the associated script EVERY TIME they take part in an assignment or when the CALL command is executed.

Page 16: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC software

There are 2 programs and one configuration file:

Config_SIOC.exe: to define scripts.

SIOC.exe: SIOC core.

SIOC.ini: configuration file.

Page 17: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC.INI

SIOC.INI file configures each SIOC module:

IOCPSERVER

FSUIPC CLIENTmodule

IOCards linkingmodule

SIOCLanguageinterface

IOCP CLIENTmodule

Page 18: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

IOCP CLIENT module

[ Desactivar el módulo cliente IOCP ][ Disable IOCP client module ] IOCPclient_disable=yes

[ IP del servidor donde debe de conectar el cliente ][ IOCP client host name ]IOCPclient_host=localhost

[ Puerto de envio del protocolo IOCP cliente ][ IOCP client port ]IOCPclient_port=8090

Page 19: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC.INI

IOCPSERVER

IOCards linkingmodule

SIOCLanguageinterface

IOCP CLIENTmodule

FSUIPC CLIENTmodule

Page 20: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

FSUIPC CLIENT module

[ Desabilitar lectura de las FSUIPC ][ FSUIPC disable mode yes/no ]FSUipcdisable=No

[ Refresco recepción FSUIPC ][ FSUIPC refresh ]FSUipcRefresh=100

Page 21: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC.INI

IOCPSERVER

SIOCLanguageinterface

IOCP CLIENTmodule

FSUIPC CLIENTmodule

IOCards linkingmodule

Page 22: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

IOCards linking module

USB=noMUSB=NodeviceUSB=2048USB_AD=0Port=$0378FullCompatible=NoNCards=1Expansion=Nosimulator=NoMasterRefresh=10

Page 23: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC.INI

SIOCLanguageinterface

IOCP CLIENTmodule

FSUIPC CLIENTmodule

IOCards linkingmodule

IOCPSERVER

Page 24: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

IOCP server

[ Puerto del servidor IOCP ][ IOCP port ]IOCP_port=8092

[ Tiempo de respuesta máximo de los paquetes IOCP ][ IOCP Timeout ]IOCP_timeout=4000

Page 25: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC scriptslanguage

// *****************************************************************************// * Config_SIOC ver 1.8 Beta - By Manolo Vélez - www.opencockpits.com// *****************************************************************************// * FileName : sioc.txt// * Date : 21/10/2004

Var 0001, Link FSUIPC_IN, Offset $07F2, Length 2{ C0 = TESTBIT V0001 ,15 IF C0 { L0 = 65536 - V0001 V0002 = L0 * -1 } ELSE { V0002 = V0001 }}

Var 0002 // Real value for V/S

Page 26: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC scripts language

1. Variables definition language.Each SIOC variable and its attributes are defined depending on its LINK.

2. Commands execution language.Functions, assignments, conditions and other

types of commands executed in sequence.

Page 27: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Defining variables in SIOC

To work with a SIOC module, we have to link our SIOC variable with the module we want to work with, defining the attributes of the module and which particular element in the module we want to control.

By this link, when our SIOC variable takes a value, an output will be generated via the defined module, and the variable value will change following the calculations made in the module.

Page 28: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Types of LINKS

FSUIPCmodule

IOCP Clientmodule

IOCP Sends and receives IOCP variables data.

IOCardsmodule

IOCARD_SW

IOCARD_OUT

IOCARD_DISPLAY

IOCARD_ENCODER

IOCARD_MOTOR

IOCARD_ANALOGIC

IOCARD_SERVO

SIOC SUBRUTINE

Works with IOCards switches (inputs).

Turns on/off IOCards outputs.

Sends data to IOCards displays.

Receives data from IOCards encoders.

Receives data from IOCards analog inputs.

Moves IOCards servomotors.

Moves IOCards DC and stepper motors

Manages a variable as a Subroutine.

FSUIPC_IN

FSUIPC_OUT

Receives data from FSUIPC offsets.

Sends data to FSUIPC offsets.

Module LINK definition Description

Page 29: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Valid ATTRIBUTES in SIOC

Offset IOCP remote variable number or FSUIPC offset

Value

Length

Input

Output

Numbers

Digit

Aceleration

PosL

Initial value for the variable

FSUIPC offset lenght

Initial input in the Master card that variable links to

Initial output in the Master card that variable links to

First figure in the Displays card that defines a number

Encoder acceleration factor

Number of figures (displays) needed by the variable

Left position calibration

Type

Link

Defines special characteristics of the element

Defines type of link for the variable

Attribute Description

PosC

PosR

Centre position calibration

Right position calibration

Page 30: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Scripts language main characteristics

Different identifiers, variables, constants and other elements are always separated by spaces, commas, brackets or tabulators.

{ and } are used to indicate different levels.

// can be used to insert general comments at the beguining of a line or at the end of a command line as a particular comment.

Only one definition or command is allowed in each line.

There’s no difference between uppercase and lowercase.

Page 31: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Temporary internal variables We can use different types of temporary internal

variables that only are valid for the script associated to a SIOC variable.

There are two types:

Real, named L0, L1 y L2. They can store decimal, integer, positive and negative values in the range 5 x 10^-324 a 1.7 x 10^308.

Boolean, named C0, C1 y C2. They can store the value of a condition (true or false).

We can make reference to a SIOC variable in our scripts by naming it V + number of the SIOC variable, for example V0001.

Page 32: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC variables definition using scripts language

VarNumber 0-9999AttributeparameterAttributeparameter …

Examples :

Var 0001, Link FSUIPC_IN, Offset $07F2, Length 2

Var 0001, Link IOCARD_ENCODER, Input 0, Acceleration 8, Type 1 // Encoder dec.

Var 0006, Link IOCARD_DISPLAY, Digit 0, Numbers 5

Var 9023

Page 33: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Linking a SIOC variable to different modules

Var 0001

Defines SIOC variable 0001, ready to be used

Var 0006 , Value 360 // We will store heading here

Here we define an initial value and insert a particular comment

Var 1387, Link FSUIPC_OUT, Offset $0BDE, Length 2

Here we link with FSUIPC module (offset $0BDE, length 2).If variable 1387 changes, the value will be sent to FSUIPC

Var 9341, Link FSUIPC_IN, Offset $0C32, Length 4

Variable 9341 will receive the value in offset $0C32 when it changes andthe associated script will be launched then.

Page 34: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Linking a SIOC variable to different modules

Var 0009 , Link IOCARD_SW, Input 25, Type PLinks variable 0009 with a switch connected to IOCards. If input (switch)Changes to OFF the value will be 0, and if input changes to ON value willbe 1.

Var 0006 , Link IOCARD_OUT, Output 54 // Led del F/D

If variable 0006 changes to 1, output 54 in IOCards will be enabledIf variable 0006 changes to 0, output 54 in IOCards will be disabled

Var 1387, Link IOCARD_DISPLAY, Digit 0, Numbers 3

The value in the variable will be shown on 3 displays starting at #0.If we are using negative values, we have to use one addtional display.

Var 9341, Link IOCARD_ENCODER, Input 3, Aceleration 1, Type 1

Each encoder click will send a value between 1 and 1+acceleration tothe variable. The encoder is connected to input 3 and the type is definedVariable value will be 0 if encoder doesn’t turn.

Page 35: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Linking a SIOC variable to different modules

Var 0009 , Link IOCARD_ANALOGIC, Input #2, PosL 1, PosC 127, PosR 255

Variable receives the value from analog input #2, calibrated with values1, 127 and 255 (left, center and right).

Var 1209 , Link IOCARD_SERVO, Output 7, PosL 1, PosC 127, PosR 255

Servo in output 7 receives the value from variable 1209, previouslyadjusted with the calibrating parameters. We can define the 10 bitsresolution control

Var 1387, Link IOCARD_MOTOR, Output 187, Aceleration 14, Type D Depending on the variable value (> or <127), the motor connected tooutput 187 will turn one way or the other, with an acceleration coefficientof 14

Var 9999, Link SUBRUTINE

Variable 9999 will be a SUBROUTINE, so the associated script will beautomatically run with the CALL command.

Page 36: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Defining a script associated to a SIOC variable

VarNumber 0-9999AttributeparameterAttributeparameter …

Example :Var 0001, Link FSUIPC_IN, Offset $07F2, Length 2{ V0002 = V0001 + 1 CALL = V9999 L1 = V0001 * 1.35 L1 = ROUND L1}

{

}

Commandparameters

Commandparameters...

Page 37: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

VAR value has been changed

Client have this VAR in your list ?

RUN VAR script

Send new value of VAR

to clients

END

EVENT

Launch others events

YESNO

Associated scripts execution

SIOC scripts manager SIOC IOCP server

Page 38: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Allowed COMMANDS in SIOC

Function Different functions used with different SIOC variables

CALL

IF condition

ELSE condition

Lets run a script associated to a SUBROUTINE type

variable, even send it a parameter.

Run related commans only if the condition is true

Part of an IF condition, lets run commands when the IF

condition is false.

Assignment

to the different SIOC variables.

With this command we can assign values or calculation

Command Description

Page 39: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Allowed OPERATORS in SIOC

* Multiplies two variables or constants

/

AND

OR

>

>=

<

=

<=

Divides two variables or constants

Logic operation, or AND condition

Logic operation, or OR condition

“Higher than” condition

“Lower than” condition

“Same as” condition

“Higher or same as” condition

“Lower or same as” condition

- Subtracts two variables or constants

Adds two variables or constants

Operator Description

<> “Different” condition

+

Page 40: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

ASSIGNMENT command

=VariableConstant

Operator

Variable

Constant

Variable=Variable

Constant

Variable

Examples:

{ V0002 = V0008 * 3.14 L2 = 3.8673 L1 = V0001 AND 128 C1 = L1 < 5}

Page 41: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

FUNCTIONS allowed in SIOC

Timer Programs periodic events using a chrono

SetBit

ClearBit

TestBit

Not

FromBCD

Rotate

ToBCD

Toggle

Sets specific bit in a variable

Clears specific bit in a variable

Checks if a specific bit is set

Inverts the value of a boolean variable (C0, C1 or C2)

Does cyclical increases/decreases

Converts to BCD a decimal value

Converts to decimal a BCD value

Makes a toggle function with a specific bit in a variable

Trunc

Round

Takes only the integer part from a variable

Rounds the value to the closest integer

Funtion Description

Abs Changes to absolute value the value of a variable

Page 42: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

FUNCTIONS definitions

=Variable

Examples :

{ V0002 = Round L0 L2 = ToBCD V0005 C1 = TestBit V1234 5 V9888 = Timer 100 5 10}

Functionparameter1parameter2parameter3

parameter can be a variable or a constant.

Each function can only have 1, 2 or 3 parameters. The final value isassigned to the variable.

Page 43: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC functions

Variable = Round parameter1

Rounds the value to the closest integer.

Parameter1: Variable, real or integer constant.

Variable = Trunc parameter1

Takes only the integer part from a variable (converts the decimal value to integer).

Parameter1 : Variable, real or integer constant.

Variable = SetBit parameter1

Sets to 1 the variable bit indicated in parameter.

Parameter1 : Variable, real or integer constant.

Page 44: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC functions

Variable = ClearBit parameter1

Sets to 0 the variable bit indicated in parameter.

Parameter1 : Variable, real or integer constant.

Variable = Toggle parameter1

Makes a toggle (set to 1 then back to 0) the variable bit indicated in the parameter

Parameter1 : Variable, real or integer constant.

Variable = ToBCD parameter1

Converts the value in parameter1 to BCD format and sends it to variable (this format is very used in FSimulator).

Parameter1 : Variable, real or integer constant.

Page 45: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Variable = Abs parameter1

Assigns to variable the absolute value (positive) defined in parameter.Parameter1 : Variable, real or integer constant.

Variable = FromBCD parameter1

Converts the value in parameter1 from BCD to decimal and assigns it to the variable.

Parameter1 : Variable, real or integer constant.

Variable = TestBit parameter1

Assigns to the boolean variable a true or false value if the bit value in parameter is 1 or not.Parameter1 : Variable, real or integer constant.

SIOC functions

Page 46: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Variable = Not parameter1

Assigns to the boolean variable the opposite value defined in parameter1.Parámetro1 : Boolean variable.

Variable = Rotate parameter1 parameter2 parameter3Increases or decreases the variable value in the quantity defined in parameter3. If the variable gets higher than parameter2, then it changes to the value in parameter1; and the opposite too. Is the typical heading case: parameter1 would be 0 and parameter2 359.

Parameter1 : Variable, real or integer constant. Lower value.

SIOC functions

Parameter2 : Variable, real or integer constant. Higher value.Parameter3 : Variable, real or integer constant. Increment/Decrement

Page 47: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Variable = Timer parameter1 parameter2 parameter3Starts the variable associated script periodically as set in parameter3 (1/10 sec).In each loop, the variable value is increased in parameter2, ending with the value reaches the value in parameter 1.

Parameter1 : Variable, real or integer constant. Final value.Parameter2 : Variable, real or integer constant. Increase/Decrease.

SIOC functions

Parameter3 : Variable, real or integer constant. Time (1/10 sec).

Page 49: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

CALL command

CALL

Constant

Variable

Example:

{ CALL V9888 CALL V1001 326 CALL V3004 L0}

Executes the variable associated script; optionally, if a parameter is included, the variable will take its value.

Anyway, the script is always executed.

Variable (subroutine)

Page 50: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Commands: IF and ELSE conditions

IF

If condition is true, the commands between the IF brackets will be executed. If condition is false, then the commands between the ELSE brackets will be executed.

The ELSE part is an option and must be always placed after the IF part.

It is posible to nest up to 100 levels of these type of conditions.

Condition{ commands}ELSE{ commands}

Page 51: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Commands: IF and ELSE conditions

Examples :

{ IF L1 > 5 { CALL V1000 } ELSE { IF C2 { L1 = L1 + 1 } }}

The condition can be: a boolean variable, two booleans variables linked with AND / OR, or conditions with variables and/or constant linked with the corresponding operators.

Page 52: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Example-1

How to use a switch, turn on a light and send tha information to the simulator:

Var 0001, Link FSUIPC_OUT, Offset $0D0C, Length 2 // Lights

Var 0002, Link IOCARD_SW, Input 154 // Light switch{ IF V0002 = 1 // If the switch is on { V0001 = SETBIT 2 // Set Bit 2 V0003 = 1 // Turn on the LED } ELSE // If the switch is off { V0001 = CLEARBIT 2 V0003 = 0 // Turn off the led }}

Var 0003, Link IOCARD_OUT, Output 38 // Led

Page 53: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Example-2 Using an encoder.

// Definition of an encoder (type 2, direct to Master card)Var 0001, Link IOCARD_ENCODER, Input 3, Aceleration 6, Type 2 { V0002 = ROTATE 1 ,360 ,V0001 // Increase/decrease in variable V0002}

// COURSE offset for autopilotVar 0002, Link FSUIPC_OUT, Offset $0C4E, Length 2, Value 1, Value 1

Page 54: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Example-3 Using analog inputs.

// Ailerons axle

Var 0001, Link IOCARD_ANALOGIC, Input #1, PosL 0, PosC 128, PosR 255 // Input #1 means analog connector #1 in USB card. Without “#” would mean //digital input{ L0 = V0001 * 129 // Potentiometer movement calculation V0002 = L0 - 16512}

// Simulator ailerons (offset from -16383 to 16383)Var 0002, Link FSUIPC_OUT, Offset $0BB6, Length 2

Page 55: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Considerations about programming with

SIOC

Page 56: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Write comments// **************************************************************************// This program moves the ailerons using an analog input in USB card *// **************************************************************************

Var 0001, Link IOCARD_ANALOGIC, Input #1, PosL 0, PosC 128, PosR 255 // Ailerons axle{ L0 = V0001 * 129 // Potentiometer movement calculation V0002 = L0 - 16512}

Var 0002, Link FSUIPC_OUT, Offset $0BB6, Length 2 // Simulator ailerons (-16383 to 16383)

It’s very interesting to insert comments along the program to make it understandable later.

• In the example, general comments are started with //.

• Particular comments also use //, but in this case at the end of the command line.

Page 57: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC variables always are started with a NULL value, so the first value they get always causes an EVENT.

The attribute VALUE let us to initialize a SIOC variable. The initialization is made in the same order they are written in the program and always causes an EVENT.

Any started script can start many others by using the assignment commands, functions and the CALL command. With the initializations, the programmer can easily loose the script control, so we recommend to use the initializing variable technique for complex programs.

Initializing variables

Page 58: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

The initializing variable technique The first variable to be initialized is the first

defined (independently from the number of variable). If we define a variable with an attribute VALUE 0, we will be sure its script will be executed. In this script we will set the assignments and calls to initializate the rest of the program.Var 0000, Value 0 // Inicialization

{ V0007 = 1 // Set 1 V0002 = 8 // Initializes the 2 higher figures V0003 = 0 // and the 2 lower ones V0008 = 0 // Set to 0 the mode selector V9999 = 0 // 0=On 1=Off V0012 = TOBCD 1300 // Initializes freq NAV1 to 113.00 V9999 = TIMER 999 ,0 ,15 // Starts timer for blinking}

Var 0002 // StdBy Freq two higher figures{ CALL V1100 // Sends value to simulator}

Page 59: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Using the TIMER function

TIMER function is a powerful tool that let us to make sincronous loops, very important in the simulations design.

Examples like starting an APU, retarding a valve opening are easily solved using TIMER function.

Page 60: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Var 0000, Value 0 // Initializing values{ V0002 = 0 // Output disabled V0003 = 1}Var 0001, Link IOCARD_SW, Input 10 // Example switch{ C0 = V0001 = 1 // If switch is on C1 = V0002 = 0 // If output is disabled, no repeat IF C0 AND C1 // If I turn on the switch { V0002 = 1 // Output is enabled V0003 = TIMER 0 ,-1 ,30 // 3 sec countdown }}Var 0002, Link IOCARD_OUT, Output 10 // Example ledVar 0003 // Variable for counter{ IF V0003 = 0 // If countdown has finished { V0003 = 1 // Prepare next countdown V0002 = 0 // Turn off the led }}

Page 61: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

Var 0012, Value 0 // Read IAS{ V0007 = V0003 V0100 = TIMER 99999 ,0 ,50 // Start timer V0101 = TIMER 99999 ,0 ,5}

Here we start two timers. As the variable doesn’t change, timers will never reach 99999, so they are infinite timers.

Another technique is to assign a value to the own timer variable from inside the timer. This will not start an event if the variable is a Subroutine type. This way when the variable reaches the final timer value, it will stop

Page 62: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

When using displays card II, we can show special characters. It’s necessary to load special values in the variable as follows:

-999999 = Display off -999998 = Display shows "-" -999997 = Display shows "6" -999996 = Display shows "t" -999995 = Display shows "d" -999994 = Display shows "_"

Working with displays

Page 63: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

There is a possibility that our program starts an infinite loop, so we must be cautions with the assignments we do.

Infinite loops

Var 0001, Value 1{ V0002 = V0001 * -1}

Var 0002{ V0001 = V0002 }

Page 64: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

We must be cautious when programming complex scripts because SIOC work with concurrent processes.

Concurrent processes are two processes working in parallel (due to TIMERS), so if we are working with the same variable in two different processes we can obtain unexpected results.

Concurrent processes

Page 65: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

The SIOC system can be highly powerful.

The system is managed as a virtual neuronal network, changing the general state depending on external or internal changes.

The capacity of communication using SIOC enables the parallel proccessing so we can connect several computers in cascade.

Power of SIOC

Page 66: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

SIOC system network

SIOC-1

SIOC-2

SIOC-3

SIOC-4

SIOC-6

SIOC-5

. . .

SIOC net

Page 67: Introduction to SIOC By Manuel Vélez (Translation by Manuel Hdez-Peña)

Introduction to SIOC23/10/2004

The end

http://www.opencockpits.com