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

SIOC Presentation

Embed Size (px)

Citation preview

Page 1: SIOC Presentation

Introduction to SIOCIntroduction to SIOC

ByByManuel VélezManuel Vélez

(Translation by Manuel Hdez-Peña)(Translation by Manuel Hdez-Peña)

www.opencockpits.comwww.opencockpits.com

Page 2: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Introduction to SIOCIntroduction to SIOC Designed to control not only the Designed to control not only the

electronic hardware, but the electronic hardware, but the simulation too.simulation too.

Balance between power and Balance between power and programming simplicity.programming simplicity.

Simulation linking element (control Simulation linking element (control core). core).

Page 3: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOCSIOC

SIOC structureSIOC structure

IOCPSERVER

IOCP CLIENTEmodule

FSUIPC CLIENTmodule

Link with IOCardsmodule

SIOCLanguageinterface

Page 4: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC <-> IOCPSIOC <-> IOCP SIOC is based in IOCP protocol.SIOC is based in IOCP protocol. It’s needed to know how IOCP works It’s needed to know how IOCP works

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

Page 5: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Flight Simulator Flight Simulator

The Flight SimulatorThe Flight Simulator

Simulation internal variables

Simulationprocess

INPUTS

- Joystick

- Keyboard…

OUTPUTS

- Virtual landscape

- Sound, gauges…

X times per second

Page 6: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Flight SimulatorFlight Simulator

Linking to flight simulatorLinking to flight simulator

Simulation internalvariables

Simulationproccess

INPUTS

- Joystick

- Keyboard…

OUTPUTS

- Virtual landscape

- Sound, gauges…

IOCPServer

IOCPvars

Page 7: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Flight SimulatorFlight Simulator

Linking to flight simulatorLinking to flight simulator

Simulation internalvariables

IOCPServer

IOCPvars

IOCP Client

IOCP Client

IOCP Client

TCP/IP TCP/IP networknetwork

Page 8: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

IOCP Client - 1

How IOCP worksHow 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: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

IOCP vs FSUIPCIOCP vs FSUIPC IOCP is faster because:IOCP is faster because:

The client doesn’t ask for information The client doesn’t ask for information constantly.constantly.

There’s no need of additional software to There’s no need of additional software to connect remotely.connect remotely.

IOCP is more efficient because:IOCP is more efficient because: Only the required information is sent.Only the required information is sent. If information doesn’t change, nothing is sent.If information doesn’t change, nothing is sent.

Page 10: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

System based on eventsSystem based on events SIOC is an SIOC is an IOCP server.IOCP server. SIOC events modify the internal variables SIOC events modify the internal variables

(the ones in the internal IOCP server).(the ones in the internal IOCP server). There are 3 types of events:There are 3 types of events:

Due to a variable change (internal or Due to a variable change (internal or external).external).

Due to a change in the IOCards inputs (digital Due to a change in the IOCards inputs (digital or analogic).or analogic).

Due to a Due to a Timer Timer action.action.

Page 11: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Scripts execution due to eventsScripts execution due to events

Associatedscript

IOCP variableSIOC

SIOC ModuleIocards, IOCP or FSUIPC

A changehappens

Page 12: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Associatedscript

IOCP variableSIOC

SIOC ModuleIocards, IOCP or FSUIPC Change

Events triggered from scripts Events triggered from scripts (1)(1)

Page 13: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Associatedscript

IOCP variableSIOC

Events triggered from scripts Events triggered from scripts (2)(2)

Page 14: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Diagram: SIOC and other elements connection

Page 15: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC – The golden ruleSIOC – The golden rule

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

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

Page 16: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC softwareSIOC software

There are 2 programs and one There are 2 programs and one configuration file:configuration file:

Config_SIOC.exe: to define scripts.Config_SIOC.exe: to define scripts.

SIOC.exe: SIOC core.SIOC.exe: SIOC core.

SIOC.ini: configuration file.SIOC.ini: configuration file.

Page 17: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC.INISIOC.INI

SIOC.INI file configures each SIOC module:SIOC.INI file configures each SIOC module:

IOCPSERVER

FSUIPC CLIENTmodule

IOCards linkingmodule

SIOCLanguageinterface

IOCP CLIENTmodule

Page 18: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC.INISIOC.INI

IOCPSERVER

IOCards linkingmodule

SIOCLanguageinterface

IOCP CLIENTmodule

FSUIPC CLIENTmodule

Page 20: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC.INISIOC.INI

IOCPSERVER

SIOCLanguageinterface

IOCP CLIENTmodule

FSUIPC CLIENTmodule

IOCards linkingmodule

Page 22: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

IOCards linking module

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

Page 23: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC.INISIOC.INI

SIOCLanguageinterface

IOCP CLIENTmodule

FSUIPC CLIENTmodule

