Project

General

Profile

Bug #182 » my_timeissue_normal.py

Veronique bouzid, 27/02/2015 12:51 PM

 
1
# -*- coding: utf-8 *-*
2

    
3
################################################################################
4
# activateLfrMode
5
# SVS-0034 (REQ-LFR-SRS-5509)
6
# SSS-CP-FS-320
7
################################################################################
8
# execfile('/opt/PYTHON/lfrverif/LFR_SVS/SVS-0034/activateLfrModeTiming.py')
9
#import sys
10

    
11
## To ensure the imported modified files are properly reloaded.
12
#for mod in sys.modules.values():
13
    #strmod = str(mod)
14
    #if not ('\'PythonQt' in strmod) and not ('\'sys\'' in strmod) and \
15
        #not ('\'pygments.' in strmod) and \
16
        #not ('\'__main__\'' in strmod) and not ('\'paste\'' in strmod) and \
17
        #not ('\'/usr/lib64/python2.7/' in strmod) and not(mod is None):
18
    ##if ('\'lfrverif' in strmod):
19
        #print mod
20
        #reload(mod)
21

    
22
import inspect
23
from lfrverif.common.param import *
24
#import time
25
#from datetime import datetime
26

    
27
import time
28
import lfrcompliance.common.socfunctions as socfunctions
29
import lfrcompliance.tcpackets.telecommands as tc
30
from   lfrcompliance.tcpackets.constants import *
31
import lfrcompliance.common.general_functions as gen
32

    
33
# fonction renommee pour ne pas utilisee celle de /opt/PYTHON_PLE
34
# Repertoire qui evolue en temps-reel
35
def my_setTimeGenval( soc ):
36

    
37
        # flush the transmission before changing the spacewire link
38
        soc.flushTCTransmission()
39
        soc.setSpaceWireLink( 2 )
40

    
41
        # get the local time with the following reference date: Jan 01 2000
42
        #localTime = gen.getLocalTimeInDPUFormat()
43
        # Utiliser la bonne fct de paul qui prend un argument
44
        localTime = 457571799
45

    
46
        # build the TC that will be sent to the timegen system
47
        tcUpdateTime = tc.TCLFRUpdateTime(DEFAULT_SEQUENCE_COUNT, RPW_INTERNAL, localTime)
48

    
49
        # send the local time to the system time generator
50
        soc.sendTC( tcUpdateTime )
51

    
52
        # flush the transmission before changing the spacewire link
53
        soc.flushTCTransmission()
54
        soc.setSpaceWireLink( 1 )
55

    
56

    
57
# setting up LPPMON plugins
58
from __main__ import proxy
59
if not(proxy.instanceExists("SpwPlugin0")):
60
        proxy.loadSysDriver("SpwPlugin","SpwPlugin0")
61
        SpwPlugin0.selectBridge("STAR-Dundee Spw USB Brick")
62

    
63
        proxy.loadSysDriverToParent("dsu3plugin","SpwPlugin0")
64
        proxy.loadSysDriverToParent("LFRControlPlugin","SpwPlugin0")
65

    
66
        availableBrickCount = SpwPlugin0.StarDundeeGetAvailableBrickCount()
67
        print str(availableBrickCount) + " SpaceWire brick(s) found"
68

    
69
        SpwPlugin0.StarDundeeSelectBrick(1)
70
        SpwPlugin0.StarDundeeSetBrickAsARouter(1)
71
        SpwPlugin0.connectBridge()
72

    
73
        #SpwPlugin0.TCPServerSetIP("127.0.0.1")
74
        SpwPlugin0.TCPServerConnect()
75

    
76
        # OPEN SPACEWIRE SERVER
77
        #LFRControlPlugin0.SetSpwServerIP(129,104,27,164)
78
        LFRControlPlugin0.TCPServerConnect()
79

    
80
        # OPEN TM ECHO BRIDGE SERVER
81
        LFRControlPlugin0.TMEchoBridgeOpenPort()
82

    
83
        # LOAD TIMEGEN USING  LINK 2
84
        SpwPlugin0.StarDundeeSelectLinkNumber( 2 )
85
        dsu3plugin0.openFile(TIMEGEN_PATH)
86
        dsu3plugin0.loadFile()
87
        dsu3plugin0.run()
88

    
89
        # LOAD FSW USING LINK 1
90
        SpwPlugin0.StarDundeeSelectLinkNumber( 1 )
91
        dsu3plugin0.openFile(LFR_FSW_PATH)
92
        dsu3plugin0.loadFile()
93
        dsu3plugin0.run()
94

    
95
        # START SENDING TIMECODES AT 1 Hz
96
        SpwPlugin0.StarDundeeStartTimecodes( 1 )