IOCards linkingmodule

IOCPSERVER

Page 24: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC scriptsSIOC scriptslanguagelanguage

// *****************************************************************************// * 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: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC scripts languageSIOC scripts language

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

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

types of commands executed in sequence.types of commands executed in sequence.

Page 27: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Defining variables in SIOCDefining variables in SIOC To work with a SIOC module, we have to link To work with a SIOC module, we have to link

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

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

Page 28: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Types of LINKSTypes of LINKS

FSUIPCmodule

IOCP Clientmodule

IOCP Sends and receives IOCP variables data.

IOCardsmodule

IOCARD_SWIOCARD_OUTIOCARD_DISPLAYIOCARD_ENCODER

IOCARD_MOTOR

IOCARD_ANALOGICIOCARD_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 motorsManages a variable as a Subroutine.

FSUIPC_INFSUIPC_OUT

Receives data from FSUIPC offsets.Sends data to FSUIPC offsets.

Module LINK definition Description

Page 29: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Valid ATTRIBUTES in SIOCValid ATTRIBUTES in SIOC

Offset IOCP remote variable number or FSUIPC offsetValueLengthInputOutput

Numbers

DigitAceleration

PosL

Initial value for the variableFSUIPC offset lenghtInitial input in the Master card that variable links toInitial output in the Master card that variable links toFirst figure in the Displays card that defines a numberEncoder acceleration factorNumber of figures (displays) needed by the variableLeft position calibration

TypeLink

Defines special characteristics of the elementDefines type of link for the variable

Attribute Description

PosCPosR

Centre position calibrationRight position calibration

Page 30: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Scripts language main characteristicsScripts language main characteristics Different identifiers, variables, constants and other Different identifiers, variables, constants and other

elements are always separated by elements are always separated by spacesspaces, , commascommas, , bracketsbrackets or or tabulatorstabulators..

{{ and and }} are used to indicate different are used to indicate different levelslevels..

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

Only Only one definition one definition oror command command is allowed in each line.is allowed in each line.

There’s no difference between There’s no difference between uppercaseuppercase and and lowercaselowercase..

Page 31: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Temporary internal variablesTemporary internal variables We can use different types of temporary internal We can use different types of temporary internal

variables that variables that onlyonly are valid for the are valid for the scriptscript associated to a SIOC variable.associated to a SIOC variable.

There are two types:There are two types:

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

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

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

Page 32: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC variables definition using scripts SIOC variables definition using scripts languagelanguage

VarVarNumber 0-9999Number 0-9999AttributeAttributeparameterparameter AttributeAttributeparameterparameter ……

Examples :Examples :

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

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

Var 0006, Link IOCARD_DISPLAY, Digit 0, Numbers 5Var 0006, Link IOCARD_DISPLAY, Digit 0, Numbers 5Var 9023Var 9023

Page 33: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Linking a SIOC variable to different Linking a SIOC variable to different modulesmodules

Var 0001Var 0001

Defines SIOC variable 0001, ready to be usedDefines SIOC variable 0001, ready to be used

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

Here we define an initial value and insert a particular commentHere we define an initial value and insert a particular commentVar 1387, Link FSUIPC_OUT, Offset $0BDE, Length 2 Var 1387, Link FSUIPC_OUT, Offset $0BDE, Length 2

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

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

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

Page 34: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Linking a SIOC variable to different Linking a SIOC variable to different modulesmodules

Var 0009 , Link IOCARD_SW, Input 25, Type PVar 0009 , Link IOCARD_SW, Input 25, Type PLinks variable 0009 with a switch connected to IOCards. If input (switch)Links 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 willChanges to OFF the value will be 0, and if input changes to ON value willbe 1.be 1.Var 0006 , Link IOCARD_OUT, Output 54 // Led del F/DVar 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 1, output 54 in IOCards will be enabledIf variable 0006 changes to 0, output 54 in IOCards will be disabledIf variable 0006 changes to 0, output 54 in IOCards will be disabled

Var 1387, Link IOCARD_DISPLAY, Digit 0, Numbers 3Var 1387, Link IOCARD_DISPLAY, Digit 0, Numbers 3

The value in the variable will be shown on 3 displays starting at #0.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.If we are using negative values, we have to use one addtional display.

Var 9341, Link IOCARD_ENCODER, Input 3, Aceleration 1, Type 1Var 9341, Link IOCARD_ENCODER, Input 3, Aceleration 1, Type 1Each encoder click will send a value between 1 and 1+acceleration toEach encoder click will send a value between 1 and 1+acceleration tothe variable. The encoder is connected to input 3 and the type is definedthe variable. The encoder is connected to input 3 and the type is definedVariable value will be 0 if encoder doesn’t turn.Variable value will be 0 if encoder doesn’t turn.

Page 35: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Linking a SIOC variable to different Linking a SIOC variable to different modulesmodules

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

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

Var 1209 , Link IOCARD_SERVO, Output 7, PosL 1, PosC 127, PosR 255 Var 1209 , Link IOCARD_SERVO, Output 7, PosL 1, PosC 127, PosR 255 Servo in output 7 receives the value from variable 1209, previouslyServo in output 7 receives the value from variable 1209, previouslyadjusted with the calibrating parameters. We can define the 10 bitsadjusted with the calibrating parameters. We can define the 10 bitsresolution controlresolution control

Var 1387, Link IOCARD_MOTOR, Output 187, Aceleration 14, Type DVar 1387, Link IOCARD_MOTOR, Output 187, Aceleration 14, Type D Depending on the variable value (> or <127), the motor connected toDepending on the variable value (> or <127), the motor connected tooutput 187 will turn one way or the other, with an acceleration coefficientoutput 187 will turn one way or the other, with an acceleration coefficientof 14of 14Var 9999, Link SUBRUTINEVar 9999, Link SUBRUTINEVariable 9999 will be a SUBROUTINE, so the associated script will beVariable 9999 will be a SUBROUTINE, so the associated script will beautomatically run with the CALL command.automatically run with the CALL command.

Page 36: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Defining a script associated to a SIOC Defining a script associated to a SIOC variablevariable

VarVarNumber 0-9999Number 0-9999AttributeAttributeparameterparameter AttributeAttributeparameterparameter ……

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

{{

}}

CommandCommandparametersparametersCommandCommandparametersparameters..

..

..

Page 37: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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 executionAssociated scripts execution

SIOC scripts managerSIOC scripts manager SIOC IOCP serverSIOC IOCP server

Page 38: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Allowed COMMANDS in SIOCAllowed COMMANDS in SIOC

Function Different functions used with different SIOC variables CALL

IF conditionELSE condition

Lets run a script associated to a SUBROUTINE type variable, even send it a parameter.Run related commans only if the condition is truePart of an IF condition, lets run commands when the IFcondition is false.

Assignmentto the different SIOC variables.With this command we can assign values or calculation

Command Description

Page 39: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Allowed OPERATORS in SIOCAllowed OPERATORS in SIOC

* Multiplies two variables or constants/

ANDOR>

>=

<=

<=

Divides two variables or constantsLogic operation, or AND conditionLogic 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 constantsAdds two variables or constants

Operator Description

<> “Different” condition

+

Page 40: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

ASSIGNMENT commandASSIGNMENT command

==VariableVariableConstantConstant

OperatorOperator

VariableVariable

ConstantConstant

VariableVariable==VariableVariable

ConstantConstant

VariableVariable

Examples:Examples:

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

Page 41: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

FUNCTIONS allowed in SIOCFUNCTIONS allowed in SIOC

Timer Programs periodic events using a chronoSetBitClearBitTestBitNot

FromBCD

RotateToBCD

Toggle

Sets specific bit in a variableClears specific bit in a variableChecks if a specific bit is setInverts the value of a boolean variable (C0, C1 or C2)Does cyclical increases/decreasesConverts to BCD a decimal valueConverts to decimal a BCD valueMakes a toggle function with a specific bit in a variable

TruncRound

Takes only the integer part from a variableRounds the value to the closest integer

Funtion Description

Abs Changes to absolute value the value of a variable

Page 42: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

FUNCTIONS definitionsFUNCTIONS definitions

==VariableVariable

Examples :Examples :

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

FunctionFunctionparameter1parameter1parameter2parameter2parameter3parameter3

parameterparameter can be a variable or a constant. can be a variable or a constant.

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

Page 43: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC functionsSIOC functionsVariable = RoundRound parameter1

Rounds the value to the closest integer..Parameter1Parameter1: Variable, real or integer constant.: Variable, real or integer constant.

Variable = TruncTrunc parameter1Takes only the integer part from a variable (converts the decimal (converts the decimal value to integer).value to integer).

Parameter1 Parameter1 : Variable, real or integer constant.: Variable, real or integer constant.Variable = SetBitSetBit parameter1

Sets to 1 the variable bit indicated in parameter.Parameter1 Parameter1 : Variable, real or integer constant.: Variable, real or integer constant.

Page 44: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC functionsSIOC functionsVariable = ClearBitClearBit parameter1

Sets to 0 the variable bit indicated in parameter.Sets to 0 the variable bit indicated in parameter.Parameter1 Parameter1 : Variable, real or integer constant.: Variable, real or integer constant.

Variable = ToggleToggle parameter1Makes a toggle (set to 1 then back to 0) the variable Makes a toggle (set to 1 then back to 0) the variable bit indicated in the parameterbit indicated in the parameter

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

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

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