97

    
98
from __main__ import SpwPlugin0
99

    
100
from lfrverif.common.actions_tc_lfr_launcher import *
101
from lfrverif.common.test_monitor import time_sent
102
from lfrverif.common.miscellaneous.fun_misc import *
103

    
104
current_file = inspect.currentframe().f_code.co_filename
105

    
106
test_launcher = TestLauncher(LFRControlPlugin0)
107
test_launcher.test_monitor.log_memo(current_file)
108

    
109
test_launcher.test_monitor.progress_memo += (
110
    "SocExplorerEngine.getSocExplorer: Version = " + SocExplorerEngine.getSocExplorerVersion() +
111
    ", Branch = " + SocExplorerEngine.getSocExplorerBranch() +
112
    ", Changeset = " + SocExplorerEngine.getSocExplorerChangeset() + '\n')
113

    
114
ACK_EXECUTION_COMPLETION = 1
115
ACK_ACCEPTANCE = 1
116
SOURCE_ID = SOURCE_ID_ENUM[0]
117

    
118
rk10 = SPW_HEADER_SIZE + 10
119
rk11 = SPW_HEADER_SIZE + 11
120
rk12 = SPW_HEADER_SIZE + 12
121
rk14 = SPW_HEADER_SIZE + 14
122
rk16 = SPW_HEADER_SIZE + 16
123
rk18 = SPW_HEADER_SIZE + 18
124
log_time = ""
125

    
126

    
127
# Gerald dit de remplacer cette code
128
#postponeNextTimeBeforeTc(1)
129
surveyAnyTmPacket(test_launcher, 1)
130

    
131
tc_lfr_enter_mode = TcLfrEnterMode()
132
tc_lfr_update_time = TcLfrUpdateTime()
133

    
134
init_tc_header([tc_lfr_enter_mode, tc_lfr_update_time],
135
    ACK_EXECUTION_COMPLETION, ACK_ACCEPTANCE, SOURCE_ID)
136

    
137
# For this TC, Msb of byte 11 is used (for spare)
138
spare = tc_lfr_enter_mode.SpW[SPW_HEADER_SIZE + 11] & 0xf0
139

    
140
# Initial mode is NORMAL (ie cp_lfr_mode=1):
141
tc_lfr_enter_mode.SpW[rk11] = spare | 1
142
tc_lfr_enter_mode.ComputeCrc()
143

    
144
#tc_lfr_enter_mode.SpW[rk12:rk18] = CUC0[:]
145
dispCrcSendSpwTcWaitVerifPkt(test_launcher, tc_lfr_enter_mode)
146
surveyAnyTmPacket(test_launcher, 2)  # delay to verify the current mode
147

    
148
#    cp_rpw_time_aux = 0x7fffffff & random.randrange(0xffffffff)
149
#    tc_lfr_update_time.SpW[rk10:rk14] =\
150
#        [(cp_rpw_time_aux >> 24) & 0xff, (cp_rpw_time_aux >> 16) & 0xff,
151
#        (cp_rpw_time_aux >> 8) & 0xff, cp_rpw_time_aux & 0xff]
152
#    tc_lfr_update_time.ComputeCrc()
153
#    displayInfoSendTc(test_launcher, tc_lfr_update_time)
154
#    surveyAnyTmPacket(test_launcher, SY_RPW_CTR_FREQUENCY)
155

    
156
# je me mets au 1er juillet 2014
157
# 23h10 = 0x1B45 FD97 0000
158
# en decimal 457571799
159
# create a SocFunction object to access SocEplorer
160
soc = socfunctions.SocFunctions( LFRControlPlugin0, SpwPlugin0 )
161
my_setTimeGenval( soc )
162

    
163
# Wait to time takes place
164
surveyAnyTmPacket(test_launcher, 5)
165

    
166
#tc_lfr_update_time.SpW[rk10:rk14] = [ 0x1B,0x45,0xfd,0x97]
167
#tc_lfr_update_time.ComputeCrc()
168
#dispCrcSendSpwTcSurvey(test_launcher, tc_lfr_update_time)
169
#surveyAnyTmPacket(test_launcher, .3)
170

    
171
#RMAPPlugin0.sendOneTimecode()
172
surveyAnyTmPacket(test_launcher, 340)
173

    
174

    
175
f_detail = open('lfr_internal_time.txt', 'w')
176
f_detail.write(log_time)
177
f_detail.close()
178

    
179
# Final mode in STANDBY (ie cp_lfr_mode=0):
180
tc_lfr_enter_mode.SpW[rk11] = spare
181
tc_lfr_enter_mode.SpW[rk12:rk18] = CUC0[:]
182
dispCrcSendSpwTcWaitVerifPkt(test_launcher, tc_lfr_enter_mode)
183
surveyAnyTmPacket(test_launcher, 1)  # delay to verify the current mode
184

    
185
test_launcher.test_monitor.log_memo("End(" + current_file + ")")
186
test_launcher.test_monitor.archivalRecord()
(8-8/8)