Page 45: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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

Variable = FromBCDFromBCD parameter1Converts the value in parameter1 from BCD to decimal and Converts the value in parameter1 from BCD to decimal and assigns it to the variable.assigns it to the variable.

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

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

SIOC functionsSIOC functions

Page 46: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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

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

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

SIOC functionsSIOC functions

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

Page 47: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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

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

SIOC functionsSIOC functions

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

Page 48: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

{{ scriptscript

}}

V000V00033

V0003 = Timer 3,1,10V0003 = Timer 3,1,10

TIMER functionTIMER function

{{ scriptscript

}}

V000V00033

{{ scriptscript

}}

V000V00033

V0003=1V0003=1 V0003=2V0003=2 V0003=3V0003=3V0003=0V0003=0

1 sec1 sec 1 sec1 sec 1 sec1 sec

Page 49: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

CALL commandCALL command

CALLCALLConstantConstant

VariableVariable

Example:Example:

{{ CALL V9888 CALL V9888 CALL V1001 326CALL V1001 326 CALL V3004 L0CALL V3004 L0}}

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

Anyway, the script is Anyway, the script is alwaysalways executed. executed.

Variable Variable (subroutine)(subroutine)

Page 50: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Commands: IF and ELSE conditionsCommands: IF and ELSE conditionsIFIF

If If conditioncondition is true, the commands between the is true, the commands between the IFIF brackets will be executed. If brackets will be executed. If conditioncondition is false, then the is false, then the commands between the commands between the ELSEELSE brackets will be brackets will be executed.executed.

The The ELSEELSE part is an option and must be always placed part is an option and must be always placed after the after the IFIF part. part.

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

ConditionCondition{ commands}ELSEELSE{ commands}

Page 51: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Commands: IF and ELSE conditionsCommands: IF and ELSE conditions

Examples :Examples :{{ IF L1 > 5IF L1 > 5 {{ CALL V1000CALL V1000 }} ELSEELSE {{ IF C2IF C2 {{ L1 = L1 + 1 L1 = L1 + 1 }} }}}}

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

Page 52: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Example-1Example-1 How to use a switch, turn on a light and How to use a switch, turn on a light and

send tha information to the simulator:send tha information to the simulator:Var 0001, Link FSUIPC_OUT, Offset $0D0C, Length 2 // LightsVar 0001, Link FSUIPC_OUT, Offset $0D0C, Length 2 // Lights

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

Var 0003, Link IOCARD_OUT, Output 38 // LedVar 0003, Link IOCARD_OUT, Output 38 // Led

Page 53: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Example-2Example-2 Using an encoder.Using an encoder.

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

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

Page 54: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Example-3Example-3 Using analog inputs.Using analog inputs.

// Ailerons axle// Ailerons axle

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

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

Page 55: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Considerations about Considerations about programming withprogramming with

SIOCSIOC

Page 56: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Write commentsWrite comments// **************************************************************************// **************************************************************************// This program moves the ailerons using an analog input in USB card *// 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 axleVar 0001, Link IOCARD_ANALOGIC, Input #1, PosL 0, PosC 128, PosR 255 // Ailerons axle{{ L0 = V0001 * 129 // L0 = V0001 * 129 // Potentiometer movement calculationPotentiometer movement calculation V0002 = L0 - 16512V0002 = L0 - 16512}}

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

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

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

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

Page 57: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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

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

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

Initializing variablesInitializing variables

Page 58: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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

(independently from the number of variable). If we (independently from the number of variable). If we define a variable with an attribute define a variable with an attribute VALUE 0VALUE 0, we will , we will be sure its script will be executed. In this script we be sure its script will be executed. In this script we will set the will set the assignmentsassignments and and callscalls to initializate the to initializate the rest of the program.rest of the program.

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

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

Page 59: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

Using the TIMER functionUsing the TIMER function

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

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

Page 60: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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

Page 61: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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

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

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

Page 62: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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

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

Working with displaysWorking with displays

Page 63: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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

Infinite loopsInfinite loops

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

Var 0002Var 0002{{ V0001 = V0002 V0001 = V0002 }}

Page 64: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

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

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

Concurrent processesConcurrent processes

Page 65: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

The SIOC system can be The SIOC system can be highly powerful.highly powerful.

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

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

Power of SIOCPower of SIOC

Page 66: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

SIOC system networkSIOC system networkSIOC-SIOC-

11

SIOC-SIOC-22

SIOC-SIOC-33

SIOC-SIOC-44

SIOC-SIOC-66

SIOC-SIOC-55

. . .. . .

SIOC netSIOC net

Page 67: SIOC Presentation

23/10/200423/10/2004 Introduction to SIOCIntroduction to SIOC

The endThe end

http://www.opencockpits.comhttp://www.opencockpits.com